Interface ObservableCardReader
- All Superinterfaces:
CardReader
- Since:
- 1.0.0
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Card detection management options to be applied after processing a card.static enum
The options that apply when a card is detected. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addObserver
(CardReaderObserverSpi observer) Registers a new observer to be notified when a reader event occurs.void
Unregisters all observers at once.int
Provides the current number of registered observers.void
Notifies the observation process that the processing of the card has been completed in order to ensure that the card monitoring cycle runs properly.void
removeObserver
(CardReaderObserverSpi observer) Unregisters a reader observer.void
setReaderObservationExceptionHandler
(CardReaderObservationExceptionHandlerSpi exceptionHandler) Sets the exception handler.void
startCardDetection
(ObservableCardReader.DetectionMode detectionMode) Starts the card detection.void
Stops the card detection.Methods inherited from interface org.eclipse.keypop.reader.CardReader
getName, isCardPresent, isContactless
-
Method Details
-
setReaderObservationExceptionHandler
void setReaderObservationExceptionHandler(CardReaderObservationExceptionHandlerSpi exceptionHandler) Sets the exception handler.The invocation of this method is mandatory when the reader 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.- Throws:
IllegalArgumentException
- If the provided handler is null.- Since:
- 1.0.0
-
addObserver
Registers a new observer to be notified when a reader event occurs.The provided observer must implement the
CardReaderObserverSpi
interface to be able to receive the events produced by this reader (card insertion, removal, etc.)- Parameters:
observer
- An observer object implementing the required interface (should be not null).- Throws:
IllegalArgumentException
- If the provided observer is null.- Since:
- 1.0.0
-
removeObserver
Unregisters a reader observer.The observer will no longer receive any of the events produced by this reader.
- Parameters:
observer
- The observer object to be removed (should be not null).- Throws:
IllegalArgumentException
- If the provided observer is null.- Since:
- 1.0.0
-
clearObservers
void clearObservers()Unregisters all observers at once.- Since:
- 1.0.0
-
countObservers
int countObservers()Provides the current number of registered observers.- Returns:
- An int.
- Since:
- 1.0.0
-
startCardDetection
Starts the card detection. Once activated, the application can be notified of the arrival of a card.The
ObservableCardReader.DetectionMode
indicates the action to be followed after processing the card.- Parameters:
detectionMode
- The card detection mode.- Throws:
IllegalArgumentException
- If the provided detection mode is null.- Since:
- 1.0.0
-
stopCardDetection
void stopCardDetection()Stops the card detection.- Since:
- 1.0.0
-
finalizeCardProcessing
void finalizeCardProcessing()Notifies the observation process that the processing of the card has been completed in order to ensure that the card monitoring cycle runs properly.This method has no effect if the physical communication channel has already been closed.
It is mandatory to call this method when the physical communication channel with the card could not be closed properly.
The channel closing is nominally managed during the last transmission with the card. However, there are cases where exchanges with the card are interrupted (e.g. by an exception), in which case it is necessary to explicitly close the channel using this method.In practice, it is recommended to call this method in all cases (e.g. in a "finally" statement) at the end of a card processing whatever the result.
- Since:
- 1.0.0
-