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);
}
}
}
}
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);
}
}
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();
}
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);
}
}
}
}
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();
}
}
Aggregations