ome.services.licenses
Class Store

java.lang.Object
  extended by ome.services.licenses.Store
All Implemented Interfaces:
ServiceInterface, ILicense, LicenseStore

public class Store
extends Object
implements LicenseStore

Example LicenseStore implementation. NOT INTENDED FOR PRODUCTION USE.

Since:
3.0-Beta1
Author:
Josh Moore, josh at glencoesoftware.com

Constructor Summary
Store()
           
Store(int count)
           
Store(int total, int used)
           
 
Method Summary
 byte[] acquireLicense()
          Reserves a license for the current user.
 void enterMethod(byte[] token, Principal p)
          Increments the number of currently active methods associated with a single license and prevents timeouts during the method call.
 void exitMethod(byte[] token, Principal p)
          Decrements the number of active methods associated with a single license and timestamps the last use of the license.
 long getAvailableLicenseCount()
          Returns the number of licenses which can currently be acquired.
 long getLicenseTimeout()
          Returns the timeout per license as interpreted by the LicenseStore implementation.
 TokenInfo getToken(byte[] token)
           
 long getTotalLicenseCount()
          Returns the total number of licenses which the server has.
 boolean hasLicense(byte[] token)
          Checks for the validity of a token and that the Not responsible for timeouts.
 boolean releaseLicense(byte[] token)
          Frees a license for re-reservation via ILicense.acquireLicense().
 void resetLicenses()
          Administrative method to clear all active licenses and possibly to re-initialize the LicenseStore.
 void setLicenseCount(int count)
           
 void setSessionManager(SessionManager sessionManager)
          See {@link LicenseStore#setSessionManager(SessionManager)
 void setStaticSecuritySystem(SecuritySystem securitySystem)
          See LicenseStore.setStaticSecuritySystem(SecuritySystem)
 void setUsedLicenses(int count)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Store

public Store()

Store

public Store(int count)

Store

public Store(int total,
             int used)
Method Detail

setStaticSecuritySystem

public void setStaticSecuritySystem(SecuritySystem securitySystem)
See LicenseStore.setStaticSecuritySystem(SecuritySystem)

Specified by:
setStaticSecuritySystem in interface LicenseStore

setSessionManager

public void setSessionManager(SessionManager sessionManager)
See {@link LicenseStore#setSessionManager(SessionManager)

Specified by:
setSessionManager in interface LicenseStore

setLicenseCount

public void setLicenseCount(int count)

setUsedLicenses

public void setUsedLicenses(int count)

getToken

public TokenInfo getToken(byte[] token)

enterMethod

public void enterMethod(byte[] token,
                        Principal p)
Description copied from interface: LicenseStore
Increments the number of currently active methods associated with a single license and prevents timeouts during the method call. Required to call LicenseStore.hasLicense(byte[]) within its synchronization boundaries, also responsible for timeouts.

Specified by:
enterMethod in interface LicenseStore

exitMethod

public void exitMethod(byte[] token,
                       Principal p)
Description copied from interface: LicenseStore
Decrements the number of active methods associated with a single license and timestamps the last use of the license.

Specified by:
exitMethod in interface LicenseStore

acquireLicense

public byte[] acquireLicense()
Description copied from interface: ILicense
Reserves a license for the current user. The token returned must likely be presented on each subsequent method call if the LicenseWiring interceptor is in effect. Licenses may timeout depending on the LicenseStore implementation. Clients should be ready to handle exceptions on any method call. Licenses should also be released when possible so that other users can access the server.

Specified by:
acquireLicense in interface ILicense

getAvailableLicenseCount

public long getAvailableLicenseCount()
Description copied from interface: ILicense
Returns the number of licenses which can currently be acquired. There is no guarantee that the number will remain constant before the next call, and therefore clients should be prepared to handle exceptions during acquisition. No guarantee is given on the interpretation of licenses used. Refer to the LicenseStore implementation for more details. For example, a power-user may consume more than one license per acquisition.

Specified by:
getAvailableLicenseCount in interface ILicense

getTotalLicenseCount

public long getTotalLicenseCount()
Description copied from interface: ILicense
Returns the total number of licenses which the server has. This number is relatively constant, but can be changed via a call to ILicense.resetLicenses()

Specified by:
getTotalLicenseCount in interface ILicense

getLicenseTimeout

public long getLicenseTimeout()
Description copied from interface: ILicense
Returns the timeout per license as interpreted by the LicenseStore implementation. Please refer there for more information.

Specified by:
getLicenseTimeout in interface ILicense

hasLicense

public boolean hasLicense(byte[] token)
Description copied from interface: LicenseStore
Checks for the validity of a token and that the Not responsible for timeouts.

Specified by:
hasLicense in interface LicenseStore

releaseLicense

public boolean releaseLicense(byte[] token)
Description copied from interface: ILicense
Frees a license for re-reservation via ILicense.acquireLicense(). If the license is invalid, no exception is thrown, but rather a false value returned.

Specified by:
releaseLicense in interface ILicense

resetLicenses

public void resetLicenses()
Description copied from interface: ILicense
Administrative method to clear all active licenses and possibly to re-initialize the LicenseStore. This may include a change to the internal settings such as license count or timeout.

Specified by:
resetLicenses in interface ILicense


OmeroJava Api

Version: Beta-4.1.1-r5927-b91

Copyright © 2009 The University of Dundee. All Rights Reserved.