Package opencard.core.service
Class CardServiceRegistry
- java.lang.Object
-
- opencard.core.service.CardServiceRegistry
-
public final class CardServiceRegistry extends java.lang.Object
The CardServiceRegistry keeps track of CardServiceFactories . When asked for a certain CardService it searches through its registered CardServiceFactorys to find one which is able to create this. NOTE that there exists only one system-wide instance of this class which can be accessed via CardServiceRegistry.getRegistry ().- Author:
- Dirk Husemann (hud@zurich.ibm.com), Reto Hermann (rhe@zurich.ibm.com), Mike Wendler (mwendler@de.ibm.com), Stephan Breideneich (sbreiden@de.ibm.com), Roland Weber (rolweber@de.ibm.com), Thomas Schaeck (schaeck@de.ibm.com)
- See Also:
CardService
,CardServiceFactory
,CardServiceScheduler
,CardChannel
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(CardServiceFactory factory)
Adds a CardServiceFactory to the registry.protected java.lang.Class
getCardServiceClassFor(java.lang.Class clazz, CardID cid, CardServiceScheduler scheduler)
Gets a CardService class object for clazz.java.util.Enumeration
getCardServiceFactories()
Gets all registered card service factories.protected CardService
getCardServiceInstance(java.lang.Class clazz, CardID cid, CardServiceScheduler scheduler, SmartCard card, boolean block)
Tries to instantiate a CardService that is an instance of clazz and that works with the smart card represented by cid.static CardServiceRegistry
getRegistry()
Gets a reference to the system-wide CardServiceRegistry object ('Singleton' pattern).protected SmartCard
getSmartCard(CardTerminalEvent ctEvent, CardRequest req, java.lang.Object lockHandle)
Gets a SmartCard object based on a received CardTerminalEvent.protected void
releaseScheduler(CardServiceScheduler scheduler)
Releases a CardServiceScheduler.void
remove(CardServiceFactory factory)
Removes the passed CardServiceFactory from the registry.java.lang.String
toString()
Gets a meaningful String representation of this CardServiceRegistry.
-
-
-
Method Detail
-
add
public void add(CardServiceFactory factory)
Adds a CardServiceFactory to the registry.- Parameters:
factory
- The CardServiceFactory to add.
-
getCardServiceClassFor
protected java.lang.Class getCardServiceClassFor(java.lang.Class clazz, CardID cid, CardServiceScheduler scheduler)
Gets a CardService class object for clazz.- Parameters:
clazz
- The class that the requested CardService should be an instance of.cid
- A CardID object representing the smart card for which the CardService is requested.scheduler
- The CardServiceScheduler for the card to be inspected.- Returns:
- The CardService class object if available; otherwise null.
-
getCardServiceFactories
public final java.util.Enumeration getCardServiceFactories()
Gets all registered card service factories. A registered factory is one that has been passed to add, but has not yet been removed using remove.- Returns:
- an enumeration of the registered card service factories
-
getCardServiceInstance
protected CardService getCardServiceInstance(java.lang.Class clazz, CardID cid, CardServiceScheduler scheduler, SmartCard card, boolean block) throws java.lang.ClassNotFoundException
Tries to instantiate a CardService that is an instance of clazz and that works with the smart card represented by cid.- Parameters:
clazz
- The class that the requested CardService should be an instance of.cid
- A CardID object representing the smart card for which the CardService is requested.scheduler
- The controlling CardServiceSchedulercard
- The SmarCard object requesting the CardServiceblock
- Specifies the waiting behavior of the newly created CardService; if true it will wait for CardChannel (i.e., block).- Throws:
java.lang.ClassNotFoundException
- Thrown when no fitting CardService could be found.
-
getRegistry
public static CardServiceRegistry getRegistry()
Gets a reference to the system-wide CardServiceRegistry object ('Singleton' pattern).- Returns:
- Reference to the system-wide CardServiceRegistry.
-
getSmartCard
protected SmartCard getSmartCard(CardTerminalEvent ctEvent, CardRequest req, java.lang.Object lockHandle) throws CardTerminalException
Gets a SmartCard object based on a received CardTerminalEvent.- Parameters:
ctEvent
- A CardTerminalEvent event received from a terminal.req
- A CardRequest object describing what kind of SmartCard is requested.lockHandle
- handle obtained by lock owner when locking the terminal- Returns:
- A SmartCard object or null if not successful.
- Throws:
CardTerminalException
-
releaseScheduler
protected void releaseScheduler(CardServiceScheduler scheduler)
Releases a CardServiceScheduler.- Parameters:
scheduler
- The CardServiceScheduler to release.
-
remove
public void remove(CardServiceFactory factory)
Removes the passed CardServiceFactory from the registry.- Parameters:
factory
- The CardServiceFactory to add.
-
toString
public java.lang.String toString()
Gets a meaningful String representation of this CardServiceRegistry.- Overrides:
toString
in classjava.lang.Object
-
-