com.ibm.as400.access
Class ProductLicense

java.lang.Object
  extended by com.ibm.as400.access.ProductLicense
All Implemented Interfaces:
Serializable

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.

Example

        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.)
        }

 

See Also:
Serialized Form

Field Summary
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 Summary
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.
 
Method Summary
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

USAGE_CONCURRENT

public static final int USAGE_CONCURRENT
Value for license usage type, concurrent usage license type.

See Also:
Constant Field Values

USAGE_REGISTERED

public static final int USAGE_REGISTERED
Value for license usage type, registered usage license type.

See Also:
Constant Field Values

COMPLIANCE_OPERATOR_ACTION

public static final 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.)

See Also:
Constant Field Values

COMPLIANCE_WARNING

public static final 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.

See Also:
Constant Field Values

COMPLIANCE_KEYED

public static final int COMPLIANCE_KEYED
Value for compliance type, keyed compliance indicates a license that requires a license key to activate the license.

See Also:
Constant Field Values

CONDITION_OK

public static final int CONDITION_OK
Value for license condition, license granted.

See Also:
Constant Field Values

CONDITION_EXCEEDED_OK

public static final int CONDITION_EXCEEDED_OK
Value for license condition, usage limit exceeded, but not enforced.

See Also:
Constant Field Values

CONDITION_EXCEEDED_GRACE_PERIOD

public static final int CONDITION_EXCEEDED_GRACE_PERIOD
Value for license condition, usage limit exceeded, but within grace period.

See Also:
Constant Field Values

CONDITION_GRACE_PERIOD_EXPIRED

public static final int CONDITION_GRACE_PERIOD_EXPIRED
Value for license condition, usage limit exceeded and grace period expired, but not enforced.

See Also:
Constant Field Values
Constructor Detail

ProductLicense

public ProductLicense()
Constructs a default ProductLicense object. The system, product, feature and release must be set for requesting a license.


ProductLicense

public ProductLicense(AS400 system,
                      String productID,
                      String featureID,
                      String release)
Constructs a ProductLicense object for a system, product, feature, and release.

Parameters:
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

addProductLicenseListener

public void addProductLicenseListener(ProductLicenseListener listener)
Adds a file listener to receive file events from this IFSFile.

Parameters:
listener - The file listener.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a property change listener.

Parameters:
listener - The property change listener to add.

finalize

protected void finalize()
The finalizer.

Overrides:
finalize in class Object

getComplianceType

public int getComplianceType()
Returns the compliance type for this license. Possible values are COMPLIANCE_OPERATOR_ACTION, COMPLIANCE_WARNING and COMPLIANCE_KEYED. A license must have been requested prior to calling this method.

Returns:
The compliance type.

getCondition

public int getCondition()
Returns the condition of the license. Possible values are CONDITION_OK, CONDITION_EXCEEDED_OK, CONDITION_EXCEEDED_GRACE_PERIOD, and CONDITION_GRACE_EXPIRED. A license must have been requested prior to calling this method.

Returns:
The license condition.

getFeature

public String getFeature()
Returns the feature identifier for this license.

Returns:
The feature identifier.

getLicenseTerm

public String getLicenseTerm()
Returns the license term for this license. A license must have been requested prior to calling this method.

Returns:
The license term.

getProductID

public String getProductID()
Returns the product identifier for this license.

Returns:
The product identifier.

getReleaseLevel

public String getReleaseLevel()
Returns the release level for this license.

Returns:
The release level.

getSystem

public AS400 getSystem()
Returns the system object for this license.

Returns:
The system.

getUsageCount

public int getUsageCount()
Returns the usage count for this license. The count returned is the number of licenses that are in use on the system for that product ID, feature, and release when this license was requested. A license must have been requested prior to calling this method.

Returns:
The usage count when this license was retrieved.

getUsageLimit

public int getUsageLimit()
Returns the usage limit for this license.A license must have been requested prior to calling this method.

Returns:
The usage limit.

getUsageType

public int getUsageType()
Returns the usage type for this license. Possible values are USAGE_CONCURRENT and USAGE_REGISTERED. A license must have been requested prior to calling this method.

Returns:
The usage type.

release

public void release()
             throws IOException,
                    InterruptedException,
                    LicenseException
Release this license. This method must be called to release the license. Failure to do so may result in incorrect license usage count. Calling this method will disconnect from the IBM i Optimized License Management server.

Throws:
IOException - If an error occurs while communicating with the system.
InterruptedException - If this thread is interrupted.
LicenseException - If a license error occurs.

request

public int request()
            throws IOException,
                   AS400SecurityException,
                   InterruptedException,
                   LicenseException
Request a license.

Throws:
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.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes this listener from being notified when a bound property changes.

Parameters:
listener - The PropertyChangeListener.

removeProductLicenseListener

public void removeProductLicenseListener(ProductLicenseListener listener)
Removes a listener from the ProductLicense listeners list.

Parameters:
listener - The product license listener.

setFeature

public void setFeature(String featureID)
Sets the feature identifier for this license.

Parameters:
featureID - the product feature. For example, "5050".

setProductID

public void setProductID(String productID)
Sets the product identifier for this license.

Parameters:
productID - the product identifier. For example, "5769JC1".

setReleaseLevel

public void setReleaseLevel(String releaseLevel)
Sets the product release for this license.

Parameters:
releaseLevel - the product release. For example, "V4R5M0".

setSystem

public void setSystem(AS400 system)
Sets the system object for this license.

Parameters:
system - the system from which the license will be requested.