Search in sources :

Example 41 with PreDestroy

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

the class ResourceInjector method invokePreDestroy.

public void invokePreDestroy() {
    boolean accessible = false;
    for (Method method : getPreDestroyMethods()) {
        PreDestroy pd = method.getAnnotation(PreDestroy.class);
        if (pd != null) {
            try {
                ReflectionUtil.setAccessible(method);
                method.invoke(target);
            } catch (IllegalAccessException e) {
                LOG.log(Level.WARNING, "PRE_DESTROY_NOT_VISIBLE", method);
            } catch (InvocationTargetException e) {
                LOG.log(Level.WARNING, "PRE_DESTROY_THREW_EXCEPTION", e);
            } finally {
                ReflectionUtil.setAccessible(method, accessible);
            }
        }
    }
}
Also used : PreDestroy(javax.annotation.PreDestroy) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 42 with PreDestroy

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

the class Alternative method preDestroy.

@PreDestroy
public void preDestroy() throws MBeanRegistrationException {
    final String name = properties.getProperty("name");
    requireNotNull(name);
    try {
        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        final ObjectName objectName = new ObjectName(name);
        mbs.unregisterMBean(objectName);
    } catch (final MalformedObjectNameException e) {
        LOGGER.severe("Malformed MBean name: " + name);
        throw new MBeanRegistrationException(e);
    } catch (final javax.management.MBeanRegistrationException e) {
        LOGGER.severe("Error unregistering " + name);
        throw new MBeanRegistrationException(e);
    } catch (InstanceNotFoundException e) {
        LOGGER.severe("Error unregistering " + name);
        throw new MBeanRegistrationException(e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(org.superbiz.resource.jmx.factory.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) PreDestroy(javax.annotation.PreDestroy)

Example 43 with PreDestroy

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

the class ClusterScopedInterceptor method preDestroy.

@PreDestroy
Object preDestroy(InvocationContext invocationContext) throws Exception {
    Class<?> beanClass = invocationContext.getTarget().getClass().getSuperclass();
    Clustered clusteredAnnotation = getAnnotation(beanManager, beanClass);
    clusteredLookup.setClusteredSessionKeyIfNotSet(beanClass, clusteredAnnotation);
    IAtomicLong count = clusteredLookup.getClusteredUsageCount();
    if (count.decrementAndGet() <= 0) {
        clusteredLookup.destroy();
    } else if (!clusteredAnnotation.callPreDestoyOnDetach()) {
        return null;
    }
    return invocationContext.proceed();
}
Also used : Clustered(fish.payara.cluster.Clustered) IAtomicLong(com.hazelcast.cp.IAtomicLong) PreDestroy(javax.annotation.PreDestroy)

Example 44 with PreDestroy

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

the class ResourceInjector method invokePreDestroy.

public void invokePreDestroy() {
    boolean accessible = false;
    for (Method method : getPreDestroyMethods()) {
        PreDestroy pd = method.getAnnotation(PreDestroy.class);
        if (pd != null) {
            try {
                ReflectionUtil.setAccessible(method);
                method.invoke(target);
            } catch (IllegalAccessException e) {
                LOG.log(Level.WARNING, "PRE_DESTROY_NOT_VISIBLE", method);
            } catch (InvocationTargetException e) {
                LOG.log(Level.WARNING, "PRE_DESTROY_THREW_EXCEPTION", e);
            } finally {
                ReflectionUtil.setAccessible(method, accessible);
            }
        }
    }
}
Also used : PreDestroy(javax.annotation.PreDestroy) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 45 with PreDestroy

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

the class TimeoutExample method stop.

@PreDestroy
public void stop() {
    System.out.println("EJB Timer: Stop timers.");
    for (Timer timer : timerService.getTimers()) {
        System.out.println("Stopping timer: " + timer.getInfo());
        timer.cancel();
    }
}
Also used : Timer(javax.ejb.Timer) 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