Interface ObservableCardReader
-
- All Superinterfaces:
CardReader
public interface ObservableCardReader extends CardReader
Card reader able to observe the insertion/removal of cards.- Since:
- 1.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ObservableCardReader.DetectionMode
Card detection management options to be applied after processing a card.static class
ObservableCardReader.NotificationMode
The options that apply when a card is detected.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addObserver(CardReaderObserverSpi observer)
Registers a new observer to be notified when a reader event occurs.void
clearObservers()
Unregisters all observers at once.int
countObservers()
Provides the current number of registered observers.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.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
stopCardDetection()
Stops the card detection.-
Methods inherited from interface org.eclipse.keypop.reader.CardReader
getName, isCardPresent, isContactless
-
-
-
-
Method Detail
-
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:
java.lang.IllegalArgumentException
- If the provided handler is null.- Since:
- 1.0.0
-
addObserver
void addObserver(CardReaderObserverSpi observer)
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:
java.lang.IllegalArgumentException
- If the provided observer is null.- Since:
- 1.0.0
-
removeObserver
void removeObserver(CardReaderObserverSpi observer)
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:
java.lang.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
void startCardDetection(ObservableCardReader.DetectionMode detectionMode)
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:
java.lang.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
-
-