Interface ISubscriber<T extends EventListener>

All Superinterfaces:
AutoCloseable, IConnection, IPropertyFilter, ITopicConnection, IURIConnection
All Known Implementing Classes:
AMQPSubscriberImpl

public interface ISubscriber<T extends EventListener> extends ITopicConnection, IPropertyFilter

This interface is designed to make it easy to listen to all events and easy to listen to a specific scan.

Listen to all events:
 
 IEventService service = ...
 IScanSubscriber sub = service.createSubscriber(...)
 IScanListener listener = new IScanListener() {
 		{@literal @}Override
 		public void scanEventPerformed(ScanEvent evt) {
 		// Everything that happens ...
 		}
 	};
 sub.addListener(listener);
 
 
Listen to specific events for a given scan: IScanListener listener2 = new IScanListener() { {@literal @}Override public void scanEventPerformed(ScanEvent evt) { // Everything that happens ... } sub.addListener(<b>id</b>, listener2); } NOTE: If a listener is registered it will then be associated with the scan it is registered with only. It should be unregistered and readded. So for instance:
 sub.addListener(id, listener); // registers for id but removes it as general listener.
 
Removes the Object listener from the general listeners and defines it as a listener of the id. This listener would have to be readded using addListener(listener) to use it again as a general listener.
  • Method Details

    • addListener

      void addListener(T listener) throws EventException
      Adds a listener which is notified when events are broadcast. The listener works event if the manager is running on a client and the broadcast is happening from a server because through JMS or similar messaging system which this service and manager are hiding.
      Parameters:
      listener -
    • removeListener

      void removeListener(T listener)
      Removes a listener such that events are no longer sent to it.
      Parameters:
      listener -
    • addListener

      void addListener(String id, T listener) throws EventException
      Register events for a given id to be reported.
      Parameters:
      id -
      listener -
    • removeListener

      void removeListener(String id, T listener)
      Unregister events for a given id to be reported.
      Parameters:
      id -
      listener -
    • removeListeners

      void removeListeners(String id)
      Unregister all listeners with this id.
      Parameters:
      id -
      listener -
    • removeAllListeners

      void removeAllListeners()
      Removes all listeners without disconnecting from events or stopping the JMS threads.
    • setSynchronous

      void setSynchronous(boolean sync)
      Call to set if the events should be ordered and BLOCKING. The default is true. When synchronous is true events are despatched in order and the event listener method is waited for until it returns before processing more events. If it is false the messaging thread is used to directly depatch the event meaning that more events may occur and be called the last listener has returned. Note: this method must be called before adding any listeners by calling addListener(EventListener) or addListener(String, EventListener).
      Parameters:
      sync -
    • isSynchronous

      boolean isSynchronous()
      Returns:
      true by default.