/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: EventService.java,v 1.19 2009/09/28 21:47:33 ww203982 Exp $
*
* Portions Copyrighted 2010-2016 ForgeRock AS.
*/
/**
* The EventService is responsible for listening to and dispatching to listening objects
* messages returning from persistent searches running in an underlying LDAP implementation.
*
* @supported.api
*/
public class EventService {
"com.iplanet.am.event.connection.delay.between.retries";
/** Retry interval for reconnecting to persistent searches. **/
public static final int RETRY_INTERVAL = SystemProperties.getAsInt(EVENT_CONNECTION_RETRY_INTERVAL, 3000);
private static final String EVENT_LISTENER_DISABLE_LIST = "com.sun.am.event.connection.disable.list";
private static final Class<? extends IDSEventListener> ACI_EVENT_LISTENER_CLASS_NAME = ACIEventListener.class;
private static final Class<? extends IDSEventListener> ENTRY_EVENT_LISTENER_CLASS_NAME = EntryEventListener.class;
private static final Class<? extends IDSEventListener> LDAP_EVENT_LISTENER_CLASS_NAME = LDAPEventManager.class;
private static volatile boolean isShutdownCalled = false;
private static volatile boolean isRunning = false;
private final Map<Class<? extends IDSEventListener>, ListenerSearch> persistentSearches = new HashMap<>();
private static final class ListenerSearch {
}
}
private enum Singleton {
Singleton() {
try {
eventService = new EventService();
new ShutdownListener() {
public void shutdown() {
if (eventService != null) {
}
}
});
} catch (EventException e) {
eventException = e;
}
}
if (eventException != null) {
throw eventException;
}
return eventService;
}
}
try {
} catch (LDAPServiceException lse) {
logger.error("EventService.getConfigManager() - Failed to get handle to Configuration Manager", lse);
}
}
/**
* Returns the event service (presuming we are not in the process of shutting down).
*
* @supported.api
* @return The singleton instance of the EventService.
*/
if (isShutdownCalled) {
return null;
}
}
/**
* Restarts all currently registered persistent searches.
*
* Persistent searches that do not have enabled listeners are removed.
*
* Legacy Comment:
* Question: is ok to not actually restart running psearches if the listener is still enabled?
*/
public synchronized void restartPSearches() {
} else {
}
}
for (Iterator<Class<? extends IDSEventListener>> iterator = listenersClasses.iterator(); iterator.hasNext();) {
try {
"objectclass");
} catch (Exception e) {
}
}
if (!listenersClasses.isEmpty()) {
}
}
isRunning = true;
}
/**
* Removes listeners from running persistent searches and then stops their execution on the datastore.
*/
public synchronized void stopPSearches() {
isShutdownCalled = true;
}
}
/**
* Informs the callers as to the state of the EventService.
*
* @return {@code true} if the EventService is started and the system is not shutting down.
*/
public static boolean isStarted() {
return isRunning && !isShutdownCalled;
}
/**
* Retrieve the listener of a specific listening class derivative type.
*
* @param listenerClass The {@link IDSEventListener} implementation class to retrieve.
* @return a listener of the class type provided.
*/
}
if (!disableUM || !disableACI) {
// Check if AMSDK is configured
if (!isAMSDKConfigured()) {
disableUM = true;
disableACI = true;
if (logger.messageEnabled()) {
+ "Disabling UM and ACI event listeners");
}
}
}
//psearch terminated if you disable the DB notifications, or add 'sm' to the list of disabled
if (!disableSM) {
}
if (logger.messageEnabled()) {
}
// Disable the selected listeners
if (!disableACI) {
}
if (!disableUM) {
}
if (!disableSM) {
}
logger.message("EventService.getListenerList() - all listeners are disabled, EventService won't start");
}
return listeners;
}
throws LDAPServiceException {
return getSmsConnectionFactory();
} else {
return getAdminConnectionFactory();
}
}
if (adminConnectionFactory == null) {
}
return adminConnectionFactory;
}
if (smsConnectionFactory == null) {
}
return smsConnectionFactory;
}
logger.error("EventService.dispatchException() - dispatching exception to the listener: {} Listener: {}",
}
}
// Get the dn from the entry
// Get information on the type of change made
// Pass the search ID as the event's change info
// set the object class name
return dsEvent;
}
}
return disabledListeners;
}
private static boolean isDuringConfigurationTime() {
}
private static boolean isAMSDKConfigured() {
boolean isAMSDKConfigured = false;
boolean configTime = isDuringConfigurationTime();
logger.message("EventService.getListenerList(): {}: {}", Constants.SYS_PROPERTY_INSTALL_TIME, configTime);
if (!configTime) {
try {
isAMSDKConfigured = true;
}
} catch (SMSException ex) {
} catch (SSOException ex) {
// Should not happen, ignore the exception
}
}
return isAMSDKConfigured;
}
private final class EventServicePersistentSearch extends LDAPv3PersistentSearch<IDSEventListener, String> {
}
protected void clearCaches() {
}
}
return resultEntryHandler;
}
private final class PSearchResultEntryHandler implements LDAPv3PersistentSearch.SearchResultEntryHandler {
new Exception("EventService - Cannot create NamingEvent, no change control info");
public boolean handle(SearchResultEntry entry, String dn, DN previousDn, PersistentSearchChangeType type) {
// Convert control into a DSEvent and dispatch to listeners
try {
}
} else {
}
}
return true;
}
}
}
}