javax.enterprise.inject.spi.ProcessBeanAttributes Java Examples

The following examples show how to use javax.enterprise.inject.spi.ProcessBeanAttributes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProviderExtensionSupport.java    From smallrye-jwt with Apache License 2.0 5 votes vote down vote up
/**
 * 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 ProviderBeanAttributes
 */
public void addTypeToClaimProducer(@Observes ProcessBeanAttributes pba) {
    if (!providerOptionalTypes.isEmpty() && pba.getAnnotated().isAnnotationPresent(Claim.class)) {
        Claim claim = pba.getAnnotated().getAnnotation(Claim.class);
        if (claim.value().length() == 0 && claim.standard() == Claims.UNKNOWN) {
            CDILogging.log.addTypeToClaimProducer(pba.getAnnotated());
            BeanAttributes delegate = pba.getBeanAttributes();
            if (delegate.getTypes().contains(Optional.class)) {
                pba.setBeanAttributes(new ProviderBeanAttributes(delegate, providerOptionalTypes, providerQualifiers));
            }
        }
    }
}
 
Example #2
Source File: MPConfigExtension.java    From microprofile-jwt-auth with Apache License 2.0 5 votes vote down vote up
void doProcessBeanAttributes(@Observes ProcessBeanAttributes pba) {
    System.out.printf("pab: %s\n", pba.getAnnotated());
    if (pba.getAnnotated().isAnnotationPresent(ConfigProperty.class)) {
        System.out.printf("\t+++ has ConfigProperty annotation\n");
        //pba.setBeanAttributes(new ConverterBeanAttribute(pba.getBeanAttributes(), types));
    }
}
 
Example #3
Source File: MPConfigExtension.java    From microprofile-jwt-auth with Apache License 2.0 5 votes vote down vote up
/**
 * Replace our {@linkplain ConfigPropertyProducer#produceConfigProperty(InjectionPoint)} BeanAttributes with
 * {@linkplain ConfigPropertyBeanAttribute} to properly reflect all of the type locations the producer method applies to.
 * @see ConfigPropertyBeanAttribute
 * @param pba
 */
public void addTypeToConfigProperty(@Observes ProcessBeanAttributes<Object> pba) {
    if (pba.getAnnotated().isAnnotationPresent(ConfigProperty.class)) {
        System.out.printf("addTypeToConfigProperty: %s", pba);
        pba.setBeanAttributes(new ConfigPropertyBeanAttribute(pba.getBeanAttributes(), configPropertyTypes));
    }
}
 
Example #4
Source File: VertxExtension.java    From weld-vertx with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #5
Source File: ImplicitArchiveExtension.java    From thorntail with Apache License 2.0 4 votes vote down vote up
<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();
                }
            });
        }
    }
}