Java 类javax.enterprise.inject.spi.ProcessBean 实例源码

项目:osgi.ee    文件:ServiceExtension.java   
/**
 * Process a bean. Checks the bean for @Service annotation and if it is found, verifies
 * the bean scope and marks it for export as service at a later stage.
 *
 * @param event The process bean event. See CDI specification
 * @param <T> The type of the bean
 */
public <T> void processBean(@Observes ProcessBean<T> event) {
    Bean<T> bean = event.getBean();
    Service service = BeanExporter.getServiceDefinition(bean);
    if (service == null) {
        return;
    }
    // Check the scope. Must be global.
    Class<? extends Annotation> scope = bean.getScope();
    if (!scope.equals(ComponentScoped.class) && !scope.equals(ApplicationScoped.class)) {
        // Set an error.
        event.addDefinitionError(new Exception("beans annotated with @Service must have a global scope"));
        return;
    }
    // Mark the bean as exportable.
    exportedBeans.put(bean, null);
}
项目:tomee    文件:HessianExtension.java   
protected <X> void findHessianWebServices(final @Observes ProcessBean<X> processBean) {
    if (ProcessSessionBean.class.isInstance(processBean)) {
        return;
    }

    final Bean<X> bean = processBean.getBean();
    final Class<?> beanClass = bean.getBeanClass();
    for (final Class<?> itf : beanClass.getInterfaces()) {
        final Hessian hessian = itf.getAnnotation(Hessian.class);
        final String key = "openejb.hessian." + beanClass.getName() + "_" + itf.getName() + ".path";
        final String path = appInfo.properties.getProperty(key, SystemInstance.get().getProperty(key));
        if (hessian != null || path != null) {
            toDeploy.add(new Deployment(itf, path, bean));
        }
    }
}
项目:Camel    文件:CdiCamelExtension.java   
private void beans(@Observes ProcessBean<?> pb, BeanManager manager) {
    cdiBeans.add(pb.getBean());
    // Lookup for CDI event endpoint injection points
    pb.getBean().getInjectionPoints().stream()
        .filter(ip -> CdiEventEndpoint.class.equals(getRawType(ip.getType())))
        .forEach(ip -> {
            Type type = ip.getType() instanceof ParameterizedType
                ? ((ParameterizedType) ip.getType()).getActualTypeArguments()[0]
                : Object.class;
            String uri = eventEndpointUri(type, ip.getQualifiers());
            cdiEventEndpoints.put(uri, new CdiEventEndpoint<>(uri, type, ip.getQualifiers(), manager));
        });
}
项目:jcache-cdi    文件:ExtraJCacheExtension.java   
public <A> void processBean(final @Observes ProcessBean<A> processBeanEvent)
{
    if (!ACTIVATED)
    {
        return;
    }

    if (cacheManagerFound && cacheProviderFound)
    {
        return;
    }

    final Bean<A> bean = processBeanEvent.getBean();
    if (CacheManagerBean.class.isInstance(bean) || CacheProviderBean.class.isInstance(bean))
    {
        return;
    }

    if (!cacheManagerFound)
    {
        cacheManagerFound = bean.getTypes().contains(CacheManager.class);
    }
    if (!cacheProviderFound)
    {
        cacheProviderFound = bean.getTypes().contains(CachingProvider.class);
    }
}
项目:ovirt-optimizer    文件:AutoloadExtension.java   
public <T> void collect(@Observes ProcessBean<T> event) {
    if (event.getAnnotated().isAnnotationPresent(Autoload.class) &&
            event.getAnnotated().isAnnotationPresent(ApplicationScoped.class)) {
        autoloadBeanList.add(event.getBean());
        log.info(String.format("Adding %s to the list of beans to autostart.",
                event.getBean().getBeanClass().toString()));
    }
}
项目:jsf-portal    文件:EagerExtension.java   
public <T> void collect(@Observes ProcessBean<T> event)
{
    if (event.getAnnotated().isAnnotationPresent(Eager.class)
        && event.getAnnotated().isAnnotationPresent(ApplicationScoped.class)) {
        eagerBeansList.add(event.getBean());
    }
}
项目:CDI-RegistrationSample_1.1    文件:StartupExtension.java   
<X> void processBean(@Observes ProcessBean<X> event)
{
   if (event.getAnnotated().isAnnotationPresent(Startup.class) &&
         event.getAnnotated().isAnnotationPresent(SingletonService.class))
   {
      System.out.println("CDI: Found @Startup in "+event.getBean().getName());
      startupBeans.add(event.getBean());
   }
}
项目:auto-web-auth    文件:StartupExtension.java   
/**
 * The container fires an event for each enabled bean, interceptor or
 * decorator deployed in a bean archive, before registering the
 * javax.enterprise.inject.spi.Bean object.
 * 
 * Scan beans for {@link Startup} annotation.
 * 
 * @param beanEvent
 *           event
 */
