EventListenerRegistryService

public interface EventListenerRegistryService

Gives access to the registry of listeners for Motech events. This interface is necessary for OSGi service publication. One can register themselves to listen for a specific set of event’s subject.

Methods

clearListenersForBean

void clearListenersForBean(String beanName)

Removes all listeners registered in the bean. This is necessary when bundles are stopped in some fashion so that the listener does not persist.

Parameters:
  • beanName – the name of the bean

getListenerCount

int getListenerCount(String subject)

Returns the number of event listeners for the event with the subject.

Parameters:
  • subject – the subject of the event
Returns:

the number of matching listeners

getListeners

Set<EventListener> getListeners(String subject)

Returns all the event listeners registered for the event with the given subject. If there are no listeners, an empty list is returned.

Parameters:
  • subject – the subject of the event
Returns:

the matching event listeners

hasListener

boolean hasListener(String subject)

Returns true if the event with the subject has any listeners.

Parameters:
  • subject – the subject of the event
Returns:

true if the subject has any listeners; false otherwise

registerListener

void registerListener(EventListener listener, List<String> subjects)

Registers the event listener to be notified when events with the matching subject are received via the Server JMS Event Queue.

Parameters:
  • listener – the listener to be registered
  • subjects – the list of subjects the listener subscribes to, wildcards are allowed

registerListener

void registerListener(EventListener listener, String subject)

Registers the event listener to be notified when the event’s subjects are received via the Server JMS Event Queue.

Parameters:
  • listener – the listener to be registered
  • subject – the subject the listener subscribes to, wildcards are allowed