use of javax.enterprise.inject.spi.Producer in project tomcat by apache.
the class OpenWebBeansInstanceManager method destroyInstance.
@SuppressWarnings("unchecked")
@Override
public void destroyInstance(Object object) throws IllegalAccessException, InvocationTargetException {
Instance injectorInstance = instances.get(object);
if (injectorInstance != null) {
try {
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(loader);
try {
BeanManagerImpl beanManager = WebBeansContext.currentInstance().getBeanManagerImpl();
@SuppressWarnings("rawtypes") Producer producer = beanManager.getProducerForJavaEeComponent(injectorInstance.object.getClass());
if (producer != null) {
producer.dispose(injectorInstance.object);
} else if (injectorInstance.context != null) {
injectorInstance.context.release();
}
} finally {
Thread.currentThread().setContextClassLoader(oldLoader);
}
} catch (Exception e) {
log.error(sm.getString("instanceManager.destroyError", object), e);
}
}
this.instanceManager.destroyInstance(object);
}
use of javax.enterprise.inject.spi.Producer in project Payara by payara.
the class MetricCDIExtension method registerCustomMetrics.
private void registerCustomMetrics(@Observes AfterDeploymentValidation adv, BeanManager manager) {
MetricsService metricsService = Globals.getDefaultBaseServiceLocator().getService(MetricsService.class);
MetricRegistry registry = metricsService.getOrAddRegistry(metricsService.getApplicationName());
MetricsHelper helper = getReference(manager, MetricsHelper.class);
for (Map.Entry<Producer<?>, AnnotatedMember<?>> entry : metrics.entrySet()) {
AnnotatedMember<?> annotatedMember = entry.getValue();
Producer<?> prod = entry.getKey();
if (hasInjectionPoints(annotatedMember)) {
continue;
}
Metadata metadata = helper.metadataOf(annotatedMember);
registry.register(metadata.getName(), (Metric) prod.produce(manager.createCreationalContext(null)), metadata);
}
metrics.clear();
}
Aggregations