use of javax.enterprise.inject.spi.BeanAttributes in project core by weld.
the class ProbeExtension method processBeanAttributes.
public <T> void processBeanAttributes(@Observes ProcessBeanAttributes<T> event, BeanManager beanManager) {
probe.getBootstrapStats().increment(EventType.PBA);
final BeanAttributes<T> beanAttributes = event.getBeanAttributes();
final WeldManager weldManager = (WeldManager) beanManager;
if (isMonitored(event.getAnnotated(), beanAttributes, weldManager)) {
event.setBeanAttributes(new ForwardingBeanAttributes<T>() {
@Override
public Set<Class<? extends Annotation>> getStereotypes() {
return ImmutableSet.<Class<? extends Annotation>>builder().addAll(attributes().getStereotypes()).add(MonitoredComponent.class).build();
}
@Override
protected BeanAttributes<T> attributes() {
return beanAttributes;
}
@Override
public String toString() {
return beanAttributes.toString();
}
});
ProbeLogger.LOG.monitoringStereotypeAdded(event.getAnnotated());
}
if (eventMonitorContainerLifecycleEvents) {
addContainerLifecycleEvent(event, "Types: [" + Formats.formatTypes(event.getBeanAttributes().getTypes()) + "], qualifiers: [" + Formats.formatAnnotations(event.getBeanAttributes().getQualifiers()) + "]", beanManager);
}
}
use of javax.enterprise.inject.spi.BeanAttributes in project wildfly-swarm by wildfly-swarm.
the class MPJWTExtension method addTypeToClaimProducer.
/**
* Replace the general producer method BeanAttributes with one bound to the collected injection site
* types to properly reflect all of the type locations the producer method applies to.
*
* @param pba the ProcessBeanAttributes
* @see ClaimProviderBeanAttributes
*/
public void addTypeToClaimProducer(@Observes ProcessBeanAttributes pba) {
if (pba.getAnnotated().isAnnotationPresent(Claim.class)) {
Claim claim = pba.getAnnotated().getAnnotation(Claim.class);
if (claim.value().length() == 0 && claim.standard() == Claims.UNKNOWN) {
log.debugf("addTypeToClaimProducer: %s\n", pba.getAnnotated());
BeanAttributes delegate = pba.getBeanAttributes();
String name = delegate.getName();
if (delegate.getTypes().contains(Optional.class)) {
if (providerOptionalTypes.size() == 0) {
providerOptionalTypes.add(Optional.class);
}
pba.setBeanAttributes(new ClaimProviderBeanAttributes(delegate, providerOptionalTypes, providerQualifiers));
// This is
} else if (name != null && name.startsWith("RawClaimTypeProducer#")) {
if (rawTypes.size() == 0) {
rawTypes.add(Object.class);
}
pba.setBeanAttributes(new ClaimProviderBeanAttributes(delegate, rawTypes, rawTypeQualifiers));
log.debugf("Setup RawClaimTypeProducer BeanAttributes");
}
}
}
}
use of javax.enterprise.inject.spi.BeanAttributes in project HotswapAgent by HotswapProjects.
the class BeanReloadExecutor method doDefineNewManagedBean.
@SuppressWarnings({ "rawtypes", "unchecked" })
private static void doDefineNewManagedBean(BeanManagerImpl beanManager, String bdaId, Class<?> beanClass) {
try {
ClassTransformer classTransformer = getClassTransformer();
SlimAnnotatedType<?> annotatedType = classTransformer.getBackedAnnotatedType(beanClass, bdaId);
boolean managedBeanOrDecorator = Beans.isTypeManagedBeanOrDecoratorOrInterceptor(annotatedType);
if (managedBeanOrDecorator) {
EnhancedAnnotatedType eat = EnhancedAnnotatedTypeImpl.of(annotatedType, classTransformer);
BeanAttributes attributes = BeanAttributesFactory.forBean(eat, beanManager);
ManagedBean<?> bean = ManagedBean.of(attributes, eat, beanManager);
ReflectionHelper.set(beanManager, beanManager.getClass(), "beanSet", Collections.synchronizedSet(new HashSet<Bean<?>>()));
beanManager.addBean(bean);
beanManager.getBeanResolver().clear();
bean.initializeAfterBeanDiscovery();
LOGGER.debug("Bean defined '{}'", beanClass.getName());
} else {
// TODO : define session bean
LOGGER.warning("Bean NOT? defined '{}', session bean?", beanClass.getName());
}
} catch (Exception e) {
LOGGER.debug("Bean definition failed.", e);
}
}
Aggregations