use of javax.annotation.PreDestroy in project wildfly by wildfly.
the class SingletonBean method sleepAndDestroy.
@PreDestroy
private void sleepAndDestroy() throws Exception {
logger.trace("Sleeping for 3 seconds while destroying singleton bean " + this);
// sleep for a while just to reproduce a race condition with EntityManagerFactory being closed before
// the singleton bean can finish its pre-destroy
Thread.sleep(3000);
logger.trace("Woke up after 3 seconds while destroying singleton bean " + this);
final EntityManagerFactory entityManagerFactory = this.entityManager.getEntityManagerFactory();
boolean emFactoryOpen = entityManagerFactory.isOpen();
if (!emFactoryOpen) {
throw new RuntimeException("Entitymanager factory: " + entityManagerFactory + " has been closed " + "even before singleton bean " + this + " could complete its @PreDestroy");
}
}
use of javax.annotation.PreDestroy in project deltaspike by apache.
the class ThreadPoolManager method shutdown.
@PreDestroy
private void shutdown() {
closed = true;
final long timeout = CoreBaseConfig.TimeoutCustomization.FUTUREABLE_TERMINATION_TIMEOUT_IN_MILLISECONDS;
for (final ExecutorService es : pools.values()) {
es.shutdown();
}
for (final ExecutorService es : pools.values()) {
try {
es.awaitTermination(timeout, TimeUnit.MILLISECONDS);
} catch (final InterruptedException e) {
Thread.interrupted();
}
}
pools.clear();
for (final CreationalContext<?> ctx : contexts) {
ctx.release();
}
contexts.clear();
}
use of javax.annotation.PreDestroy in project midpoint by Evolveum.
the class TaskManagerQuartzImpl method destroy.
@PreDestroy
public void destroy() {
OperationResult result = new OperationResult(DOT_IMPL_CLASS + "shutdown");
systemConfigurationChangeDispatcher.unregisterListener(this);
upAndDown.shutdown(result);
}
use of javax.annotation.PreDestroy in project canal by alibaba.
the class CanalAdapterService method destroy.
@PreDestroy
public synchronized void destroy() {
if (!running) {
return;
}
try {
running = false;
logger.info("## stop the canal client adapters");
if (adapterLoader != null) {
adapterLoader.destroy();
adapterLoader = null;
}
for (DruidDataSource druidDataSource : DatasourceConfig.DATA_SOURCES.values()) {
try {
druidDataSource.close();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
DatasourceConfig.DATA_SOURCES.clear();
} catch (Throwable e) {
logger.warn("## something goes wrong when stopping canal client adapters:", e);
} finally {
logger.info("## canal client adapters are down.");
}
}
use of javax.annotation.PreDestroy in project oxTrust by GluuFederation.
the class AuthenticationSessionService method sessionDestroyed.
@PreDestroy
public void sessionDestroyed() {
OauthData oauthData = identity.getOauthData();
if ((oauthData == null) || StringHelper.isEmpty(oauthData.getSessionState())) {
return;
}
String userUid = oauthData.getUserUid();
log.debug("Calling oxAuth logout method at the end of HTTP session. User: '{}'", userUid);
try {
String endSessionState = UUID.randomUUID().toString();
EndSessionRequest endSessionRequest = new EndSessionRequest(oauthData.getIdToken(), appConfiguration.getLogoutRedirectUrl(), endSessionState);
endSessionRequest.setSid(oauthData.getSessionState());
EndSessionClient endSessionClient = new EndSessionClient(openIdService.getOpenIdConfiguration().getEndSessionEndpoint());
endSessionClient.setRequest(endSessionRequest);
EndSessionResponse endSessionResponse = endSessionClient.exec();
if ((endSessionResponse == null) || (endSessionResponse.getStatus() != 302)) {
log.error("Invalid response code at oxAuth logout. User: '{}'", userUid);
}
} catch (Exception ex) {
log.error("Exception happened at oxAuth logout. User: '{}'", userUid, ex);
}
}
Aggregations