当前位置: 首页>>代码示例>>Java>>正文


Java AfterBeanDiscovery类代码示例

本文整理汇总了Java中javax.enterprise.inject.spi.AfterBeanDiscovery的典型用法代码示例。如果您正苦于以下问题:Java AfterBeanDiscovery类的具体用法?Java AfterBeanDiscovery怎么用?Java AfterBeanDiscovery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AfterBeanDiscovery类属于javax.enterprise.inject.spi包,在下文中一共展示了AfterBeanDiscovery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerConfigProducer

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
public void registerConfigProducer(@Observes AfterBeanDiscovery abd, BeanManager bm) {
    // excludes type that are already produced by ConfigProducer
    Set<Class> types = injectionPoints.stream()
            .filter(ip -> ip.getType() instanceof Class
                    && ip.getType() != String.class
                    && ip.getType() != Boolean.class
                    && ip.getType() != Boolean.TYPE
                    && ip.getType() != Integer.class
                    && ip.getType() != Integer.TYPE
                    && ip.getType() != Long.class
                    && ip.getType() != Long.TYPE
                    && ip.getType() != Float.class
                    && ip.getType() != Float.TYPE
                    && ip.getType() != Double.class
                    && ip.getType() != Double.TYPE
                    && ip.getType() != Duration.class
                    && ip.getType() != LocalDate.class
                    && ip.getType() != LocalTime.class
                    && ip.getType() != LocalDateTime.class)
            .map(ip -> (Class) ip.getType())
            .collect(Collectors.toSet());
    types.forEach(type -> abd.addBean(new ConfigInjectionBean(bm, type)));
}
 
开发者ID:wildfly-extras,项目名称:wildfly-microprofile-config,代码行数:24,代码来源:ConfigExtension.java

示例2: registerNoSQLSourceBeans

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
/**
 */
void registerNoSQLSourceBeans(@Observes AfterBeanDiscovery abd, BeanManager bm) {

    if (bm.getBeans(clusterClass, DefaultLiteral.INSTANCE).isEmpty()) {
        // Iterate profiles and create Cluster/Session bean for each profile, that application code can @Inject
        for(String profile: getService().profileNames()) {
            log.log(Level.INFO, "Registering bean for profile {0}", profile);
            abd.addBean(bm.createBean(
                    new ClusterBeanAttributes(bm.createBeanAttributes(bm.createAnnotatedType(clusterClass)), profile),
                    clusterClass, new ClusterProducerFactory(profile, clusterClass)));
            abd.addBean(bm.createBean(
                    new SessionBeanAttributes(bm.createBeanAttributes(bm.createAnnotatedType(sessionClass)), profile),
                    sessionClass, new SessionProducerFactory(profile, sessionClass)));
        }
     } else {
        log.log(Level.INFO, "Application contains a default Cluster Bean, automatic registration will be disabled");
    }
}
 
开发者ID:wildfly,项目名称:wildfly-nosql,代码行数:20,代码来源:CassandraExtension.java

示例3: registerNoSQLSourceBeans

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
void registerNoSQLSourceBeans(@Observes AfterBeanDiscovery abd, BeanManager bm) {
    if (bm.getBeans(mongoClientClass, DefaultLiteral.INSTANCE).isEmpty()) {
        // Iterate profiles and create Cluster/Session bean for each profile, that application code can @Inject
        for(String profile: getService().profileNames()) {
            log.log(Level.INFO, "Registering bean for profile {0}", profile);
            abd.addBean(bm.createBean(
                    new MongoClientBeanAttributes(bm.createBeanAttributes(bm.createAnnotatedType(mongoClientClass)), profile),
                    mongoClientClass, new MongoClientProducerFactory(profile, mongoClientClass)));
            abd.addBean(bm.createBean(
                    new MongoDatabaseBeanAttributes(bm.createBeanAttributes(bm.createAnnotatedType(mongoDatabaseClass)), profile),
                    mongoDatabaseClass, new MongoDatabaseProducerFactory(profile, mongoDatabaseClass)));
        }
     } else {
        log.log(Level.INFO, "Application contains a default MongoClient Bean, automatic registration will be disabled");
    }
}
 
开发者ID:wildfly,项目名称:wildfly-nosql,代码行数:17,代码来源:MongoExtension.java

示例4: afterBeanDiscovery

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager beanManager) {

        final CommandContextImpl commandContext = new CommandContextImpl();

        // Register the command context
        event.addContext(commandContext);

        // Register the command context bean using CDI 2 configurators API
        event.addBean()
            .addType(CommandContext.class)
            .createWith(ctx -> new InjectableCommandContext(commandContext, beanManager))
            .addQualifier(Default.Literal.INSTANCE)
            .scope(Dependent.class)
            .beanClass(CommandExtension.class);

        // Register the CommandExecution bean using CDI 2 configurators API
        event.addBean()
            .createWith(ctx -> commandContext.getCurrentCommandExecution())
            .addType(CommandExecution.class)
            .addQualifier(Default.Literal.INSTANCE)
            .scope(CommandScoped.class)
            .beanClass(CommandExtension.class);
    }
 
