@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); } }
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)); }
/** * Returns {@link EnhancedAnnotatedType} for the EJB implementation class. Throws {@link IllegalStateException} if called after bootstrap. * @param bean * @throws IllegalStateException if called after bootstrap * @return {@link EnhancedAnnotatedType} representation of this EJB's implementation class */ public static <T> EnhancedAnnotatedType<T> getEjbImplementationClass(SessionBean<T> bean) { return getEjbImplementationClass(bean.getEjbDescriptor(), bean.getBeanManager(), bean.getEnhancedAnnotated()); }
@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())); }