Package org.eclipse.keyple.core.service
Interface ObservablePlugin
- All Superinterfaces:
Plugin
Plugin able to observe the connection/disconnection of
CardReader.
Allows registered observers to receive a PluginEvent when a reader is
connected/disconnected.
- Since:
- 2.0.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddObserver(PluginObserverSpi observer) Registers a new observer to be notified when a plugin event occurs.voidUnregisters all observers at once.intProvides the current number of registered observers.voidremoveObserver(PluginObserverSpi observer) Unregisters a plugin observer.voidsetPluginObservationExceptionHandler(PluginObservationExceptionHandlerSpi exceptionHandler) Sets the exception handler.Methods inherited from interface org.eclipse.keyple.core.service.Plugin
findReader, getExtension, getName, getReader, getReaderExtension, getReaderNames, getReaders
-
Method Details
-
addObserver
Registers a new observer to be notified when a plugin event occurs.The provided observer must implement the
PluginObserverSpiinterface to be able to receive the events produced by this plugin (reader connection, disconnection).If applicable, the observation process shall be started when the first observer is added.
- Parameters:
observer- An observer object implementing the required interface (should be not null).- Throws:
IllegalArgumentException- if observer is null.IllegalStateException- if no exception handler is defined.- Since:
- 2.0.0
-
removeObserver
Unregisters a plugin observer.The observer will no longer receive any of the events produced by the plugin.
If applicable, the observation process shall be stopped when the last observer is removed.
- Parameters:
observer- The observer object to be unregistered (should be not null).- Throws:
IllegalArgumentException- if observer is null.- Since:
- 2.0.0
-
clearObservers
void clearObservers()Unregisters all observers at once.- Since:
- 2.0.0
-
countObservers
int countObservers()Provides the current number of registered observers.- Returns:
- An int.
- Since:
- 2.0.0
-
setPluginObservationExceptionHandler
Sets the exception handler.The invocation of this method is mandatory when the plugin has to be observed.
In case of a fatal error during the observation, the handler will receive a notification.
- Parameters:
exceptionHandler- The exception handler implemented by the application.- Since:
- 2.0.0
-