com.jp.protection.pub.pro.lserver
Class BasicLicensingServiceProvider

java.lang.Object
  extended by com.jp.protection.pub.pro.lserver.BasicLicensingServiceProvider
All Implemented Interfaces:
LicensingServiceProvider

public abstract class BasicLicensingServiceProvider
extends java.lang.Object
implements LicensingServiceProvider

Basic implementation of the LicensingServiceProvider interface. This class contains number of helper methods allowing for easy building actual implementations which are based on BasicLicensingServiceProvider.

Since:
3.0

Nested Class Summary
protected  class BasicLicensingServiceProvider.LicensingServiceProxy
           
 
Field Summary
protected  java.lang.String fAddress
           
protected  java.util.Map fAttributes
           
protected  boolean fConfirmLicenseLocks
           
protected  java.lang.Thread fConfirmLicenseLocksThread
           
protected  boolean fDefault
           
protected  java.util.List fLicensingServices
           
protected  LicensingServiceProviderListenerSupport fListenerSupport
           
protected  java.util.Map fProxyLicensingServiceMap
           
protected  java.util.HashMap fTicketLicenseDataMap
           
protected  java.util.HashMap fTicketMap
           
 
Constructor Summary
BasicLicensingServiceProvider()
          Creates a new instance of the BasicLicensingServiceProvider
 
Method Summary
 void addLicensingServiceProviderListener(LicensingServiceProviderListener l)
          Adds a listener to the listeners list
protected  void addTicket(LicensingService aLicensingService, java.lang.String aTicket, LicenseData aLicenseData)
           
protected  boolean confirmLicenseLocks(LicensingService aLicensingService, java.util.Map anAttributes)
           
protected  boolean confirmLicenseLocks(java.util.Map anAttributes)
           
 LicensingService createLicensingService(java.util.Map anAttributes)
          Creates a new instance of the Licensing Service
protected abstract  LicensingService createLicensingServiceImpl(java.util.Map anAttributes)
           
protected  LicensingService createLicensingServiceProxy(LicensingService aLicensingService)
           
protected  LicenseData getLicenseData(java.lang.String aTicket)
           
protected  long getLicenseLockConfirmPeriod()
           
static java.lang.String getMessage(java.lang.Throwable ex)
          Returns user-friendly formatted initmessage for the given exception
protected  java.util.Set getTickets(LicensingService aLicensingService)
           
 void init(java.lang.String anAddress, java.util.Map anAttributes)
          Initializes the provider instance
 boolean isConfirmLicenseLocks()
          Returns whether provider automatically (in background) confirms all acquired license locks
 boolean isDefault()
          Returns whether this provider is a default provider
 void release()
          Releases provider and of all associated recourses including the Licensing Services created by the provider
 void releaseLicensingService(LicensingService aLicensingService)
          Releases a Licensing Service and all of the associated resources including the license locks acquired by the service
protected abstract  void releaseLicensingServiceImpl(LicensingService aLicensingService)
           
 void removeLicensingServiceProviderListener(LicensingServiceProviderListener l)
          Removes the listener from the listeners list
protected  void removeTicket(LicensingService aLicensingService, java.lang.String aTicket)
           
 void setConfirmLicenseLocks(boolean aConfirmLicenseLocks)
          Specifies whether the provider should automatically (in the background) confirm all acquired license locks
 void setConfirmLicenseLocks(boolean aConfirmLicenseLocks, java.util.Map anAttributes)
          Specifies whether the provider should automatically (in the background) confirm all acquired license locks
 void setDefault(boolean aDefault)
          Specifies that this provider should be default one
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fAddress

protected java.lang.String fAddress

fAttributes

protected java.util.Map fAttributes

fProxyLicensingServiceMap

protected java.util.Map fProxyLicensingServiceMap

fConfirmLicenseLocks

protected boolean fConfirmLicenseLocks

fConfirmLicenseLocksThread

protected java.lang.Thread fConfirmLicenseLocksThread

fLicensingServices

protected java.util.List fLicensingServices

fTicketMap

protected java.util.HashMap fTicketMap

fTicketLicenseDataMap

protected java.util.HashMap fTicketLicenseDataMap

fDefault

protected boolean fDefault

fListenerSupport

protected transient LicensingServiceProviderListenerSupport fListenerSupport
Constructor Detail

BasicLicensingServiceProvider

public BasicLicensingServiceProvider()
Creates a new instance of the BasicLicensingServiceProvider

Method Detail

