interceptionModel = beanManager.getInterceptorModelRegistry().get(getType()); && (interceptionModel.hasExternalNonConstructorInterceptors() || interceptionModel.hasTargetClassInterceptors()); decorators = beanManager.resolveDecorators(getBean().getTypes(), getBean().getQualifiers()); SubclassedComponentInstantiator.forInterceptedDecoratedBean(annotatedType, getBean(), delegate, beanManager)); getBeanManager().getContextId(), getInstantiator(), getBean(), decorators));
@Override public void initializeAfterBeanDiscovery(EnhancedAnnotatedType<T> annotatedType) { initializeInterceptionModel(annotatedType); List<Decorator<?>> decorators = beanManager.resolveDecorators(getBean().getTypes(), getBean().getQualifiers()); if (!decorators.isEmpty()) { Instantiator<T> instantiator = getInstantiator(); EnhancedAnnotatedType<T> implementationClass = Beans.getEjbImplementationClass(getBean()); instantiator = SubclassedComponentInstantiator.forInterceptedDecoratedBean(implementationClass, getBean(), (AbstractInstantiator<T>) instantiator, beanManager); instantiator = new SubclassDecoratorApplyingInstantiator<T>(getBeanManager().getContextId(), instantiator, getBean(), decorators, implementationClass.getJavaClass()); setInstantiator(instantiator); } /* * We only take care of @AroundConstructor interception. The EJB container deals with the other types of interception. */ setupConstructorInterceptionInstantiator(beanManager.getInterceptorModelRegistry().get(getType())); }
@Override public <T> BasicInjectionTarget<T> createMessageDrivenInjectionTarget(EnhancedAnnotatedType<T> type, EjbDescriptor<T> d, BeanManagerImpl manager) { InternalEjbDescriptor<T> descriptor = InternalEjbDescriptor.of(d); EnhancedAnnotatedType<T> implementationClass = SessionBeans.getEjbImplementationClass(descriptor, manager, type); Instantiator<T> instantiator = null; if (type.equals(implementationClass)) { instantiator = new DefaultInstantiator<T>(type, null, manager); } else { // Session bean subclassed by the EJB container instantiator = SubclassedComponentInstantiator.forSubclassedEjb(type, implementationClass, null, manager); } InterceptionModel interceptionModel = manager.getInterceptorModelRegistry().get(type.slim()); if (interceptionModel != null) { if (interceptionModel.hasExternalNonConstructorInterceptors()) { instantiator = SubclassedComponentInstantiator .forInterceptedDecoratedBean(implementationClass, null, (AbstractInstantiator<T>) instantiator, manager); instantiator = new InterceptorApplyingInstantiator<>(instantiator, interceptionModel, type.slim()); } if (interceptionModel.hasExternalConstructorInterceptors()) { instantiator = new ConstructorInterceptionInstantiator<>(instantiator, interceptionModel, type.slim()); } } return BasicInjectionTarget.createDefault(type, null, manager, instantiator); }
protected Class<T> createEnhancedSubclass(EnhancedAnnotatedType<T> type, Bean<?> bean, BeanManagerImpl manager) { Set<InterceptionModel> models = getInterceptionModelsForType(type, manager, bean); Set<MethodSignature> enhancedMethodSignatures = new HashSet<MethodSignature>(); Set<MethodSignature> interceptedMethodSignatures = (models == null) ? enhancedMethodSignatures : new HashSet<MethodSignature>(); for (AnnotatedMethod<?> method : Beans.getInterceptableMethods(type)) { enhancedMethodSignatures.add(MethodSignatureImpl.of(method)); if (models != null) { for (InterceptionModel model : models) { if (!model.getInterceptors(InterceptionType.AROUND_INVOKE, method.getJavaMember()).isEmpty()) { interceptedMethodSignatures.add(MethodSignatureImpl.of(method)); break; } } } } Set<Type> types = null; if (bean == null) { types = Collections.<Type>singleton(type.getJavaClass()); } else { types = bean.getTypes(); } return new InterceptedSubclassFactory<T>(manager.getContextId(), type.getJavaClass(), types, bean, enhancedMethodSignatures, interceptedMethodSignatures).getProxyClass(); }
protected EnhancedAnnotatedConstructor<T> initEnhancedSubclass(BeanManagerImpl manager, EnhancedAnnotatedType<T> type, Bean<?> bean, ConstructorInjectionPoint<T> originalConstructorInjectionPoint) { ClassTransformer transformer = manager.getServices().get(ClassTransformer.class); EnhancedAnnotatedType<T> enhancedSubclass = transformer.getEnhancedAnnotatedType(createEnhancedSubclass(type, bean, manager), type.slim().getIdentifier().getBdaId()); return findMatchingConstructor(originalConstructorInjectionPoint.getSignature(), enhancedSubclass); }
public static <T> SubclassedComponentInstantiator<T> forSubclassedEjb(EnhancedAnnotatedType<T> componentType, EnhancedAnnotatedType<T> subclass, Bean<T> bean, BeanManagerImpl manager) { final EnhancedAnnotatedConstructor<T> componentConstructor = Beans.getBeanConstructor(componentType); final EnhancedAnnotatedConstructor<T> subclassConstructor = findMatchingConstructor(componentConstructor.getSignature(), subclass); final ConstructorInjectionPoint<T> cip = InjectionPointFactory.instance().createConstructorInjectionPoint(bean, componentType.getJavaClass(), subclassConstructor, manager); return new SubclassedComponentInstantiator<T>(cip, componentConstructor.getJavaMember()); }
protected SubclassedComponentInstantiator(EnhancedAnnotatedType<T> type, Bean<T> bean, ConstructorInjectionPoint<T> originalConstructor, BeanManagerImpl manager) { EnhancedAnnotatedConstructor<T> constructorForEnhancedSubclass = initEnhancedSubclass(manager, type, bean, originalConstructor); this.proxyClassConstructorInjectionPoint = new ProxyClassConstructorInjectionPointWrapper<T>(bean, type.getJavaClass(), constructorForEnhancedSubclass, originalConstructor, manager); this.componentClassConstructor = originalConstructor.getAnnotated().getJavaMember(); }
@Override protected Instantiator<T> initInstantiator(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Set<InjectionPoint> injectionPoints) { if (bean instanceof SessionBean<?>) { EnhancedAnnotatedType<T> implementationClass = Beans.getEjbImplementationClass((SessionBean<T>) bean); AbstractInstantiator<T> instantiator = null; if (type.equals(implementationClass)) { instantiator = new DefaultInstantiator<T>(type, bean, beanManager); } else { // Session bean subclassed by the EJB container instantiator = SubclassedComponentInstantiator.forSubclassedEjb(type, implementationClass, bean, beanManager); } injectionPoints.addAll(instantiator.getConstructorInjectionPoint().getParameterInjectionPoints()); return instantiator; } else { throw new IllegalArgumentException("Cannot create SessionBeanInjectionTarget for " + bean); } }
public static <T> SubclassedComponentInstantiator<T> forInterceptedDecoratedBean(EnhancedAnnotatedType<T> type, Bean<T> bean, AbstractInstantiator<T> delegate, BeanManagerImpl manager) { return new SubclassedComponentInstantiator<T>(type, bean, delegate.getConstructorInjectionPoint(), manager); }
@Override protected Instantiator<T> initInstantiator(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager, Set<InjectionPoint> injectionPoints) { if (bean instanceof SessionBean<?>) { EnhancedAnnotatedType<T> implementationClass = SessionBeans.getEjbImplementationClass((SessionBean<T>) bean); AbstractInstantiator<T> instantiator = null; if (type.equals(implementationClass)) { instantiator = new DefaultInstantiator<T>(type, bean, beanManager); } else { // Session bean subclassed by the EJB container instantiator = SubclassedComponentInstantiator.forSubclassedEjb(type, implementationClass, bean, beanManager); } injectionPoints.addAll(instantiator.getConstructorInjectionPoint().getParameterInjectionPoints()); return instantiator; } else { throw new IllegalArgumentException("Cannot create SessionBeanInjectionTarget for " + bean); } }
protected InjectionTarget<T> createMessageDrivenInjectionTarget(InternalEjbDescriptor<T> descriptor) { EnhancedAnnotatedType<T> implementationClass = Beans.getEjbImplementationClass(descriptor, manager, type); AbstractInstantiator<T> instantiator = null; if (type.equals(implementationClass)) { instantiator = new DefaultInstantiator<T>(type, null, manager); } else { // Session bean subclassed by the EJB container instantiator = SubclassedComponentInstantiator.forSubclassedEjb(type, implementationClass, null, manager); } return prepareInjectionTarget(BasicInjectionTarget.createDefault(type, null, manager, instantiator)); }
@Override public void initializeAfterBeanDiscovery(EnhancedAnnotatedType<T> annotatedType) { initializeInterceptionModel(annotatedType); List<Decorator<?>> decorators = beanManager.resolveDecorators(getBean().getTypes(), getBean().getQualifiers()); if (!decorators.isEmpty()) { Instantiator<T> instantiator = getInstantiator(); EnhancedAnnotatedType<T> implementationClass = SessionBeans.getEjbImplementationClass(getBean()); instantiator = SubclassedComponentInstantiator.forInterceptedDecoratedBean(implementationClass, getBean(), (AbstractInstantiator<T>) instantiator, beanManager); instantiator = new SubclassDecoratorApplyingInstantiator<T>(getBeanManager().getContextId(), instantiator, getBean(), decorators, implementationClass.getJavaClass()); setInstantiator(instantiator); } /* * We only take care of @AroundConstructor interception. The EJB container deals with the other types of interception. */ setupConstructorInterceptionInstantiator(beanManager.getInterceptorModelRegistry().get(getType())); }
protected Class<T> createEnhancedSubclass(EnhancedAnnotatedType<T> type, Bean<?> bean, BeanManagerImpl manager) { Set<InterceptionModel> models = getInterceptionModelsForType(type, manager, bean); Set<MethodSignature> enhancedMethodSignatures = new HashSet<MethodSignature>(); Set<MethodSignature> interceptedMethodSignatures = (models == null) ? enhancedMethodSignatures : new HashSet<MethodSignature>(); for (AnnotatedMethod<?> method : Beans.getInterceptableMethods(type)) { enhancedMethodSignatures.add(MethodSignatureImpl.of(method)); if (models != null) { for (InterceptionModel model : models) { if (!model.getInterceptors(InterceptionType.AROUND_INVOKE, method.getJavaMember()).isEmpty()) { interceptedMethodSignatures.add(MethodSignatureImpl.of(method)); break; } } } } Set<Type> types = null; if (bean == null) { types = Collections.<Type>singleton(type.getJavaClass()); } else { types = bean.getTypes(); } return new InterceptedSubclassFactory<T>(manager.getContextId(), type.getJavaClass(), types, bean, enhancedMethodSignatures, interceptedMethodSignatures).getProxyClass(); }
protected EnhancedAnnotatedConstructor<T> initEnhancedSubclass(BeanManagerImpl manager, EnhancedAnnotatedType<T> type, Bean<?> bean, ConstructorInjectionPoint<T> originalConstructorInjectionPoint) { ClassTransformer transformer = manager.getServices().get(ClassTransformer.class); EnhancedAnnotatedType<T> enhancedSubclass = transformer.getEnhancedAnnotatedType(createEnhancedSubclass(type, bean, manager), type.slim().getIdentifier().getBdaId()); return findMatchingConstructor(originalConstructorInjectionPoint.getSignature(), enhancedSubclass); }
public static <T> SubclassedComponentInstantiator<T> forSubclassedEjb(EnhancedAnnotatedType<T> componentType, EnhancedAnnotatedType<T> subclass, Bean<T> bean, BeanManagerImpl manager) { final EnhancedAnnotatedConstructor<T> componentConstructor = Beans.getBeanConstructor(componentType); final EnhancedAnnotatedConstructor<T> subclassConstructor = findMatchingConstructor(componentConstructor.getSignature(), subclass); final ConstructorInjectionPoint<T> cip = InjectionPointFactory.instance().createConstructorInjectionPoint(bean, componentType.getJavaClass(), subclassConstructor, manager); return new SubclassedComponentInstantiator<T>(cip, componentConstructor.getJavaMember()); }
protected SubclassedComponentInstantiator(EnhancedAnnotatedType<T> type, Bean<T> bean, ConstructorInjectionPoint<T> originalConstructor, BeanManagerImpl manager) { EnhancedAnnotatedConstructor<T> constructorForEnhancedSubclass = initEnhancedSubclass(manager, type, bean, originalConstructor); this.proxyClassConstructorInjectionPoint = new ProxyClassConstructorInjectionPointWrapper<T>(bean, type.getJavaClass(), constructorForEnhancedSubclass, originalConstructor, manager); this.componentClassConstructor = originalConstructor.getAnnotated().getJavaMember(); }
public static <T> SubclassedComponentInstantiator<T> forInterceptedDecoratedBean(EnhancedAnnotatedType<T> type, Bean<T> bean, AbstractInstantiator<T> delegate, BeanManagerImpl manager) { return new SubclassedComponentInstantiator<T>(type, bean, delegate.getConstructorInjectionPoint(), manager); }
interceptionModel = beanManager.getInterceptorModelRegistry().get(getType()); boolean hasNonConstructorInterceptors = interceptionModel != null && (interceptionModel.hasExternalNonConstructorInterceptors() || interceptionModel.hasTargetClassInterceptors()); decorators = beanManager.resolveDecorators(getBean().getTypes(), getBean().getQualifiers()); setInstantiator(SubclassedComponentInstantiator.forInterceptedDecoratedBean(annotatedType, getBean(), delegate, beanManager)); if (hasDecorators) { setInstantiator(new SubclassDecoratorApplyingInstantiator<T>(getBeanManager().getContextId(), getInstantiator(), getBean(), decorators));
protected Class<T> createEnhancedSubclass(EnhancedAnnotatedType<T> type, Bean<?> bean, BeanManagerImpl manager) { Set<InterceptionModel> models = getInterceptionModelsForType(type, manager, bean); Set<MethodSignature> enhancedMethodSignatures = new HashSet<MethodSignature>(); Set<MethodSignature> interceptedMethodSignatures = (models == null) ? enhancedMethodSignatures : new HashSet<MethodSignature>(); for (AnnotatedMethod<?> method : Beans.getInterceptableMethods(type)) { enhancedMethodSignatures.add(MethodSignatureImpl.of(method)); if (models != null) { for (InterceptionModel model : models) { if (!model.getInterceptors(InterceptionType.AROUND_INVOKE, method.getJavaMember()).isEmpty()) { interceptedMethodSignatures.add(MethodSignatureImpl.of(method)); break; } } } } Set<Type> types = null; if (bean == null) { types = Collections.<Type>singleton(type.getJavaClass()); } else { types = bean.getTypes(); } return new InterceptedSubclassFactory<T>(manager.getContextId(), type.getJavaClass(), types, bean, enhancedMethodSignatures, interceptedMethodSignatures).getProxyClass(); }
protected EnhancedAnnotatedConstructor<T> initEnhancedSubclass(BeanManagerImpl manager, EnhancedAnnotatedType<T> type, Bean<?> bean, ConstructorInjectionPoint<T> originalConstructorInjectionPoint) { ClassTransformer transformer = manager.getServices().get(ClassTransformer.class); EnhancedAnnotatedType<T> enhancedSubclass = transformer.getEnhancedAnnotatedType(createEnhancedSubclass(type, bean, manager), type.slim().getIdentifier().getBdaId()); return findMatchingConstructor(originalConstructorInjectionPoint.getSignature(), enhancedSubclass); }