<T> void processBean(@Observes ProcessBean<T> beanEvent)
{
   this.log.info("{} is processing Bean before registering the Bean object", beanEvent
         .getAnnotated().getClass().getName());
   if (beanEvent.getAnnotated().isAnnotationPresent(Startup.class)
         && beanEvent.getAnnotated().isAnnotationPresent(ApplicationScoped.class))
   {
      this.startupBeans.add(beanEvent.getBean());
   }
}
项目:deltaspike    文件:ExceptionControlExtension.java   
/**
 * Listener to ProcessBean event to locate handlers.
 *
 * @param processBean current {@link AnnotatedType}
 * @param beanManager  Activated Bean Manager
 * @throws TypeNotPresentException if any of the actual type arguments refers to a non-existent type declaration
 *                                 when trying to obtain the actual type arguments from a
 *                                 {@link java.lang.reflect.ParameterizedType}
 * @throws java.lang.reflect.MalformedParameterizedTypeException
 *                                 if any of the actual type parameters refer to a parameterized type that cannot
 *                                 be instantiated for any reason when trying to obtain the actual type arguments
 *                                 from a {@link java.lang.reflect.ParameterizedType}
 */
@SuppressWarnings("UnusedDeclaration")
public <T> void findHandlers(@Observes final ProcessBean<?> processBean, final BeanManager beanManager)
{
    if (!isActivated)
    {
        return;
    }

    if (processBean.getBean() instanceof Interceptor || processBean.getBean() instanceof Decorator ||
            !(processBean.getAnnotated() instanceof AnnotatedType))
    {
        return;
    }

    AnnotatedType annotatedType = (AnnotatedType)processBean.getAnnotated();

    if (annotatedType.getJavaClass().isAnnotationPresent(ExceptionHandler.class))
    {
        final Set<AnnotatedMethod<? super T>> methods = annotatedType.getMethods();

        for (AnnotatedMethod<? super T> method : methods)
        {
            if (HandlerMethodImpl.isHandler(method))
            {
                if (method.getJavaMember().getExceptionTypes().length != 0)
                {
                    processBean.addDefinitionError(new IllegalArgumentException(
                        String.format("Handler method %s must not throw exceptions", method.getJavaMember())));
                }

                //beanManager won't be stored in the instance -> no issue with wls12c
                registerHandlerMethod(new HandlerMethodImpl(processBean.getBean(), method, beanManager));
            }
        }
    }
}
项目:deltaspike    文件:ConfigurationExtension.java   
public void findSources(@Observes ProcessBean<? extends ConfigSource> source)
{
    if (!source.getAnnotated().isAnnotationPresent(Source.class))
    {
        return;
    }
    cdiSources.add(source.getBean());
}
项目:deltaspike    文件:ConfigurationExtension.java   
public void findFilters(@Observes ProcessBean<? extends ConfigFilter> filter)
{
    if (!filter.getAnnotated().isAnnotationPresent(Filter.class))
    {
        return;
    }
    cdiFilters.add(filter.getBean());
}
项目:deltaspike    文件:ConfigurationExtension.java   
public void collectDynamicTypes(@Observes ProcessBean<?> processBean)
{
    for (final InjectionPoint ip : processBean.getBean().getInjectionPoints())
    {
        final ConfigProperty annotation = ip.getAnnotated().getAnnotation(ConfigProperty.class);
        if (annotation == null || annotation.converter() == ConfigResolver.Converter.class)
        {
            continue;
        }

        dynamicConfigTypes.add(ip.getType());
    }
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:ObserverExtension.java   
<T> void processBean(@Observes ProcessBean<T> pb) {
    logger.info("finished the scanning process");
    processBean++;
}
项目:hawkular-apm    文件:EagerExtension.java   
public <T> void collect(@Observes ProcessBean<T> event) {
    if (event.getAnnotated().isAnnotationPresent(Eager.class) &&
            event.getAnnotated().isAnnotationPresent(ApplicationScoped.class)) {
        eagerBeansList.add(event.getBean());
    }
}
项目:activemq-artemis    文件:ArtemisExtension.java   
void foundClientConfig(@Observes ProcessBean<?> processBean) {
   if (processBean.getBean().getTypes().contains(ArtemisClientConfiguration.class)) {
      ActiveMQCDILogger.LOGGER.discoveredConfiguration(processBean);
      foundConfiguration = true;
   }
}
项目:activemq-artemis    文件:ArtemisExtension.java   
void foundEmbeddedConfig(@Observes ProcessBean<?> processBean) {
   if (processBean.getBean().getTypes().contains(Configuration.class)) {
      ActiveMQCDILogger.LOGGER.discoveredClientConfiguration(processBean);
      foundEmbeddedConfig = true;
   }
}
项目:activemq-artemis    文件:ActiveMQCDILogger.java   
@LogMessage
@Message(id = 571000, value = "Discovered configuration class {0}", format = Message.Format.MESSAGE_FORMAT)
void discoveredConfiguration(ProcessBean<?> pb);
项目:activemq-artemis    文件:ActiveMQCDILogger.java   
@LogMessage
@Message(id = 571001, value = "Discovered client configuration class {0}", format = Message.Format.MESSAGE_FORMAT)
void discoveredClientConfiguration(ProcessBean<?> pb);
项目:osgi.ee    文件:ComponentExtension.java   
public <T> void processBean(@Observes ProcessBean<T> event) {
    if (event.getAnnotated().isAnnotationPresent(ComponentScoped.class)) {
        // Add this one.
        theseBeans.add(event.getBean());
    }
}
项目:rtgov-ui    文件:StartupBeanExtension.java   
<X> void processBean(@Observes ProcessBean<X> event) {
    if (event.getAnnotated().isAnnotationPresent(Startup.class)
            && event.getAnnotated().isAnnotationPresent(ApplicationScoped.class)) {
        startupBeans.add(event.getBean());
    }
}
项目:hawkular-metrics    文件:EagerExtension.java   
public <T> void collect(@Observes ProcessBean<T> event) {
    if (event.getAnnotated().isAnnotationPresent(Eager.class) &&
        event.getAnnotated().isAnnotationPresent(ApplicationScoped.class)) {
        eagerBeansList.add(event.getBean());
    }
}
项目:Java-EE    文件:LifeCycleLogger.java   
<X> void logLifecycleEvent(@Observes ProcessBean<X> event) {
    LOGGER.info("ProcessBean: bean=" + event.getBean());
}
项目:hammock    文件:FlywayExtension.java   
public void findFlywayBean(@Observes ProcessBean<Flyway> flywayProcessBean) {
   this.foundFlywayBean = true;
}
项目:kumuluzee-examples    文件:EagerExtension.java   
/**
 * <p>Collect all beans that have the {@link com.acme.trains.Eager @Eager} and {@link javax.enterprise.context.ApplicationScoped @ApplicationScoped}
 * annotation and save them for startup.</p>
 *
 * @param event Event represents and contains the found CDI bean during initial scanning.
 * @param <T> Class of the found bean.
 *
 * @see com.acme.trains.Eager
 * @see javax.enterprise.context.ApplicationScoped
 */
public <T> void collect(@Observes ProcessBean<T> event) {

    if (event.getAnnotated().isAnnotationPresent(Eager.class)
            && event.getAnnotated().isAnnotationPresent(ApplicationScoped.class)) {
        eagerBeansList.add(event.getBean());
    }
}