Package org.eclipse.keyple.core.service
Interface ObservablePlugin
-
- All Superinterfaces:
Plugin
public interface ObservablePlugin extends Plugin
Plugin able to observe the connection/disconnection ofReader
.Allows registered observers to receive a
PluginEvent
when a reader is connected/disconnected.- Since:
- 2.0.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addObserver(PluginObserverSpi observer)
Registers a new observer to be notified when a plugin event occurs.void
clearObservers()
Unregisters all observers at once.int
countObservers()
Provides the current number of registered observers.void
removeObserver(PluginObserverSpi observer)
Unregisters a plugin observer.void
setPluginObservationExceptionHandler(PluginObservationExceptionHandlerSpi exceptionHandler)
Sets the exception handler.-
Methods inherited from interface org.eclipse.keyple.core.service.Plugin
getExtension, getName, getReader, getReaderNames, getReaders
-
-
-
-
Method Detail
-
addObserver
void addObserver(PluginObserverSpi observer)
Registers a new observer to be notified when a plugin event occurs.The provided observer must implement the
PluginObserverSpi
interface 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:
java.lang.IllegalArgumentException
- if observer is null.java.lang.IllegalStateException
- if no exception handler is defined.- Since:
- 2.0.0
-
removeObserver
void removeObserver(PluginObserverSpi observer)
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:
java.lang.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
void setPluginObservationExceptionHandler(PluginObservationExceptionHandlerSpi exceptionHandler)
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
-
-