private void checkDecoratedMethods(EnhancedAnnotatedType<T> type, List<Decorator<?>> decorators) { if (type.isFinal()) { throw BeanLogger.LOG.finalBeanClassWithDecoratorsNotAllowed(this); } checkNoArgsConstructor(type); for (Decorator<?> decorator : decorators) { EnhancedAnnotatedType<?> decoratorClass; if (decorator instanceof DecoratorImpl<?>) { DecoratorImpl<?> decoratorBean = (DecoratorImpl<?>) decorator; decoratorClass = decoratorBean.getBeanManager().getServices().get(ClassTransformer.class) .getEnhancedAnnotatedType(decoratorBean.getAnnotated()); } else if (decorator instanceof CustomDecoratorWrapper<?>) { decoratorClass = ((CustomDecoratorWrapper<?>) decorator).getEnhancedAnnotated(); } else { throw BeanLogger.LOG.nonContainerDecorator(decorator); } for (EnhancedAnnotatedMethod<?, ?> decoratorMethod : decoratorClass.getEnhancedMethods()) { EnhancedAnnotatedMethod<?, ?> method = type.getEnhancedMethod(decoratorMethod.getSignature()); if (method != null && !method.isStatic() && !method.isPrivate() && method.isFinal()) { throw BeanLogger.LOG.finalBeanClassWithInterceptorsNotAllowed(this); } } } }
public void endInitialization() { tracker.start(Tracker.OP_END_INIT); final BeanIdentifierIndex index = deploymentManager.getServices().get(BeanIdentifierIndex.class); if (index != null) { deploymentManager.getServices().cleanupAfterBoot(); deploymentManager.cleanupAfterBoot(); for (BeanDeployment beanDeployment : getBeanDeployments()) { BeanManagerImpl beanManager = beanDeployment.getBeanManager(); beanManager.getInterceptorMetadataReader().cleanAfterBoot(); beanManager.getServices().cleanupAfterBoot(); beanManager.cleanupAfterBoot(); for (Decorator<?> decorator : beanManager.getDecorators()) { if (decorator instanceof DecoratorImpl<?>) { Reflections.<DecoratorImpl<?>>cast(decorator).cleanupAfterBoot(); for (Interceptor<?> interceptor : beanManager.getInterceptors()) { if (interceptor instanceof InterceptorImpl<?>) { Reflections.<InterceptorImpl<?>>cast(interceptor).cleanupAfterBoot(); if (modules != null) { modules.processBeanDeployments(getBeanDeployments()); BootstrapLogger.LOG.debugv("EE modules: {0}", modules);
private void validateDecorators(BeanManagerImpl beanManager, DecorableBean<?> bean) { if (!(beanManager.isPassivatingScope(bean.getScope()) || bean instanceof AbstractDecorableBuiltInBean<?>)) { return; } List<Decorator<?>> decorators = bean.getDecorators(); if (decorators.isEmpty()) { return; } for (Decorator<?> decorator : decorators) { if (!Decorators.isPassivationCapable(decorator)) { if (bean instanceof AbstractDecorableBuiltInBean<?>) { throw ValidatorLogger.LOG.builtinBeanWithNonserializableDecorator(decorator, bean); } else { throw ValidatorLogger.LOG.passivatingBeanWithNonserializableDecorator(bean, decorator); } } if (decorator instanceof DecoratorImpl) { beanManager = ((DecoratorImpl<?>) decorator).getBeanManager(); } for (InjectionPoint ij : decorator.getInjectionPoints()) { if (!ij.isDelegate()) { Bean<?> resolvedBean = beanManager.resolve(beanManager.getBeans(ij)); validateInterceptorDecoratorInjectionPointPassivationCapable(ij, resolvedBean, beanManager, bean); } } } }
@Override public String toString() { return "Decorator [" + getBeanClass().toString() + "] decorates [" + Formats.formatTypes(getDecoratedTypes()) + "] with delegate type [" + Formats.formatType(getDelegateType()) + "] and delegate qualifiers [" + Formats.formatAnnotations(getDelegateQualifiers()) + "]"; } }
@SuppressWarnings("unchecked") private void checkAbstractMethods(EnhancedAnnotatedType<T> type) { if(!type.isAbstract()) { return; } Set<Type> decoratedTypes = null; Bean<?> bean = getBean(); if(bean != null && (bean instanceof DecoratorImpl)) { decoratedTypes = ((DecoratorImpl<T>)bean).getDecoratedTypes(); } Decorators.checkAbstractMethods(decoratedTypes, type, beanManager); } }
/** * Indicates whether a {@link Decorator} is passivation capable or not. * @return */ public static boolean isPassivationCapable(Decorator<?> decorator) { if (decorator instanceof CustomDecoratorWrapper<?>) { // unwrap decorator = Reflections.<CustomDecoratorWrapper<?>>cast(decorator).delegate(); } if (decorator instanceof DecoratorImpl<?>) { DecoratorImpl<?> weldDecorator = (DecoratorImpl<?>) decorator; return weldDecorator.getEnhancedAnnotated().isSerializable(); } return decorator instanceof PassivationCapable; } }
protected void initDecoratedTypes() { Set<Type> decoratedTypes = new HashSet<Type>(getEnhancedAnnotated().getInterfaceClosure()); decoratedTypes.retainAll(getTypes()); decoratedTypes.remove(Serializable.class); this.decoratedTypes = SharedObjectCache.instance(beanManager).getSharedSet(decoratedTypes); this.decoratedMethods = new DecoratedMethods(beanManager, this); }
protected void initDelegateInjectionPoint() { // TODO: findDelegateInjectionPoint() is called also from DecoratorInjectionTarget. Try to avoid calling the method multiple times this.delegateInjectionPoint = Decorators.findDelegateInjectionPoint(getEnhancedAnnotated(), getInjectionPoints()); }
/** * Creates a decorator bean * * @param <T> The type * @param clazz The class * @param beanManager the current manager * @return a Bean */ public static <T> DecoratorImpl<T> of(BeanAttributes<T> attributes, EnhancedAnnotatedType<T> clazz, BeanManagerImpl beanManager) { return new DecoratorImpl<T>(attributes, clazz, beanManager); }
public void endInitialization() { tracker.start(Tracker.OP_END_INIT); final BeanIdentifierIndex index = deploymentManager.getServices().get(BeanIdentifierIndex.class); if (index != null) { deploymentManager.getServices().cleanupAfterBoot(); deploymentManager.cleanupAfterBoot(); for (BeanDeployment beanDeployment : getBeanDeployments()) { BeanManagerImpl beanManager = beanDeployment.getBeanManager(); beanManager.getInterceptorMetadataReader().cleanAfterBoot(); beanManager.getServices().cleanupAfterBoot(); beanManager.cleanupAfterBoot(); for (Decorator<?> decorator : beanManager.getDecorators()) { if (decorator instanceof DecoratorImpl<?>) { Reflections.<DecoratorImpl<?>>cast(decorator).cleanupAfterBoot(); for (Interceptor<?> interceptor : beanManager.getInterceptors()) { if (interceptor instanceof InterceptorImpl<?>) { Reflections.<InterceptorImpl<?>>cast(interceptor).cleanupAfterBoot(); if (modules != null) { modules.processBeanDeployments(getBeanDeployments()); BootstrapLogger.LOG.debugv("EE modules: {0}", modules);
private void validateDecorators(BeanManagerImpl beanManager, DecorableBean<?> bean) { if (!(beanManager.isPassivatingScope(bean.getScope()) || bean instanceof AbstractDecorableBuiltInBean<?>)) { return; } List<Decorator<?>> decorators = bean.getDecorators(); if (decorators.isEmpty()) { return; } for (Decorator<?> decorator : decorators) { if (!Decorators.isPassivationCapable(decorator)) { if (bean instanceof AbstractDecorableBuiltInBean<?>) { throw ValidatorLogger.LOG.builtinBeanWithNonserializableDecorator(decorator, bean); } else { throw ValidatorLogger.LOG.passivatingBeanWithNonserializableDecorator(bean, decorator); } } if (decorator instanceof DecoratorImpl) { beanManager = ((DecoratorImpl<?>) decorator).getBeanManager(); } for (InjectionPoint ij : decorator.getInjectionPoints()) { if (!ij.isDelegate()) { Bean<?> resolvedBean = beanManager.resolve(beanManager.getBeans(ij)); validateInterceptorDecoratorInjectionPointPassivationCapable(ij, resolvedBean, beanManager, bean); } } } }
@Override public String toString() { return "Decorator [" + getBeanClass().toString() + "] decorates [" + Formats.formatTypes(getDecoratedTypes()) + "] with delegate type [" + Formats.formatType(getDelegateType()) + "] and delegate qualifiers [" + Formats.formatAnnotations(getDelegateQualifiers()) + "]"; } }
@SuppressWarnings("unchecked") private void checkAbstractMethods(EnhancedAnnotatedType<T> type) { if(!type.isAbstract()) { return; } Set<Type> decoratedTypes = null; Bean<?> bean = getBean(); if(bean != null && (bean instanceof DecoratorImpl)) { decoratedTypes = ((DecoratorImpl<T>)bean).getDecoratedTypes(); } Decorators.checkAbstractMethods(decoratedTypes, type, beanManager); } }
/** * Indicates whether a {@link Decorator} is passivation capable or not. * @return */ public static boolean isPassivationCapable(Decorator<?> decorator) { if (decorator instanceof CustomDecoratorWrapper<?>) { // unwrap decorator = Reflections.<CustomDecoratorWrapper<?>>cast(decorator).delegate(); } if (decorator instanceof DecoratorImpl<?>) { DecoratorImpl<?> weldDecorator = (DecoratorImpl<?>) decorator; return weldDecorator.getEnhancedAnnotated().isSerializable(); } return decorator instanceof PassivationCapable; } }
protected void initDecoratedTypes() { Set<Type> decoratedTypes = new HashSet<Type>(getEnhancedAnnotated().getInterfaceClosure()); decoratedTypes.retainAll(getTypes()); decoratedTypes.remove(Serializable.class); this.decoratedTypes = SharedObjectCache.instance(beanManager).getSharedSet(decoratedTypes); this.decoratedMethods = new DecoratedMethods(beanManager, this); }
protected void initDelegateInjectionPoint() { this.delegateInjectionPoint = Decorators.findDelegateInjectionPoint(getEnhancedAnnotated(), getInjectionPoints()); }
/** * Creates a decorator bean * * @param <T> The type * @param clazz The class * @param beanManager the current manager * @return a Bean */ public static <T> DecoratorImpl<T> of(BeanAttributes<T> attributes, EnhancedAnnotatedType<T> clazz, BeanManagerImpl beanManager) { return new DecoratorImpl<T>(attributes, clazz, beanManager); }
public void endInitialization() { tracker.start(Tracker.OP_END_INIT); final BeanIdentifierIndex index = deploymentManager.getServices().get(BeanIdentifierIndex.class); if (index != null) { deploymentManager.getServices().cleanupAfterBoot(); deploymentManager.cleanupAfterBoot(); for (BeanDeployment beanDeployment : getBeanDeployments()) { BeanManagerImpl beanManager = beanDeployment.getBeanManager(); beanManager.getInterceptorMetadataReader().cleanAfterBoot(); beanManager.getServices().cleanupAfterBoot(); beanManager.cleanupAfterBoot(); for (Decorator<?> decorator : beanManager.getDecorators()) { if (decorator instanceof DecoratorImpl<?>) { Reflections.<DecoratorImpl<?>>cast(decorator).cleanupAfterBoot(); for (Interceptor<?> interceptor : beanManager.getInterceptors()) { if (interceptor instanceof InterceptorImpl<?>) { Reflections.<InterceptorImpl<?>>cast(interceptor).cleanupAfterBoot(); if (modules != null) { modules.processBeanDeployments(getBeanDeployments()); BootstrapLogger.LOG.debugv("EE modules: {0}", modules);
protected void checkDecoratedMethods(EnhancedAnnotatedType<T> type, List<Decorator<?>> decorators) { if (type.isFinal()) { throw BeanLogger.LOG.finalBeanClassWithDecoratorsNotAllowed(this); } checkNoArgsConstructor(type); for (Decorator<?> decorator : decorators) { EnhancedAnnotatedType<?> decoratorClass; if (decorator instanceof DecoratorImpl<?>) { DecoratorImpl<?> decoratorBean = (DecoratorImpl<?>) decorator; decoratorClass = decoratorBean.getBeanManager().getServices().get(ClassTransformer.class).getEnhancedAnnotatedType(decoratorBean.getAnnotated()); } else if (decorator instanceof CustomDecoratorWrapper<?>) { decoratorClass = ((CustomDecoratorWrapper<?>) decorator).getEnhancedAnnotated(); } else { throw BeanLogger.LOG.nonContainerDecorator(decorator); } for (EnhancedAnnotatedMethod<?, ?> decoratorMethod : decoratorClass.getEnhancedMethods()) { EnhancedAnnotatedMethod<?, ?> method = type.getEnhancedMethod(decoratorMethod.getSignature()); if (method != null && !method.isStatic() && !method.isPrivate() && method.isFinal()) { throw BeanLogger.LOG.finalBeanClassWithInterceptorsNotAllowed(this); } } } }
private void validateDecorators(BeanManagerImpl beanManager, DecorableBean<?> bean) { if (!(beanManager.isPassivatingScope(bean.getScope()) || bean instanceof AbstractDecorableBuiltInBean<?>)) { return; } List<Decorator<?>> decorators = bean.getDecorators(); if (decorators.isEmpty()) { return; } for (Decorator<?> decorator : decorators) { if (!Decorators.isPassivationCapable(decorator)) { if (bean instanceof AbstractDecorableBuiltInBean<?>) { throw ValidatorLogger.LOG.builtinBeanWithNonserializableDecorator(decorator, bean); } else { throw ValidatorLogger.LOG.passivatingBeanWithNonserializableDecorator(bean, decorator); } } if (decorator instanceof DecoratorImpl) { beanManager = ((DecoratorImpl<?>) decorator).getBeanManager(); } for (InjectionPoint ij : decorator.getInjectionPoints()) { if (!ij.isDelegate()) { Bean<?> resolvedBean = beanManager.resolve(beanManager.getBeans(ij)); validateInterceptorDecoratorInjectionPointPassivationCapable(ij, resolvedBean, beanManager, bean); } } } }