Interface ObservableCardReader

  • All Superinterfaces:
    CardReader

    public interface ObservableCardReader
    extends CardReader
    Card reader able to observe the insertion/removal of cards.
    Since:
    1.0.0
    • 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()
        Terminates the card processing.

        This method notifies the observation process that the processing of the card has been completed in order to ensure that the card monitoring cycle runs properly.
        It is mandatory to invoke it when the physical communication channel with the card could not be closed.
        This method will do nothing if the channel has already been closed.
        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.

        Since:
        1.0.0