use of org.forgerock.util.thread.listener.ShutdownListener in project OpenAM by OpenRock.
the class ShutdownManager method shutdown.
/**
* Shuts down all the listeners in this ShutdownManager.
*/
public void shutdown() throws IllegalMonitorStateException {
if (acquireValidLock()) {
try {
shutdownCalled = true;
List<ShutdownPriority> priorities = ShutdownPriority.getPriorities();
for (ShutdownPriority i : priorities) {
for (Iterator<ShutdownListener> j = listeners[i.getIntValue() - 1].iterator(); j.hasNext(); ) {
j.next().shutdown();
// remove the components which have been shutdown to avoid
// problem when the shutdown function is called twice.
j.remove();
}
}
if (appSSOTokenDestroyer != null) {
appSSOTokenDestroyer.shutdown();
appSSOTokenDestroyer = null;
}
instance = null;
} catch (RuntimeException t) {
Debug.getInstance("amUtil").error("Error during shutdown", t);
throw t;
} finally {
releaseLockAndNotify();
}
} else {
throw new IllegalMonitorStateException("Failed to acquire lock during shutdown.");
}
}
use of org.forgerock.util.thread.listener.ShutdownListener in project OpenAM by OpenRock.
the class UpgradeUtils method getLDAPConnectionFactory.
private static ConnectionFactory getLDAPConnectionFactory(String hostname, int port, Options options) {
if (factory == null) {
factory = new LDAPConnectionFactory(hostname, port, options);
ShutdownManager.getInstance().addShutdownListener(new ShutdownListener() {
@Override
public void shutdown() {
if (factory != null) {
factory.close();
}
}
});
}
return factory;
}
Aggregations