public class ProductLicense
extends java.lang.Object
implements java.io.Serializable
The ProductLicense class does not enforce the license policy. It is up to the application to enforce the policy based on information contained in the ProductLicense object after the license is requested. If a license is not granted, indicated by a LicenseException, it is up to the application to notify the user and not perform the behavior that requires a license.
The ProductLicense object may successfully get a license even though there was an error retrieving the product license. These "soft" errors are usage limit exceeded, but license limit not strictly enforced (CONDITION_EXCEEDED_OK), usage limit exceeded, but within grace period (CONDITION_EXCEED_GRACE_PERIOD) and usage limit exceeded and grace period expired but not strictly enforced (CONDITION_GRACE_PERIOD_EXPIRED.) The application must decide to continue or end the application based on this information.
The request() method will throw a LicenseException if no license is available. If a license is granted, the ProductLicense object contains information about the license such as the compliance type and license condition.
AS400 system = new AS400("myas400"); // request a license for "myproductID" and "myfeatureID" for "myrelease" try { ProductLicense license = new ProductLicense(system, "myproductID", "myfeatureID", "myrelease"); license.request(); switch (license.getCondition()) { case ProductLicense.CONDITION_OK: // license retrieved successfully break; case ProductLicense.CONDITION_EXCEEDED_OK: // usage limit exceeded, but license limit not strictly enforced // issue message but allow to proceed. sendMessage("Usage limit exceeded, but license limit not strictly enforced"); break; case ProductLicense.CONDITION_EXCEEDED_GRACE_PERIOD: // usage limit exceeded, but within grace period // issue message but allow to proceed sendMessage("Usage limit exceeded, but within grace period"); break; case ProductLicense.CONDITION_GRACE_PERIOD_EXPIRED: // usage limit exceeded and grace period expired but not strictly enforced // issue message but allow to proceed sendMessage("Usage limit exceeded and grace period expired but not strictly enforced"); break; default: // Some other condition. // This should never happen, but if it does, display value. sendMessage("Unrecognized condition: " + license.getCondition()); } .. .. // product code... .. .. // release the license license.release(); } catch (LicenseException le) { // handle license failures such as license expired... } catch (Exception e) { // handle general failures (security error, communication error, etc.) }
Modifier and Type | Field and Description |
---|---|
static int |
COMPLIANCE_KEYED
Value for compliance type, keyed compliance indicates a license
that requires a license key to activate the license.
|
static int |
COMPLIANCE_OPERATOR_ACTION
Value for compliance type, operator action compliance indicates a form
of soft compliance that will not allow a license in the usage limit exceeded
case until the operator increases the maximum number of licenses on the system
(this does not require a license key to increase.)
|
static int |
COMPLIANCE_WARNING
Value for compliance type, warning compliance indicates that a
warning message will be sent to the system operators message queue
when a license violation, such as usage limit exceeded is encountered.
|
static int |
CONDITION_EXCEEDED_GRACE_PERIOD
Value for license condition, usage limit exceeded, but within grace period.
|
static int |
CONDITION_EXCEEDED_OK
Value for license condition, usage limit exceeded, but not enforced.
|
static int |
CONDITION_GRACE_PERIOD_EXPIRED
Value for license condition, usage limit exceeded and grace period expired, but not
enforced.
|
static int |
CONDITION_OK
Value for license condition, license granted.
|
static int |
USAGE_CONCURRENT
Value for license usage type, concurrent usage license type.
|
static int |
USAGE_REGISTERED
Value for license usage type, registered usage license type.
|
Constructor and Description |
---|
ProductLicense()
Constructs a default ProductLicense object.
|
ProductLicense(AS400 system,
java.lang.String productID,
java.lang.String featureID,
java.lang.String release)
Constructs a ProductLicense object for a system, product, feature,
and release.
|
Modifier and Type | Method and Description |
---|---|
void |
addProductLicenseListener(ProductLicenseListener listener)
Adds a file listener to receive file events from this IFSFile.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a property change listener.
|
protected void |
finalize()
The finalizer.
|
int |
getComplianceType()
Returns the compliance type for this license.
|
int |
getCondition()
Returns the condition of the license.
|
java.lang.String |
getFeature()
Returns the feature identifier for this license.
|
java.lang.String |
getLicenseTerm()
Returns the license term for this license.
|
java.lang.String |
getProductID()
Returns the product identifier for this license.
|
java.lang.String |
getReleaseLevel()
Returns the release level for this license.
|
AS400 |
getSystem()
Returns the system object for this license.
|
int |
getUsageCount()
Returns the usage count for this license.
|
int |
getUsageLimit()
Returns the usage limit for this license.A license must have been requested prior to
calling this method.
|
int |
getUsageType()
Returns the usage type for this license.
|
void |
release()
Release this license.
|
void |
removeProductLicenseListener(ProductLicenseListener listener)
Removes a listener from the ProductLicense listeners list.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes this listener from being notified when a bound property changes.
|
int |
request()
Request a license.
|
void |
setFeature(java.lang.String featureID)
Sets the feature identifier for this license.
|
void |
setProductID(java.lang.String productID)
Sets the product identifier for this license.
|
void |
setReleaseLevel(java.lang.String releaseLevel)
Sets the product release for this license.
|
void |
setSystem(AS400 system)
Sets the system object for this license.
|
public static final int USAGE_CONCURRENT
public static final int USAGE_REGISTERED
public static final int COMPLIANCE_OPERATOR_ACTION
public static final int COMPLIANCE_WARNING
public static final int COMPLIANCE_KEYED
public static final int CONDITION_OK
public static final int CONDITION_EXCEEDED_OK
public static final int CONDITION_EXCEEDED_GRACE_PERIOD
public static final int CONDITION_GRACE_PERIOD_EXPIRED
public ProductLicense()
public ProductLicense(AS400 system, java.lang.String productID, java.lang.String featureID, java.lang.String release)
system
- the system from which the license will be requested.productID
- the product identifier. For example, "5769JC1".featureID
- the product feature. For example, "5050".release
- the product release. For example, "V4R5M0".public void addProductLicenseListener(ProductLicenseListener listener)
listener
- The file listener.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The property change listener to add.protected void finalize()
finalize
in class java.lang.Object
public int getComplianceType()
public int getCondition()
public java.lang.String getFeature()
public java.lang.String getLicenseTerm()
public java.lang.String getProductID()
public java.lang.String getReleaseLevel()
public AS400 getSystem()
public int getUsageCount()
public int getUsageLimit()
public int getUsageType()
public void release() throws java.io.IOException, java.lang.InterruptedException, LicenseException
java.io.IOException
- If an error occurs while communicating with the system.java.lang.InterruptedException
- If this thread is interrupted.LicenseException
- If a license error occurs.public int request() throws java.io.IOException, AS400SecurityException, java.lang.InterruptedException, LicenseException
java.io.IOException
- If an error occurs while communicating with the system.AS400SecurityException
- Unable to connect due to some problem with the user ID or password used to authenticate.java.lang.InterruptedException
- If this thread is interrupted.LicenseException
- If a license error occurs.ExtendedIllegalStateException
- If a license is requested a second time for the same ProductLicense object.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener.public void removeProductLicenseListener(ProductLicenseListener listener)
listener
- The product license listener.public void setFeature(java.lang.String featureID)
featureID
- the product feature. For example, "5050".public void setProductID(java.lang.String productID)
productID
- the product identifier. For example, "5769JC1".public void setReleaseLevel(java.lang.String releaseLevel)
releaseLevel
- the product release. For example, "V4R5M0".public void setSystem(AS400 system)
system
- the system from which the license will be requested.