|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.as400.access.ProductLicense
public class ProductLicense extends Object implements Serializable
A ProductLicense object represents a license for a product. To request a license, construct a ProductLicense object then invoke the request() method. The caller must keep a reference to the ProductLicense object until the license is no longer needed since the ProductLicense object will release the license when it is garbage collected. Licenses are managed on a per-connection basis. Each ProductLicense object has a separate connection to the system. If the connection ends unexpectedly the system releases the license. To maintain an accurate count, the application should call release() instead of relying on the license being released when the object is garbage collected or when the connection ends. Cleanup during garbage collection and/or system cleanup is not as reliable as calling release().
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; } .. .. // 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,
String productID,
String featureID,
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(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. |
String |
getFeature()
Returns the feature identifier for this license. |
String |
getLicenseTerm()
Returns the license term for this license. |
String |
getProductID()
Returns the product identifier for this license. |
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(PropertyChangeListener listener)
Removes this listener from being notified when a bound property changes. |
int |
request()
Request a license. |
void |
setFeature(String featureID)
Sets the feature identifier for this license. |
void |
setProductID(String productID)
Sets the product identifier for this license. |
void |
setReleaseLevel(String releaseLevel)
Sets the product release for this license. |
void |
setSystem(AS400 system)
Sets the system object for this license. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
public ProductLicense()
public ProductLicense(AS400 system, String productID, String featureID, 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".Method Detail |
---|
public void addProductLicenseListener(ProductLicenseListener listener)
listener
- The file listener.public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- The property change listener to add.protected void finalize()
finalize
in class Object
public int getComplianceType()
public int getCondition()
public String getFeature()
public String getLicenseTerm()
public String getProductID()
public String getReleaseLevel()
public AS400 getSystem()
public int getUsageCount()
public int getUsageLimit()
public int getUsageType()
public void release() throws IOException, InterruptedException, LicenseException
IOException
- If an error occurs while communicating with the system.InterruptedException
- If this thread is interrupted.LicenseException
- If a license error occurs.public int request() throws IOException, AS400SecurityException, InterruptedException, LicenseException
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.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(PropertyChangeListener listener)
listener
- The PropertyChangeListener.public void removeProductLicenseListener(ProductLicenseListener listener)
listener
- The product license listener.public void setFeature(String featureID)
featureID
- the product feature. For example, "5050".public void setProductID(String productID)
productID
- the product identifier. For example, "5769JC1".public void setReleaseLevel(String releaseLevel)
releaseLevel
- the product release. For example, "V4R5M0".public void setSystem(AS400 system)
system
- the system from which the license will be requested.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |