Java Code Examples for javax.enterprise.inject.spi.ProcessBean#getBean()

The following examples show how to use javax.enterprise.inject.spi.ProcessBean#getBean() . 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: HessianExtension.java    From tomee with Apache License 2.0 6 votes vote down vote up
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));
        }
    }
}
 
Example 2
Source File: ExtraJCacheExtension.java    From jcache-cdi with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 3
Source File: ExtraJCacheExtension.java    From commons-jcs with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 4
Source File: ExceptionControlExtension.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
/**
 * 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));
            }
        }
    }
}