Java Code Examples for javax.enterprise.inject.spi.BeforeBeanDiscovery#addAnnotatedType()

The following examples show how to use javax.enterprise.inject.spi.BeforeBeanDiscovery#addAnnotatedType() . 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: FaultToleranceExtension.java    From smallrye-fault-tolerance with Apache License 2.0 6 votes vote down vote up
void registerInterceptorBindings(@Observes BeforeBeanDiscovery bbd, BeanManager bm) {
    LOGGER.info("MicroProfile: Fault Tolerance activated");
    bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(CircuitBreaker.class)));
    bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(Retry.class)));
    bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(Timeout.class)));
    bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(Asynchronous.class)));
    bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(Fallback.class)));
    bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(Bulkhead.class)));

    // It seems that fraction deployment module cannot be picked up as a CDI bean archive - see also SWARM-1725
    bbd.addAnnotatedType(bm.createAnnotatedType(FaultToleranceInterceptor.class),
            FaultToleranceInterceptor.class.getName());
    bbd.addAnnotatedType(bm.createAnnotatedType(DefaultFallbackHandlerProvider.class),
            DefaultFallbackHandlerProvider.class.getName());
    bbd.addAnnotatedType(bm.createAnnotatedType(ExecutorProvider.class),
            ExecutorProvider.class.getName());
    bbd.addAnnotatedType(bm.createAnnotatedType(DefaultFaultToleranceOperationProvider.class),
            DefaultFaultToleranceOperationProvider.class.getName());
    bbd.addAnnotatedType(bm.createAnnotatedType(MetricsCollectorFactory.class), MetricsCollectorFactory.class.getName());
    bbd.addAnnotatedType(bm.createAnnotatedType(StrategyCache.class), StrategyCache.class.getName());
}
 
Example 2
Source File: MetricCdiInjectionExtension.java    From smallrye-metrics with Apache License 2.0 6 votes vote down vote up
private void addInterceptorBindings(@Observes BeforeBeanDiscovery bbd, BeanManager manager) {
    SmallRyeMetricsLogging.log.logSmallRyeMetricsVersion(getImplementationVersion().orElse("unknown"));

    String extensionName = MetricCdiInjectionExtension.class.getName();

    // It seems that fraction deployment module cannot be picked up as a CDI bean archive - see also SWARM-1725
    for (Class clazz : new Class[] {
            MetricProducer.class,
            MetricNameFactory.class,
            GaugeRegistrationInterceptor.class,
            MetricRegistries.class,

            MeteredInterceptor.class,
            CountedInterceptor.class,
            ConcurrentGaugeInterceptor.class,
            TimedInterceptor.class,
            SimplyTimedInterceptor.class,
            MetricsRequestHandler.class
    }) {
        bbd.addAnnotatedType(manager.createAnnotatedType(clazz), extensionName + "_" + clazz.getName());
    }
}
 
Example 3
Source File: CdiExtension.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void register(@Observes BeforeBeanDiscovery beforeBean, BeanManager beanManager) {
    if (!InMemoryIdentityStore.getCALLER_TO_CREDENTIALS().isEmpty()) {
        beforeBean.addAnnotatedType(
            beanManager.createAnnotatedType(InMemoryIdentityStore.class), 
            "Piranha " + InMemoryIdentityStore.class.getName());
    }
}
 
Example 4
Source File: OpenTracingCDIExtension.java    From thorntail with Apache License 2.0 5 votes vote down vote up
public void observeBeforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd, BeanManager manager) {
  logger.info("Registering Tracer CDI producer");
  String extensionName = OpenTracingCDIExtension.class.getName();
  for (Class<?> clazz : new Class<?>[] {
          TracerProducer.class,
          OpenTracingInterceptor.class,
  }) {
    bbd.addAnnotatedType(manager.createAnnotatedType(clazz), extensionName + "_" + clazz.getName());
  }
}
 
Example 5
Source File: MPJWTExtension.java    From thorntail with Apache License 2.0 5 votes vote down vote up
/**
 * Register the MPJWTProducer JsonWebToken producer bean
 *
 * @param bbd         before discovery event
 * @param beanManager cdi bean manager
 */
public void observeBeforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd, BeanManager beanManager) {
    log.debugf("MPJWTExtension(), adding producers");
    String extensionName = MPJWTExtension.class.getName();
    for (Class<?> clazz : new Class<?>[] {
            JWTAuthContextInfoProvider.class,
            CommonJwtProducer.class,
            PrincipalProducer.class,
            RawClaimTypeProducer.class,
            ClaimValueProducer.class,
            JsonValueProducer.class,
    }) {
        bbd.addAnnotatedType(beanManager.createAnnotatedType(clazz), extensionName + "_" + clazz.getName());
    }
}
 
Example 6
Source File: TomEESecurityExtension.java    From tomee with Apache License 2.0 5 votes vote down vote up
void observeBeforeBeanDiscovery(@Observes final BeforeBeanDiscovery beforeBeanDiscovery,
                                final BeanManager beanManager) {
    beforeBeanDiscovery.addAnnotatedType(beanManager.createAnnotatedType(DefaultAuthenticationMechanism.class));
    beforeBeanDiscovery.addAnnotatedType(
            beanManager.createAnnotatedType(TomEESecurityServletAuthenticationMechanismMapper.class));
    beforeBeanDiscovery.addAnnotatedType(beanManager.createAnnotatedType(TomEEDefaultIdentityStore.class));
    beforeBeanDiscovery.addAnnotatedType(beanManager.createAnnotatedType(TomEEIdentityStoreHandler.class));

    beforeBeanDiscovery.addAnnotatedType(beanManager.createAnnotatedType(AutoApplySessionInterceptor.class));
    beforeBeanDiscovery.addAnnotatedType(beanManager.createAnnotatedType(RememberMeInterceptor.class));
    beforeBeanDiscovery.addAnnotatedType(beanManager.createAnnotatedType(LoginToContinueInterceptor.class));

    beforeBeanDiscovery.addAnnotatedType(beanManager.createAnnotatedType(TomEESecurityContext.class));
}
 
