Search in sources :

Example 21 with PreDestroy

use of javax.annotation.PreDestroy in project metacat by Netflix.

the class DataSourceManager method close.

/**
 * Closes all the data sources stored in the manager.
 */
@PreDestroy
public void close() {
    final Iterator<DataSource> iter = dataSources.values().iterator();
    while (iter.hasNext()) {
        final DataSourceProxy dataSource = (DataSourceProxy) iter.next();
        if (dataSource != null) {
            dataSource.close();
        }
        iter.remove();
    }
}
Also used : DataSourceProxy(org.apache.tomcat.jdbc.pool.DataSourceProxy) DataSource(javax.sql.DataSource) PreDestroy(javax.annotation.PreDestroy)

Example 22 with PreDestroy

use of javax.annotation.PreDestroy in project cxf by apache.

the class ServerRegistryImpl method preShutdown.

@PreDestroy
public void preShutdown() {
    // Shutdown the service.
    // To avoid the CurrentModificationException, do not use serversList directly
    Object[] servers = serversList.toArray();
    for (int i = 0; i < servers.length; i++) {
        Server server = (Server) servers[i];
        server.destroy();
    }
}
Also used : Server(org.apache.cxf.endpoint.Server) PreDestroy(javax.annotation.PreDestroy)

Example 23 with PreDestroy

use of javax.annotation.PreDestroy in project cxf by apache.

the class RMManager method shutdown.

@PreDestroy
public void shutdown() {
    // shutdown remaining endpoints
    if (!reliableEndpoints.isEmpty()) {
        LOG.log(Level.FINE, "Shutting down RMManager with {0} remaining endpoints.", new Object[] { Integer.valueOf(reliableEndpoints.size()) });
        for (RMEndpoint rme : reliableEndpoints.values()) {
            rme.shutdown();
        }
    }
    // remove references to timer tasks cancelled above to make them
    // eligible for garbage collection
    Timer t = getTimer(false);
    if (t != null) {
        t.purge();
        t.cancel();
    }
// unregistring of this managed bean from the server is done by the bus itself
}
Also used : Timer(java.util.Timer) PreDestroy(javax.annotation.PreDestroy)

Example 24 with PreDestroy

use of javax.annotation.PreDestroy in project flow by vaadin.

the class DestroyBean method preDestroy.

@PreDestroy
public void preDestroy() {
    UI ui = UI.getCurrent();
    Div info = new Div();
    info.setText("Bean is destroyed");
    info.addClassName("info");
    ui.add(info);
}
Also used : Div(com.vaadin.flow.component.html.Div) UI(com.vaadin.flow.component.UI) PreDestroy(javax.annotation.PreDestroy)

Example 25 with PreDestroy

use of javax.annotation.PreDestroy in project Payara by payara.

the class AbstractJMSContextManager method cleanup.

// Close and remove the JMSContext instances
@PreDestroy
public synchronized void cleanup() {
    ServiceLocator serviceLocator = Globals.get(ServiceLocator.class);
    InvocationManager invMgr = serviceLocator.getService(InvocationManager.class);
    ComponentInvocation currentInv = invMgr.getCurrentInvocation();
    for (Entry<String, JMSContextEntry> entry : contexts.entrySet()) {
        JMSContextEntry contextEntry = entry.getValue();
        String ipId = contextEntry.getInjectionPointId();
        JMSContext context = contextEntry.getCtx();
        if (context != null) {
            ComponentInvocation inv = contextEntry.getComponentInvocation();
            if (inv != null && currentInv != inv)
                invMgr.preInvoke(inv);
            try {
                context.close();
                if (logger.isLoggable(Level.FINE)) {
                    logger.log(Level.FINE, localStrings.getLocalString("JMSContext.impl.close", "Closed JMSContext instance associated with id {0}: {1}.", ipId, context.toString()));
                }
            } catch (Exception e) {
                logger.log(Level.SEVERE, localStrings.getLocalString("JMSContext.impl.close.failure", "Failed to close JMSContext instance associated with id {0}: {1}.", ipId, context.toString()), e);
            } finally {
                if (inv != null && currentInv != inv)
                    invMgr.postInvoke(inv);
            }
        }
    }
    contexts.clear();
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager) JMSContext(javax.jms.JMSContext) 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