javax.decorator.Decorator Java Examples

The following examples show how to use javax.decorator.Decorator. 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: CdiScanner.java    From tomee with Apache License 2.0 6 votes vote down vote up
private boolean isBean(final Class clazz) {
    try {
        for (final Annotation a : clazz.getAnnotations()) {
            final Class<? extends Annotation> annotationType = a.annotationType();
            final BeanManagerImpl beanManager = webBeansContext.getBeanManagerImpl();
            if (beanManager.isScope(annotationType)
                    || beanManager.isStereotype(annotationType)
                    || beanManager.isInterceptorBinding(annotationType)
                    || Decorator.class == a.annotationType()) {
                return true;
            }
        }
    }
    catch (final Throwable e) {
        // no-op
    }
    return false;
}
 
Example #2
Source File: BeanClassRefreshAgent.java    From HotswapAgent with GNU General Public License v2.0 5 votes vote down vote up
private static boolean isCDIAnnotation(BeanManagerImpl beanManager, Class<? extends Annotation> annotation) {
    if (Interceptor.class.equals(annotation) || Decorator.class.equals(annotation)) {
        return true;
    }

    boolean isBeanAnnotation = beanManager.isScope(annotation);
    if (!isBeanAnnotation) {
        isBeanAnnotation = beanManager.isStereotype(annotation);
    }
    return isBeanAnnotation;
}
 
Example #3
Source File: CdiEjbBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
public CdiEjbBean(final BeanContext bc, final WebBeansContext webBeansContext, final Class beanClass, final AnnotatedType<T> at,
                  final InjectionTargetFactoryImpl<T> factory, final BeanAttributes<T> attributes) {
    super(webBeansContext, toSessionType(bc.getComponentType()), at,
            new EJBBeanAttributesImpl<T>(bc, attributes),
            beanClass, factory);
    this.beanContext = bc;
    bc.set(Bean.class, this);
    passivatingId = bc.getDeploymentID() + getReturnType().getName();

    final boolean stateful = BeanType.STATEFUL.equals(bc.getComponentType());
    final boolean isDependent = getScope().equals(Dependent.class);
    isDependentAndStateful = isDependent && stateful;
    if (webBeansContext.getBeanManagerImpl().isPassivatingScope(getScope()) && stateful) {
        if (!getBeanContext().isPassivable()) {
            throw new DefinitionException(
                    getBeanContext().getBeanClass()
                            + " is a not apssivation-capable @Stateful with a scope "
                            + getScope().getSimpleName() + " which need passivation");
        }
        passivable = true;
    } else {
        passivable = false;
    }
    if (!isDependent) {
        for (final Type type : attributes.getTypes()) {
            if (ParameterizedType.class.isInstance(type)) {
                throw new DefinitionException("Parameterized session bean should be @Dependent: " + beanClass);
            }
        }
    }
    if (getAnnotatedType().isAnnotationPresent(Interceptor.class) || getAnnotatedType().isAnnotationPresent(Decorator.class)) {
        throw new DefinitionException("An EJB can't be an interceptor or a decorator: " + beanClass);
    }
}
 
Example #4
Source File: ClassScanning.java    From weld-junit with Apache License 2.0 4 votes vote down vote up
private static boolean hasBeanDefiningAnnotation(Class<?> clazz) {
    return isAnnotated(clazz, NormalScope.class) || isAnnotated(clazz, Dependent.class) ||
            isAnnotated(clazz, Interceptor.class) || isAnnotated(clazz, Decorator.class) ||
            isAnnotated(clazz, Stereotype.class);
}