public abstract class AbstractThreadedObservablePlugin extends AbstractObservablePlugin
ObservablePlugin.PluginObserver
Modifier and Type | Field and Description |
---|---|
protected long |
threadWaitTimeout
Thread wait timeout in ms
|
readers
Modifier | Constructor and Description |
---|---|
protected |
AbstractThreadedObservablePlugin(java.lang.String name)
Instantiates a threaded observable plugin.
|
Modifier and Type | Method and Description |
---|---|
void |
addObserver(ObservablePlugin.PluginObserver observer)
Add a plugin observer.
|
void |
clearObservers()
Remove all observers at once
|
protected abstract Reader |
fetchNativeReader(java.lang.String name)
Fetch connected native reader (from third party library) by its name Returns the current
AbstractReader if it is already listed. |
protected abstract java.util.SortedSet<java.lang.String> |
fetchNativeReadersNames()
Fetch the list of connected native reader (usually from third party library) and returns their
names (or id)
|
protected abstract PluginObservationExceptionHandler |
getObservationExceptionHandler()
Allows to call the defined handler when an exception condition needs to be transmitted to the
application level.
|
void |
removeObserver(ObservablePlugin.PluginObserver observer)
Remove a plugin observer.
|
countObservers, notifyObservers, unregister
getName, getReader, getReaderNames, getReaders, initNativeReaders, register
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName, getReader, getReaderNames, getReaders
protected long threadWaitTimeout
This timeout value will determined the latency to detect changes
protected AbstractThreadedObservablePlugin(java.lang.String name)
name
- name of the pluginKeypleReaderException
- when an issue is raised with readerprotected abstract java.util.SortedSet<java.lang.String> fetchNativeReadersNames()
KeypleReaderIOException
- if the communication with the reader or the card has failedprotected abstract Reader fetchNativeReader(java.lang.String name)
AbstractReader
if it is already listed. Creates and returns a new AbstractReader
if
not.name
- the reader nameKeypleReaderNotFoundException
- if the reader was not found by its nameKeypleReaderIOException
- if the communication with the reader or the card has failedpublic final void addObserver(ObservablePlugin.PluginObserver observer)
Overrides the method defined in AbstractObservablePlugin
, a thread is created if it
does not already exist (when the first observer is added).
Register the PluginObservationExceptionHandler
returned by the plugin implementation
of getObservationExceptionHandler as an uncaught exception handler.
addObserver
in interface ObservablePlugin
addObserver
in class AbstractObservablePlugin
observer
- the observer objectjava.lang.IllegalStateException
- If observer is null or no PluginObservationExceptionHandler
has been set.public final void removeObserver(ObservablePlugin.PluginObserver observer)
Overrides the method defined in AbstractObservablePlugin
, the monitoring thread is
ended when the last observer is removed.
removeObserver
in interface ObservablePlugin
removeObserver
in class AbstractObservablePlugin
observer
- the observer objectpublic final void clearObservers()
In addition to the super method in AbstractObservablePlugin
, the thread is ended.
clearObservers
in interface ObservablePlugin
clearObservers
in class AbstractObservablePlugin
protected abstract PluginObservationExceptionHandler getObservationExceptionHandler()
Must be implemented by the plugin provider.
PluginObservationExceptionHandler
interface.