use of org.forgerock.util.thread.listener.ShutdownListener in project OpenAM by OpenRock.
the class AuditServiceProviderImpl method registerListeners.
private void registerListeners() {
configProvider.addConfigurationListener(new AuditServiceConfigurationListener() {
@Override
public void globalConfigurationChanged() {
refreshDefaultAuditService();
}
@Override
public void realmConfigurationChanged(String realm) {
refreshRealmAuditService(realm);
}
@Override
public void realmConfigurationRemoved(String realm) {
removeRealmAuditService(realm);
}
});
shutdownManager.addShutdownListener(new ShutdownListener() {
@Override
public void shutdown() {
closeAuditServices();
}
});
}
use of org.forgerock.util.thread.listener.ShutdownListener in project OpenAM by OpenRock.
the class DataLayer method initLdapPool.
/**
* Initialize the pool shared by all DataLayer object(s).
*/
private synchronized void initLdapPool() throws UMSException {
// Don't do anything if pool is already initialized
if (_ldapPool != null)
return;
/*
* Initialize the pool with minimum and maximum connections settings
* retrieved from configuration
*/
ServerInstance svrCfg = null;
String hostName = null;
try {
DSConfigMgr dsCfg = DSConfigMgr.getDSConfigMgr();
hostName = dsCfg.getHostName("default");
baseFactory = dsCfg.getNewProxyConnectionFactory();
svrCfg = dsCfg.getServerInstance(LDAPUser.Type.AUTH_PROXY);
} catch (LDAPServiceException ex) {
debug.error("Error initializing connection pool " + ex.getMessage());
}
// Check if svrCfg was successfully obtained
if (svrCfg == null) {
debug.error("Error getting server config.");
String[] args = new String[1];
args[0] = hostName == null ? "default" : hostName;
throw new UMSException(i18n.getString(IUMSConstants.NEW_INSTANCE_FAILED, args));
}
int poolMin = svrCfg.getMinConnections();
int poolMax = svrCfg.getMaxConnections();
m_releaseConnectionBeforeSearchCompletes = svrCfg.getBooleanValue(LDAP_RELEASECONNBEFORESEARCH, false);
if (debug.messageEnabled()) {
debug.message("Creating ldap connection pool with: poolMin {}, poolMax {}", poolMin, poolMax);
}
int idleTimeout = SystemProperties.getAsInt(Constants.LDAP_CONN_IDLE_TIME_IN_SECS, 0);
if (idleTimeout == 0) {
debug.warning("Idle timeout not set. Defaulting to 0.");
}
_ldapPool = Connections.newCachedConnectionPool(Connections.newNamedConnectionFactory(baseFactory, "DataLayer"), poolMin, poolMax, idleTimeout, TimeUnit.SECONDS);
ShutdownManager shutdownMan = com.sun.identity.common.ShutdownManager.getInstance();
shutdownMan.addShutdownListener(new ShutdownListener() {
public void shutdown() {
if (_ldapPool != null) {
_ldapPool.close();
}
}
});
}
use of org.forgerock.util.thread.listener.ShutdownListener in project OpenAM by OpenRock.
the class IdServicesImpl method getInstance.
protected static synchronized IdServices getInstance() {
if (_instance == null) {
DEBUG.message("IdServicesImpl.getInstance(): " + "Creating new Instance of IdServicesImpl()");
ShutdownManager shutdownMan = com.sun.identity.common.ShutdownManager.getInstance();
_instance = new IdServicesImpl();
shutdownMan.addShutdownListener(new ShutdownListener() {
public void shutdown() {
synchronized (_instance) {
shutdownCalled = true;
}
_instance.clearIdRepoPlugins();
}
});
}
return _instance;
}
use of org.forgerock.util.thread.listener.ShutdownListener in project OpenAM by OpenRock.
the class SystemTimerPool method getTimerPool.
/**
* Create and return the system timer pool.
*/
public static synchronized TimerPool getTimerPool() {
if (instance == null) {
ShutdownManager shutdownMan = ShutdownManager.getInstance();
// Don't load the Debug object in static block as it can
// cause issues when doing a container restart.
instance = new TimerPool("SystemTimerPool", poolSize, false, Debug.getInstance("SystemTimerPool"));
try {
shutdownMan.addShutdownListener(new ShutdownListener() {
public void shutdown() {
instance.shutdown();
instance = null;
}
});
} catch (IllegalMonitorStateException e) {
instance.shutdown();
instance = null;
throw e;
}
}
return instance;
}
use of org.forgerock.util.thread.listener.ShutdownListener in project OpenAM by OpenRock.
the class SystemTimer method getTimer.
/**
* Create and return the system timer.
*/
public static synchronized TimerPool getTimer() {
if (instance == null) {
ShutdownManager shutdownMan = ShutdownManager.getInstance();
// Don't load the Debug object in static block as it can
// cause issues when doing a container restart.
instance = new TimerPool("SystemTimer", 1, false, Debug.getInstance("SystemTimer"));
shutdownMan.addShutdownListener(new ShutdownListener() {
public void shutdown() {
instance.shutdown();
instance = null;
}
});
}
return instance;
}
Aggregations