开发者ID:weld,项目名称:command-context-example,代码行数:24,代码来源:CommandExtension.java

示例5: processMojoCdiProducerFields

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
@SuppressWarnings("unused")
 // will be called automatically by the CDI container once the bean discovery has finished
 private void processMojoCdiProducerFields(@Observes AfterBeanDiscovery event, BeanManager beanManager)
     throws MojoExecutionException {
  
Class<?> cls = getClass();
   Set<Field> fields = Sets.newHashSet();

   while (cls != AbstractCDIMojo.class) {
   	fields.addAll(Sets.newHashSet(cls.getFields()));
   	fields.addAll(Sets.newHashSet(cls.getDeclaredFields()));
   	cls = cls.getSuperclass();
   }
   
   for (Field f : fields) {
     if (f.isAnnotationPresent(MojoProduces.class)) {
       try {
         f.setAccessible(true);
         event.addBean(
             new CdiBeanWrapper<Object>(f.get(this), f.getGenericType(), f.getType(), CDIUtil.getCdiQualifiers(f)));
       } catch (Throwable t) {
         throw new MojoExecutionException("Could not process CDI producer field of the Mojo.", t);
       }
     }
   }
 }
 
开发者ID:shillner,项目名称:maven-cdi-plugin-utils,代码行数:27,代码来源:AbstractCDIMojo.java

示例6: processMojoCdiProducerMethods

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
@SuppressWarnings({ "unused", "unchecked", "rawtypes" })
// will be called automatically by the CDI container once the bean discovery has finished
private void processMojoCdiProducerMethods(@Observes AfterBeanDiscovery event, BeanManager beanManager)
    throws MojoExecutionException {
  // no method parameter injection possible at the moment since the container is not yet initialized at this point!
  Class<?> cls = getClass();
  Set<Method> methods = Sets.newHashSet();

  while (cls != AbstractCDIMojo.class) {
  	methods.addAll(Sets.newHashSet(cls.getMethods()));
  	methods.addAll(Sets.newHashSet(cls.getDeclaredMethods()));
  	cls = cls.getSuperclass();
  }
  
  for (Method m : methods) {
    if (m.getReturnType() != Void.class && m.isAnnotationPresent(MojoProduces.class)) {
      try {
        event.addBean(new CdiProducerBean(m, this, beanManager, m.getGenericReturnType(), m.getReturnType(),
            CDIUtil.getCdiQualifiers(m)));
      } catch (Throwable t) {
        throw new MojoExecutionException("Could not process CDI producer method of the Mojo.", t);
      }
    }
  }
}
 
开发者ID:shillner,项目名称:maven-cdi-plugin-utils,代码行数:26,代码来源:AbstractCDIMojo.java

