Search in sources :

Example 16 with PreDestroy

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");
    }
}
Also used : EntityManagerFactory(javax.persistence.EntityManagerFactory) PreDestroy(javax.annotation.PreDestroy)

Example 17 with 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();
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) PreDestroy(javax.annotation.PreDestroy)

Example 18 with PreDestroy

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);
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PreDestroy(javax.annotation.PreDestroy)

Example 19 with PreDestroy

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.");
    }
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource) PreDestroy(javax.annotation.PreDestroy)

Example 20 with PreDestroy

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);
    }
}
Also used : OauthData(org.gluu.oxtrust.security.OauthData) EndSessionClient(org.gluu.oxauth.client.EndSessionClient) EndSessionRequest(org.gluu.oxauth.client.EndSessionRequest) EndSessionResponse(org.gluu.oxauth.client.EndSessionResponse) PreDestroy(javax.annotation.PreDestroy)

Aggregations

PreDestroy (javax.annotation.PreDestroy)45 ServiceDescriptor (org.opendaylight.infrautils.diagstatus.ServiceDescriptor)4 File (java.io.File)3 ObjectName (javax.management.ObjectName)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 PrestoException (com.facebook.presto.spi.PrestoException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 Principal (java.security.Principal)2 JMException (javax.management.JMException)2 MBeanServer (javax.management.MBeanServer)2 InitialContext (javax.naming.InitialContext)2 Terminated (akka.actor.Terminated)1 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 SqlTask.createSqlTask (com.facebook.presto.execution.SqlTask.createSqlTask)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IAtomicLong (com.hazelcast.cp.IAtomicLong)1 CollectorManager (com.navercorp.pinpoint.collector.manage.CollectorManager)1 CommonState (com.navercorp.pinpoint.common.server.cluster.zookeeper.util.CommonState)1 Cache (com.publiccms.common.api.Cache)1