/** * 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)); } 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"); } } } }
@SuppressWarnings("rawtypes") void addAsyncReferenceQualifiers(@Observes ProcessBeanAttributes<AsyncReferenceImpl> event) { // Add all discovered qualifiers to AsyncReferenceImpl bean attributes if (!asyncReferenceQualifiers.isEmpty()) { LOGGER.debug("Adding additional AsyncReference qualifiers: {0}", asyncReferenceQualifiers); event.configureBeanAttributes().addQualifiers(asyncReferenceQualifiers); } }
<T> void processBeanAttributes(@Observes ProcessBeanAttributes<T> pb) { logger.info("finished the scanning process"); processBeanAttributes++; }
@SuppressWarnings("unused") <T> void processBeanAttributes(@Observes ProcessBeanAttributes<T> pba, BeanManager beanManager) throws Exception { final BeanAttributes<T> beanAttributes = pba.getBeanAttributes(); if (beanAttributes.getTypes().contains(Archive.class)) { if (!DeploymentScoped.class.isAssignableFrom(beanAttributes.getScope())) { pba.setBeanAttributes(new BeanAttributes<T>() { @Override public Set<Type> getTypes() { return beanAttributes.getTypes(); } @Override public Set<Annotation> getQualifiers() { Set<Annotation> qualifiers = new HashSet<>(); qualifiers.addAll(beanAttributes.getQualifiers()); qualifiers.add(ImplicitDeployment.Literal.INSTANCE); qualifiers.removeIf(e -> Default.class.isAssignableFrom(e.getClass())); return qualifiers; } @Override public Class<? extends Annotation> getScope() { return beanAttributes.getScope(); } @Override public String getName() { return beanAttributes.getName(); } @Override public Set<Class<? extends Annotation>> getStereotypes() { return beanAttributes.getStereotypes(); } @Override public boolean isAlternative() { return beanAttributes.isAlternative(); } }); } } }
<T> void logLifecycleEvent(@Observes ProcessBeanAttributes<T> event) { LOGGER.info("ProcessBeanAttributes: beanAttributes=" + event.getBeanAttributes()); }