public class DefaultLicenseListener extends Object implements LicenseListener
LicenseListener
interface which
prints out details of how the licensed connections are being used. It may be
used for debugging of license usage or also for tracking of the connection pool
traffic (see RemoteDesktopClientFactory
).T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Constructor and Description |
---|
DefaultLicenseListener()
Default constructor which constructs a listener instance which prints
out the debug messages into the console (
System.out ). |
DefaultLicenseListener(String preferenceKey,
PrintStream outStream)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
licenseReleased(LicenseEvent event)
This method gets called when a seat (connection) is released.
|
void |
licenseStatus(LicenseEvent event)
This method has several purposes.
|
void |
licenseUtilized(LicenseEvent event)
This method gets called when a seat (connection) is utilized by a connection
to a desktop.
|
void |
print(LicenseEvent event)
Print a license event to the print stream.
|
public DefaultLicenseListener()
System.out
).public DefaultLicenseListener(String preferenceKey, PrintStream outStream)
preferenceKey
- an optional preference key to enable/disable writing
of the debug messages. If the parameter is not null, the listener makes an
attempt to load a boolean value with the given key from the user preferences
object. If the value exists and is 'false', the listener disables printing of
the messages. This makes the listener configurable in a global way even
for objects which do not have reference to the listener. Example:
ApplicationSupport app = new ApplicationSupport(); app.addLicenseListener(new DefaultLicenseListener("mylicenselistener", System.out)); ... // Disable the listener UserConfiguration.getInstance().setBoolean("mylicenselistener", Boolean.FALSE); // Enable the listener UserConfiguration.getInstance().setBoolean("mylicenselistener", Boolean.TRUE);
outStream
- custom output stream for the debug messages. If the argument is
null, the listener defaults to System.out
.public void print(LicenseEvent event)
event
- a license event.public void licenseStatus(LicenseEvent event)
LicenseListener
This method has several purposes. First of all it is called immediately
when the listener registers for license notifications through
ApplicationSupport.addLicenseListener(com.tplan.robot.LicenseListener)
with the event type of LicenseEvent.TYPE_STATUS
.
The method then gets called when the status of the desktop clients changes without an immediate impact on the overall license number status. These changes include these type events:
LicenseEvent.TYPE_POOLED
type is fired when a connection is pooled.
Reuse of the connection and its removal from the pool fires a LicenseEvent.TYPE_REUSED
event.
Though these events mean no change to the license status because pooled connections keep holding the license seat,
it is useful for debugging of the pool mechanism. Be aware that this
behavior is subject to configuration and this type of event may be never
fired if this feature is set off. See the RemoteDesktopClientFactory
class
for details on connection pooling.LicenseEvent.TYPE_WAITING
type is fired in a situation
when the number of licenses is already exhausted and the client requesting
a license seat is queued to wait for a released license. Be aware that this
behavior is subject to configuration and this type of event may be never
fired if this feature is set off.licenseStatus
in interface LicenseListener
event
- license event providing the initial information about the total number
of licensed seats (connections) as well as the free ones.public void licenseReleased(LicenseEvent event)
LicenseListener
licenseReleased
in interface LicenseListener
event
- license event with information about license numbers
and a reference to the desktop client which released the seat.public void licenseUtilized(LicenseEvent event)
LicenseListener
licenseUtilized
in interface LicenseListener
event
- license event with information about license numbers
and a reference to the desktop client which reserved the seat.