License Status and Errors


Retrieving and Monitoring License Status


// License status and errors if found
License.getInstance()
                .getStatus()
                .isValid(); // returns boolean

License.getInstance()
                .getStatus()
                .getCode(); // return error code

 License.getInstance()
                .getStatus()
                .getMessage(); // returns a simple descriptive string

The License.getInstance().getStatus() method is the primary mechanism for obtaining the current state of a license, returning a Status object. Within this Status object, the isValid() method provides a boolean indicator of whether the license is currently valid. If isValid() returns false, the system provides a specific error code and a corresponding error message. This detailed feedback is crucial for accurately diagnosing the reasons behind an invalid license status, enabling users or developers to understand and address underlying issues effectively.

To access these specific error details, you can use License.getInstance().getStatus().getCode() for the error code and License.getInstance().getStatus().getMessage() for the descriptive error message.

Real-time License Status Monitoring with Listeners

For dynamic applications or scenarios where license validation occurs in a separate thread, implementing a listener for license status changes is highly recommended. This mechanism allows your application to receive timely notifications whenever the license's status code changes. This is particularly useful for long-running applications that need to react to real-time changes in license validity, such as a license expiring, being disabled by an administrator, or encountering a network issue during validation.

The licensing library automatically initiates a timer task after a successful license activation. For node-locked licenses, the system attempts to re-validate the license daily. For floating licenses, which require more frequent checks due to their concurrent nature, validation attempts occur every 10 minutes. This proactive monitoring ensures that your application remains aware of the license's current state, enabling it to respond appropriately to any changes.

An example of how to add a listener for license status changes is provided below.
// set a listener on license status change
License.getInstance().setStatusChangeListener((status) -> {
    // do anything depending on status
});