use of org.jboss.weld.manager.BeanManagerImpl in project aries by apache.
the class HttpExtension method afterDeploymentValidation.
void afterDeploymentValidation(@Observes AfterDeploymentValidation adv, BeanManager beanManager) {
processWebClasses();
BeanManagerImpl beanManagerImpl = ((BeanManagerProxy) beanManager).delegate();
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, getSelectedContext());
properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, Boolean.TRUE.toString());
properties.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE - 100);
_registrations.add(_bundle.getBundleContext().registerService(LISTENER_CLASSES, new WeldInitialListener(beanManagerImpl), properties));
}
use of org.jboss.weld.manager.BeanManagerImpl in project aries by apache.
the class ReferenceExtension method processInjectionTarget.
void processInjectionTarget(@Observes @SuppressWarnings("rawtypes") ProcessInjectionPoint pip, BeanManager manager) {
InjectionPoint injectionPoint = pip.getInjectionPoint();
Annotated annotated = injectionPoint.getAnnotated();
Reference reference = annotated.getAnnotation(Reference.class);
if (reference == null) {
return;
}
try {
BeanManagerImpl beanManagerImpl = ((BeanManagerProxy) manager).delegate();
ReferenceDependency referenceDependency = new ReferenceDependency(beanManagerImpl, reference, injectionPoint);
_referenceDependencies.add(referenceDependency);
if (_log.isDebugEnabled()) {
_log.debug("CDIe - Found OSGi service reference {}", referenceDependency);
}
} catch (Exception e) {
if (_log.isErrorEnabled()) {
_log.error("CDIe - Error on reference {}", reference, e);
}
}
}
use of org.jboss.weld.manager.BeanManagerImpl in project wildfly by wildfly.
the class Jsr299BindingsCreateInterceptor method processInvocation.
@Override
public Object processInvocation(InterceptorContext interceptorContext) throws Exception {
BeanManagerImpl beanManager = this.beanManager;
if (beanManager == null) {
//cache the BM lookup, as it is quite slow
beanManager = this.beanManager = this.weldContainer.getValue().getBeanManager(beanArchiveId);
}
//this is not always called with the deployments TCCL set
//which causes weld to blow up
SessionBean<Object> bean = null;
if (ejbName != null) {
EjbDescriptor<Object> descriptor = beanManager.getEjbDescriptor(this.ejbName);
if (descriptor != null) {
bean = beanManager.getBean(descriptor);
}
}
InterceptorBindings interceptorBindings = this.interceptorBindings.getValue();
final ComponentInstance componentInstance = interceptorContext.getPrivateData(ComponentInstance.class);
InterceptorInstances existing = interceptorSupport.getInterceptorInstances(componentInstance);
if (existing == null) {
CreationalContext<Object> creationalContext = beanManager.createCreationalContext(bean);
HashMap<String, SerializableContextualInstance<Interceptor<Object>, Object>> interceptorInstances = new HashMap<String, SerializableContextualInstance<Interceptor<Object>, Object>>();
if (interceptorBindings != null) {
for (Interceptor<?> interceptor : interceptorBindings.getAllInterceptors()) {
addInterceptorInstance((Interceptor<Object>) interceptor, beanManager, interceptorInstances, creationalContext);
}
}
interceptorSupport.setInterceptorInstances(componentInstance, new WeldInterceptorInstances(creationalContext, interceptorInstances));
}
return interceptorContext.proceed();
}
use of org.jboss.weld.manager.BeanManagerImpl in project wildfly by wildfly.
the class WeldClassIntrospector method getInjectionTarget.
private InjectionTarget getInjectionTarget(Class<?> clazz) {
InjectionTarget<?> target = injectionTargets.get(clazz);
if (target != null) {
return target;
}
final BeanManagerImpl beanManager = BeanManagerProxy.unwrap(this.beanManager.getValue());
Bean<?> bean = null;
Set<Bean<?>> beans = new HashSet<>(beanManager.getBeans(clazz, AnyLiteral.INSTANCE));
Iterator<Bean<?>> it = beans.iterator();
//go through and remove them from the bean set
while (it.hasNext()) {
Bean<?> b = it.next();
if (b.getBeanClass() != clazz) {
it.remove();
}
}
if (beans.size() == 1) {
bean = beans.iterator().next();
}
InjectionTarget<?> newTarget = InjectionTargets.createInjectionTarget(clazz, bean, beanManager, true);
target = injectionTargets.putIfAbsent(clazz, newTarget);
if (target == null) {
return newTarget;
} else {
return target;
}
}
use of org.jboss.weld.manager.BeanManagerImpl in project wildfly by wildfly.
the class WeldInterceptorBindingsService method start.
@Override
public void start(StartContext startContext) throws StartException {
BeanManagerImpl beanManager = this.weldContainer.getValue().getBeanManager(beanArchiveId);
//this is not always called with the deployments TCCL set
//which causes weld to blow up
interceptorBindings = getInterceptorBindings(this.ejbName, beanManager);
}
Aggregations