Coding a Commuter License

Declare Variables/Constants

String FEATURE_NAME = "FeatureCommuter";
String CONTACT_SERVER = "localhost";
String LOCK_SELECTOR = "0x04";
Attribute attrAppContext = null;
ApplicationContext appContext = null;
String transferActionCommute = "<commute>"+ 
                               "<featureName>"+FEATURE_NAME+"</featureName>"+ 
                               "<featureVersion>"FEATURE_VERSION"</featureVersion>"+
                               "<duration>5</duration>"+
                               "</commute>";
 
String scopeRecipientInfo= "<sentinelScope>"+ 
                           "<lockSelector>"+LOCK_SELECTOR+"</lockSelector>"+ 
                           "</sentinelScope>";

API Calls

To install a commuter license, execute the APIs in the specified sequential order only:

>attrAppContext = new Attribute();

>attrAppContext.set(LicensingConstants.SNTL_ATTR_APPCONTEXT_CONTACT_SERVER, CONTACT_SERVER);

NOTE   If instead the LSFORCEHOST or LSHOST environment variables are set, then the above mentioned steps are not required.

>appContext = new ApplicationContext(attrAppContext);

>String recipientInfo = appContext.getInfo(scopeRecipientInfo, LicensingConstants. SNTL_QUERY_RECIPIENT_INFO_VERSION("1.0")) ;

>String commuterLicenseString = appContext.transfer(transferActionCommute, null, null, RecipientInfo);

>appContext.install(commuterLicenseString,null);

Notes

>Once the commuter license is installed successfully using appContext.install, it can be requested in the similar way as any license is requested in standalone licensing environment.

>The SNTL_QUERY_RECIPIENT_INFO_VERSION("1.0") constant is defined in the LicensingConstants.cs file.