Search in sources :

Example 1 with PreDestroy

use of javax.annotation.PreDestroy in project wildfly by wildfly.

the class DatabaseCreatorBean method dropTables.

@PreDestroy
public void dropTables() {
    try {
        final Connection conn = ds.getConnection();
        executeUpdate(conn, "DROP TABLE " + TABLE_NAME_ROLES);
        executeUpdate(conn, "DROP TABLE " + TABLE_NAME_USERS);
        conn.close();
    } catch (SQLException e) {
        LOGGER.error("Dropping tables failed", e);
    }
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) PreDestroy(javax.annotation.PreDestroy)

Example 2 with PreDestroy

use of javax.annotation.PreDestroy in project midpoint by Evolveum.

the class TaskManagerQuartzImpl method shutdown.

@PreDestroy
public void shutdown() {
    OperationResult result = createOperationResult("shutdown");
    LOGGER.info("Task Manager shutdown starting");
    if (executionManager.getQuartzScheduler() != null) {
        executionManager.stopScheduler(getNodeId(), result);
        executionManager.stopAllTasksOnThisNodeAndWait(0L, result);
        if (configuration.isTestMode()) {
            LOGGER.info("Quartz scheduler will NOT be shutdown. It stays in paused mode.");
        } else {
            try {
                executionManager.shutdownLocalScheduler();
            } catch (TaskManagerException e) {
                LoggingUtils.logUnexpectedException(LOGGER, "Cannot shutdown Quartz scheduler, continuing with node shutdown", e);
            }
        }
    }
    clusterManager.stopClusterManagerThread(0L, result);
    clusterManager.recordNodeShutdown(result);
    if (configuration.isJdbcJobStore() && configuration.isDatabaseIsEmbedded()) {
        LOGGER.trace("Waiting {} msecs to give Quartz thread pool a chance to shutdown.", WAIT_ON_SHUTDOWN);
        try {
            Thread.sleep(WAIT_ON_SHUTDOWN);
        } catch (InterruptedException e) {
        // safe to ignore
        }
    }
    LOGGER.info("Task Manager shutdown finished");
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PreDestroy(javax.annotation.PreDestroy)

Example 3 with PreDestroy

use of javax.annotation.PreDestroy in project cas by apereo.

the class MongoDbAuthenticationHandler method close.

@PreDestroy
@Override
public void close() {
    try {
        final MongoProfileService service = MongoProfileService.class.cast(authenticator);
        service.getMongoClient().close();
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}
Also used : MongoProfileService(org.pac4j.mongo.profile.service.MongoProfileService) PreDestroy(javax.annotation.PreDestroy)

Example 4 with PreDestroy

use of javax.annotation.PreDestroy in project netvirt by opendaylight.

the class BgpAlarmBroadcaster method close.

@Override
@PreDestroy
public void close() {
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName objectName = objectName();
        if (mbs.isRegistered(objectName)) {
            mbs.unregisterMBean(objectName);
        }
    } catch (JMException e) {
        LOG.error("Error unregistering MXBean", e);
    }
}
Also used : JMException(javax.management.JMException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) PreDestroy(javax.annotation.PreDestroy)

Example 5 with PreDestroy

use of javax.annotation.PreDestroy in project cf-java-client by cloudfoundry.

the class _DefaultConnectionContext method dispose.

/**
 * Disposes resources created to service this connection context
 */
@PreDestroy
public final void dispose() {
    getConnectionPool().ifPresent(PoolResources::dispose);
    getThreadPool().dispose();
    try {
        ObjectName name = getByteBufAllocatorObjectName();
        if (ManagementFactory.getPlatformMBeanServer().isRegistered(name)) {
            ManagementFactory.getPlatformMBeanServer().unregisterMBean(name);
        }
    } catch (JMException e) {
        this.logger.error("Unable to register ByteBufAllocator MBean", e);
    }
}
Also used : PoolResources(reactor.ipc.netty.resources.PoolResources) JMException(javax.management.JMException) ObjectName(javax.management.ObjectName) 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