final Set<Bean<?>> beans = bm.getBeans(handler.getHandlerClass());
final Bean<?> bean = bm.resolve(beans);
if (bean != null) { // proxy so faster to do it
final boolean normalScoped = bm.isNormalScope(bean.getScope());
final CreationalContextImpl<?> creationalContext = bm.createCreationalContext(bean);
final Handler instance = Handler.class.cast(bm.getReference(bean, bean.getBeanClass(), creationalContext));
// hack for destroyHandlers()
handlers.add(instance);
handlerInstances.add(new InjectionProcessor<Handler>(instance, Collections.<Injection>emptySet(), null) {
@Override
public void preDestroy() {
if (!normalScoped) {
creationalContext.release();
}
}
});
continue;
}
} catch (final InjectionException ie) {
LOGGER.info(ie.getMessage(), ie);
}
}
}
try { // old way
final Class<? extends Handler> handlerClass = handler.getHandlerClass().asSubclass(Handler.class);
final InjectionProcessor<Handler> processor = new InjectionProcessor<Handler>(handlerClass,
injections,
handler.getPostConstruct(),
handler.getPreDestroy(),
unwrap(context));
processor.createInstance();
processor.postConstruct();
final Handler handlerInstance = processor.getInstance();
handlers.add(handlerInstance);
handlerInstances.add(processor);
} catch (final Exception e) {
throw new WebServiceException("Failed to instantiate handler", e);