Example 7
Source File: MPJWTCDIExtension.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void observeBeforeBeanDiscovery(@Observes final BeforeBeanDiscovery bbd, final BeanManager beanManager) {
    bbd.addAnnotatedType(beanManager.createAnnotatedType(JWTAuthConfigurationProperties.class));
    bbd.addAnnotatedType(beanManager.createAnnotatedType(JsonbProducer.class));
    bbd.addAnnotatedType(beanManager.createAnnotatedType(MPJWTFilter.class));
    bbd.addAnnotatedType(beanManager.createAnnotatedType(MPJWTInitializer.class));
    bbd.addAnnotatedType(beanManager.createAnnotatedType(org.apache.tomee.microprofile.jwt.bval.BValInterceptor.class));
}
 
Example 8
Source File: SmallRyeJWTAuthCDIExtension.java    From smallrye-jwt with Apache License 2.0 4 votes vote down vote up
void addAnnotatedType(BeforeBeanDiscovery event, BeanManager beanManager, Class<?> type) {
    final String id = "SmallRye" + type.getSimpleName();
    event.addAnnotatedType(beanManager.createAnnotatedType(type), id);
    CDILogging.log.addedType(type.getName());
}
 
Example 9
Source File: ConfigExtension.java    From smallrye-config with Apache License 2.0 4 votes vote down vote up
protected void beforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd, BeanManager bm) {
    AnnotatedType<ConfigProducer> configBean = bm.createAnnotatedType(ConfigProducer.class);
    bbd.addAnnotatedType(configBean, ConfigProducer.class.getName());
}
 
Example 10
Source File: CdiUtils.java    From krazo with Apache License 2.0 4 votes vote down vote up
/**
 * @param beforeBean The BeforeBeanDiscovery.
 * @param bm         The BeanManager.
 * @param types      annotated types to register
 */
public static void addAnnotatedTypes(BeforeBeanDiscovery beforeBean, BeanManager bm, Class<?>... types) {
    for (Class<?> type : types) {
        beforeBean.addAnnotatedType(bm.createAnnotatedType(type), type.getName());
    }
}
 
Example 11
Source File: CdiUtils.java    From ozark with Apache License 2.0 4 votes vote down vote up
/**
 * @param beforeBean The BeforeBeanDiscovery.
 * @param bm         The BeanManager.
 * @param types      annotated types to register
 */
public static void addAnnotatedTypes(BeforeBeanDiscovery beforeBean, BeanManager bm, Class<?>... types) {
    for (Class<?> type : types) {
        beforeBean.addAnnotatedType(bm.createAnnotatedType(type), type.getName());
    }
}
 
Example 12
Source File: SwaggerExtension.java    From thorntail with Apache License 2.0 4 votes vote down vote up
/**
 * Associate the InterceptorBinding annotation.
 */
public void processBeforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager beanManager) {
    event.addInterceptorBinding(beanManager.createAnnotatedType(AddSwaggerResources.class));
    event.addAnnotatedType(beanManager.createAnnotatedType(SwaggerRestApplicationInterceptor.class), SwaggerRestApplicationInterceptor.class.getName());
}
 
Example 13
Source File: InjectConfigViewExtension.java    From thorntail with Apache License 2.0 4 votes vote down vote up
public void addConfigView(@Observes BeforeBeanDiscovery bbd, BeanManager beanManager) {
    bbd.addAnnotatedType(beanManager.createAnnotatedType(ConfigurationValueProducer.class), ConfigurationValueProducer.class.getName());
}
 
Example 14
Source File: JMS2CDIExtension.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void addContextProducer(@Observes final BeforeBeanDiscovery beforeBeanDiscovery, final BeanManager beanManager) {
    beforeBeanDiscovery.addAnnotatedType(beanManager.createAnnotatedType(ContextProducer.class));
    beforeBeanDiscovery.addAnnotatedType(beanManager.createAnnotatedType(RequestAutoContextDestruction.class));
    beforeBeanDiscovery.addAnnotatedType(beanManager.createAnnotatedType(TransactionAutoContextDestruction.class));
}
 
Example 15
Source File: BatchCDIInjectionExtension.java    From incubator-batchee with Apache License 2.0 4 votes vote down vote up
void beforeBeanDiscovery(final @Observes BeforeBeanDiscovery bbd, BeanManager bm) {
    bbd.addAnnotatedType(bm.createAnnotatedType(BatchProducerBean.class));
}
 
Example 16
Source File: ResourceLoaderExtension.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public void addResourceLoaders(final BeforeBeanDiscovery beforeBeanDiscovery, final BeanManager beanManager)
{
    beforeBeanDiscovery.addAnnotatedType(this.createAnnotatedType(ClasspathResourceProvider.class,beanManager));
    beforeBeanDiscovery.addAnnotatedType(this.createAnnotatedType(InjectableResourceProducer.class,beanManager));
    beforeBeanDiscovery.addAnnotatedType(this.createAnnotatedType(FileResourceProvider.class,beanManager));
}