Package opencard.core.terminal
Class CardTerminalRegistry
- java.lang.Object
-
- opencard.core.terminal.CardTerminalRegistry
-
public final class CardTerminalRegistry extends java.lang.ObjectThe CardTerminalRegistry keeps track of the installed CardTerminals registered within a system. You can get an enumeration of the registered CardTerminals via CardTerminalRegistry.getCardTerminals().NOTE that there may be a difference between the terminals physically attached to your computer and those registered in the registry.
Using the add()/remove () methods you can dynamically add to and remove card terminals from the registry. Usually however this will be done automatically by SmartCard.start () based on the information provided by the Opencard properties.
- Author:
- Dirk Husemann (hud@zurich.ibm.com), Peter Trommler (trp@zurich.ibm.com), Mike Wendler (mwendler@de.ibm.com), Stephan Breideneich (sbreiden@de.ibm.com)
- See Also:
CardTerminal,CardTerminalFactory,CardID
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashtablectListenerstable with all registered CTListener-objects
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(CardTerminal terminal)Adds a CardTerminal instance to the registry.voidaddCTListener(CTListener listener)Deprecated.use EventGenerator.addCTListenervoidaddPollable(Pollable p)Adds a Pollable card terminal to the observer's list of pollable terminals.protected voidcardInserted(CardTerminal terminal, int slotID)Notify listeners that a card was inserted into a slot of a terminal.protected voidcardRemoved(CardTerminal terminal, int slotID)Notify listeners that a card was removed from a slot of this terminal.CardTerminalcardTerminalForName(java.lang.String name)Iterates over the registered terminals and searches for one with the given name.intcountCardTerminals()Gets the number of registered CardTerminals.voidcreateEventsForPresentCards(CTListener ctListener)Deprecated.use EvenGenerator.createEventsForPresentCardsjava.util.EnumerationgetCardTerminals()Gets all registered CardTerminal instances.intgetPollInterval()Deprecated.static CardTerminalRegistrygetRegistry()Gets the system wide CardTerminalRegistry.booleanremove(java.lang.String name)Remove the card terminal named name.booleanremove(CardTerminal terminal)Closes the card terminal and removes it from the registry.voidremoveCTListener(CTListener listener)Deprecated.use EventGenerator.removeCTListener() insteadbooleanremovePollable(Pollable p)Removes a Pollable card terminal from the observer's list of terminals to be polled.voidsetObserver(Observer o)The Observer is the bridge to the opencard.core.event package which creates events for card insertion/card removalvoidsetPollInterval(int duration)Deprecated.
-
-
-
Method Detail
-
setObserver
public void setObserver(Observer o)
The Observer is the bridge to the opencard.core.event package which creates events for card insertion/card removal
-
getRegistry
public static CardTerminalRegistry getRegistry()
Gets the system wide CardTerminalRegistry. This conforms to the Singleton pattern.- Returns:
- the one system-wide card terminal registry.
-
add
public void add(CardTerminal terminal) throws CardTerminalException
Adds a CardTerminal instance to the registry. Should be called by the CardTerminalFactory when creating a card terminal.- Parameters:
terminal- The CardTerminal to add.- Throws:
thrown- in case of errors in the CardTerminal.open() method.CardTerminalException
-
addPollable
public void addPollable(Pollable p)
Adds a Pollable card terminal to the observer's list of pollable terminals. Should be called by pollable terminals in their open() method.- Parameters:
p- The Pollable terminal to add.
-
cardTerminalForName
public CardTerminal cardTerminalForName(java.lang.String name)
Iterates over the registered terminals and searches for one with the given name.- Parameters:
name- The name of the card terminal to search for.- Returns:
- A CardTerminal instance with name or null if none could be found.
-
countCardTerminals
public int countCardTerminals()
Gets the number of registered CardTerminals.- Returns:
- the number of terminals registered in the registry
-
getCardTerminals
public java.util.Enumeration getCardTerminals()
Gets all registered CardTerminal instances.- Returns:
- An Enumeration of the currently registered CardTerminals.
-
remove
public boolean remove(java.lang.String name) throws CardTerminalExceptionRemove the card terminal named name.- Parameters:
name- The name of the card terminal to unregister.- Returns:
- True if the terminal was unregistered successfully.
- Throws:
CardTerminalException- thrown if error occurred
-
remove
public boolean remove(CardTerminal terminal) throws CardTerminalException
Closes the card terminal and removes it from the registry.- Parameters:
terminal- The reference to the CardTerminal object to unregister.- Returns:
- true if the terminal was removed from the registry successfully, false otherwise
- Throws:
CardTerminalException- thrown when error occurred in terminal.close().- See Also:
CardTerminal.close()
-
removePollable
public boolean removePollable(Pollable p)
Removes a Pollable card terminal from the observer's list of terminals to be polled.- Parameters:
p- The Pollable to be removed.
-
cardInserted
protected void cardInserted(CardTerminal terminal, int slotID)
Notify listeners that a card was inserted into a slot of a terminal.- Parameters:
terminal- terminal where a card was insertedslot- slot where a card was inserted
-
cardRemoved
protected void cardRemoved(CardTerminal terminal, int slotID)
Notify listeners that a card was removed from a slot of this terminal. (utility method).- Parameters:
slot- slot number of the slot where a card was removed
-
setPollInterval
@Deprecated public void setPollInterval(int duration)
Deprecated.
-
addCTListener
@Deprecated public void addCTListener(CTListener listener)
Deprecated.use EventGenerator.addCTListener
-
createEventsForPresentCards
@Deprecated public void createEventsForPresentCards(CTListener ctListener) throws CardTerminalException
Deprecated.use EvenGenerator.createEventsForPresentCards- Throws:
CardTerminalException
-
getPollInterval
@Deprecated public int getPollInterval()
Deprecated.
-
removeCTListener
@Deprecated public void removeCTListener(CTListener listener)
Deprecated.use EventGenerator.removeCTListener() instead
-
-