Search in sources :

Example 1 with EventService

use of com.iplanet.services.ldap.event.EventService in project OpenAM by OpenRock.

the class EventManager method addListeners.

/**
     * This method starts the EventService of the UMS and registers two
     * listeners EntryEventListener and ACIEventListener to the EventService
     * inorder to receive notifications. Both the above listeners implement the
     * <code>com.iplanet.services.ldap.event.
     * IDSListener</code> interface.
     * <p>
     * 
     * NOTE: This method should be invoked only once.
     * 
     * @throws AMEventManagerException
     *             when encounters errors in starting the underlying
     *             EventService.
     */
protected void addListeners(Map listeners) throws AMEventManagerException {
    // Get a handle to the (singleton object) Event Manager
    EventService eventService = null;
    try {
        if (debug.messageEnabled()) {
            debug.message("EventManager.start() - Getting EventService" + " instance");
        }
        eventService = EventService.getEventService();
        synchronized (eventService) {
            if (!EventService.isStarted()) {
                eventService.restartPSearches();
            }
        }
    } catch (Exception e) {
        debug.error("EventManager.start() Unable to get EventService ", e);
        throw new AMEventManagerException(AMSDKBundle.getString("501"), "501");
    }
    // Initialize the listeners
    if (eventService != null) {
        // If "null" then disabled!!
        for (Class<? extends IDSEventListener> listenerClass : PSEARCH_LISTENERS) {
            IDSEventListener pSearchListener = eventService.getListener(listenerClass);
            if (pSearchListener != null) {
                pSearchListener.setListeners(listeners);
                debug.message("EventManager.start() - Added listeners to " + "pSearch Listener: " + listenerClass.getSimpleName());
            }
        }
    }
}
Also used : AMEventManagerException(com.iplanet.am.sdk.AMEventManagerException) IDSEventListener(com.iplanet.services.ldap.event.IDSEventListener) EventService(com.iplanet.services.ldap.event.EventService) AMEventManagerException(com.iplanet.am.sdk.AMEventManagerException)

Aggregations

AMEventManagerException (com.iplanet.am.sdk.AMEventManagerException)1 EventService (com.iplanet.services.ldap.event.EventService)1 IDSEventListener (com.iplanet.services.ldap.event.IDSEventListener)1