示例7: afterBeanDiscovery

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd) {
    CommonBean<String[]> stringBean = CommonBeanBuilder.newBuilder(String[].class)
            .beanClass(CommandLineArgsExtension.class)
            .scope(Dependent.class)
            .createSupplier(() -> args)
            .addQualifier(CommandLineArgs.Literal.INSTANCE)
            .addType(String[].class)
            .addType(Object.class).build();
    abd.addBean(stringBean);
    CommonBean<List> listBean = CommonBeanBuilder.newBuilder(List.class)
            .beanClass(CommandLineArgsExtension.class)
            .scope(Dependent.class)
            .createSupplier(() -> argsList)
            .addQualifier(DefaultLiteral.INSTANCE)
            .addType(List.class)
            .addType(Object.class).build();
    abd.addBean(listBean);
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:19,代码来源:CommandLineArgsExtension.java

示例8: afterBeanDiscovery

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
void afterBeanDiscovery(@Observes final AfterBeanDiscovery abd,
                        final BeanManager bm) {

    if (systemFSNotExists) {
        buildSystemFS(abd,
                      bm);
    }

    if (ioStrategyBeanNotFound) {
        buildIOStrategy(abd,
                        bm);
    }

    if (!CDI_METHOD.equalsIgnoreCase(START_METHOD)) {
        buildStartableBean(abd,
                           bm);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:19,代码来源:SystemConfigProducer.java

示例9: addJCacheBeans

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
public void addJCacheBeans(final @Observes AfterBeanDiscovery afterBeanDiscovery)
{
    if (!ACTIVATED)
    {
        return;
    }

    if (cacheManagerFound && cacheProviderFound) {
        return;
    }

    cachingProvider = Caching.getCachingProvider();
    if (!cacheManagerFound)
    {
        cacheManager = cachingProvider.getCacheManager(
                cachingProvider.getDefaultURI(),
                cachingProvider.getDefaultClassLoader(),
                new Properties());
        afterBeanDiscovery.addBean(new CacheManagerBean(cacheManager));
    }
    if (!cacheProviderFound)
    {
        afterBeanDiscovery.addBean(new CacheProviderBean(cachingProvider));
    }
}
 
开发者ID:tomitribe,项目名称:jcache-cdi,代码行数:26,代码来源:ExtraJCacheExtension.java

示例10: afterBeanDiscovery

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
/**
 * {@link javax.enterprise.inject.spi.ProcessBean} CDI event observer.
 *
 * @param afterEvent  CDI Event instance.
 */
public void afterBeanDiscovery(@Observes AfterBeanDiscovery afterEvent) {
    for (ClientProxyBean proxyBean : _createdProxyBeans) {
        _logger.debug("Adding ClientProxyBean for bean Service " + proxyBean.getServiceName() + ".  Service Interface type is " + proxyBean.getServiceInterface().getName());
        afterEvent.addBean(proxyBean);
        _beanDeploymentMetaData.addClientProxy(proxyBean);
    }
    
    for (ReferenceInvokerBean invokerBean : _createdInvokerBeans) {
        _logger.debug("Adding ReferenceInvokerBean for bean Service " + invokerBean.getServiceName());
        afterEvent.addBean(invokerBean);
        _beanDeploymentMetaData.addReferenceInvoker(invokerBean);
    }

    afterEvent.addBean(new BeanDeploymentMetaDataCDIBean(_beanDeploymentMetaData));
    afterEvent.addBean(new ContextBean());
    afterEvent.addBean(new MessageBean());
    afterEvent.addBean(new ExchangeBean());

    _logger.debug("CDI Bean discovery process completed.");
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:26,代码来源:SwitchYardCDIServiceDiscovery.java

示例11: createBeans

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
public <X> void createBeans(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager)
{
    if (!this.isActivated)
    {
        return;
    }

    for (Class<?> originalClass : this.classesToProxy)
    {
        Bean bean = createBean(originalClass, beanManager);

        if (bean != null)
        {
            afterBeanDiscovery.addBean(bean);
        }
    }

    this.classesToProxy.clear();
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:20,代码来源:ConverterAndValidatorProxyExtension.java

示例12: initScheduler

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
private void initScheduler(AfterBeanDiscovery afterBeanDiscovery)
{
    List<Scheduler> availableSchedulers = ServiceUtils.loadServiceImplementations(Scheduler.class, true);

    this.scheduler = findScheduler(availableSchedulers, this.jobClass);

    if (this.scheduler != null)
    {
        try
        {
            this.scheduler.start();
        }
        catch (Throwable t)
        {
            afterBeanDiscovery.addDefinitionError(t);
        }
    }
    else if (!this.foundManagedJobClasses.isEmpty())
    {
        LOG.warning(
            this.foundManagedJobClasses.size() + " scheduling-jobs found, but there is no configured scheduler");
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:24,代码来源:SchedulerExtension.java

示例13: installMessageBundleProducerBeans

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
protected void installMessageBundleProducerBeans(@Observes AfterBeanDiscovery abd, BeanManager beanManager)
{
    if (!deploymentErrors.isEmpty())
    {
        abd.addDefinitionError(new IllegalArgumentException("The following MessageBundle problems where found: " +
                Arrays.toString(deploymentErrors.toArray())));
        return;
    }

    MessageBundleExtension parentExtension = ParentExtensionStorage.getParentExtension(this);
    if (parentExtension != null)
    {
        messageBundleTypes.addAll(parentExtension.messageBundleTypes);
    }

    for (AnnotatedType<?> type : messageBundleTypes)
    {
        abd.addBean(createMessageBundleBean(type, beanManager));
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:22,代码来源:MessageBundleExtension.java

示例14: addDynamicBeans

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
public void addDynamicBeans(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager bm)
{
    if (dynamicProducer != null && !dynamicConfigTypes.isEmpty())
    {
        afterBeanDiscovery.addBean(new DynamicBean(dynamicProducer, dynamicConfigTypes));
    }
    for (final Class<?> proxyType : dynamicConfigurationBeanClasses)
    {
        afterBeanDiscovery.addBean(new BeanBuilder(null)
                .types(proxyType, Object.class)
                .qualifiers(new DefaultLiteral(), new AnyLiteral())
                .beanLifecycle(new ProxyConfigurationLifecycle(proxyType))
                .scope(ApplicationScoped.class)
                .passivationCapable(true)
                .id("DeltaSpikeConfiguration#" + proxyType.getName())
                .beanClass(proxyType)
                .create());
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:20,代码来源:ConfigurationExtension.java

示例15: afterBeandiscovery

import javax.enterprise.inject.spi.AfterBeanDiscovery; //导入依赖的package包/类
void afterBeandiscovery(@Observes AfterBeanDiscovery event) {
    if (scopesToActivate != null) {
        for (Class<? extends Annotation> scope : scopesToActivate) {
            ContextImpl ctx = new ContextImpl(scope);
            contexts.add(ctx);
            event.addContext(ctx);
        }
    }
    if (beans != null) {
        for (Bean<?> bean : beans) {
            event.addBean(bean);
        }
    }
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:15,代码来源:WeldCDIExtension.java


注:本文中的javax.enterprise.inject.spi.AfterBeanDiscovery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。