createLicensingServiceProxy

protected LicensingService createLicensingServiceProxy(LicensingService aLicensingService)

init

public void init(java.lang.String anAddress,
                 java.util.Map anAttributes)
Description copied from interface: LicensingServiceProvider
Initializes the provider instance

Specified by:
init in interface LicensingServiceProvider
Parameters:
anAddress - address of the Licensing Server to connect
anAttributes - initialization attributes

createLicensingService

public LicensingService createLicensingService(java.util.Map anAttributes)
Description copied from interface: LicensingServiceProvider
Creates a new instance of the Licensing Service

Specified by:
createLicensingService in interface LicensingServiceProvider
Parameters:
anAttributes - attributes (identified by LicensingService.ATTR_ keys) which describe client environment.
Returns:
new instance of the Licensing Service

createLicensingServiceImpl

protected abstract LicensingService createLicensingServiceImpl(java.util.Map anAttributes)

releaseLicensingServiceImpl

protected abstract void releaseLicensingServiceImpl(LicensingService aLicensingService)

releaseLicensingService

public void releaseLicensingService(LicensingService aLicensingService)
Description copied from interface: LicensingServiceProvider
Releases a Licensing Service and all of the associated resources including the license locks acquired by the service

Specified by:
releaseLicensingService in interface LicensingServiceProvider
Parameters:
aLicensingService - a Licensing Service to release

release

public void release()
Description copied from interface: LicensingServiceProvider
Releases provider and of all associated recourses including the Licensing Services created by the provider

Specified by:
release in interface LicensingServiceProvider

confirmLicenseLocks

protected boolean confirmLicenseLocks(java.util.Map anAttributes)

confirmLicenseLocks

protected boolean confirmLicenseLocks(LicensingService aLicensingService,
                                      java.util.Map anAttributes)

isConfirmLicenseLocks

public boolean isConfirmLicenseLocks()
Returns whether provider automatically (in background) confirms all acquired license locks

Returns:
true if provider automatically (in background) confirms all acquired license locks; false otherwise

setConfirmLicenseLocks

public void setConfirmLicenseLocks(boolean aConfirmLicenseLocks)
Specifies whether the provider should automatically (in the background) confirm all acquired license locks

Parameters:
aConfirmLicenseLocks - true if the provider should automatically (in the background) confirm all acquired license locks; false otherwise

getLicenseLockConfirmPeriod

protected long getLicenseLockConfirmPeriod()

setConfirmLicenseLocks

public void setConfirmLicenseLocks(boolean aConfirmLicenseLocks,
                                   java.util.Map anAttributes)
Specifies whether the provider should automatically (in the background) confirm all acquired license locks

Parameters:
aConfirmLicenseLocks - true if the provider should automatically (in the background) confirm all acquired license locks; false otherwise
anAttributes - attributes to pass to confirmLicenseLock(...) method of Licensing Service

getTickets

protected java.util.Set getTickets(LicensingService aLicensingService)

getLicenseData

protected LicenseData getLicenseData(java.lang.String aTicket)

addTicket

protected void addTicket(LicensingService aLicensingService,
                         java.lang.String aTicket,
                         LicenseData aLicenseData)

removeTicket

protected void removeTicket(LicensingService aLicensingService,
                            java.lang.String aTicket)

isDefault

public boolean isDefault()
Description copied from interface: LicensingServiceProvider
Returns whether this provider is a default provider

Specified by:
isDefault in interface LicensingServiceProvider
Returns:
true if this provider is default; false otherwise

setDefault

public void setDefault(boolean aDefault)
Specifies that this provider should be default one

Parameters:
aDefault - true if this provider should be default one; false otherwise

addLicensingServiceProviderListener

public void addLicensingServiceProviderListener(LicensingServiceProviderListener l)
Description copied from interface: LicensingServiceProvider
Adds a listener to the listeners list

Specified by:
addLicensingServiceProviderListener in interface LicensingServiceProvider
Parameters:
l - listener to add

removeLicensingServiceProviderListener

public void removeLicensingServiceProviderListener(LicensingServiceProviderListener l)
Description copied from interface: LicensingServiceProvider
Removes the listener from the listeners list

Specified by:
removeLicensingServiceProviderListener in interface LicensingServiceProvider
Parameters:
l - listener to remove

getMessage

public static java.lang.String getMessage(java.lang.Throwable ex)
Returns user-friendly formatted initmessage for the given exception

Parameters:
ex - exception to return message for
Returns:
message