com.ibm.as400.access

Class ProductLicense

  • All Implemented Interfaces:
    Serializable


    public class ProductLicense
    extends Object
    implements Serializable
    Represents a license for a product on the IBM i system. 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;
                    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.)
            }
    
     
    See Also:
    Serialized Form
    • 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.
      • 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.