/** * 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()); }
/** * 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 T newInstance(CreationalContext<T> ctx, BeanManagerImpl manager) { try { T instance = AccessController.doPrivileged(NewInstanceAction.of(proxyClass)); if (!bean.getScope().equals(Dependent.class)) { ctx.push(instance); } ProxyFactory.setBeanInstance(bean.getBeanManager().getContextId(), instance, createEnterpriseTargetBeanInstance(), bean); return instance; } catch (PrivilegedActionException e) { if (e.getCause() instanceof InstantiationException) { throw new WeldException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } else if (e.getCause() instanceof IllegalAccessException) { throw new WeldException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } else { throw new WeldException(e.getCause()); } } catch (Exception e) { throw BeanLogger.LOG.sessionBeanProxyInstantiationFailed(bean, proxyClass, e); } }
protected void registerInterceptors() { InterceptionModel model = beanManager.getInterceptorModelRegistry().get(getAnnotated()); if (model != null) { getBeanManager().getServices().get(EjbServices.class).registerInterceptors(getEjbDescriptor().delegate(), new InterceptorBindingsAdapter(model)); } } }
/** * Produces a factory for a specific bean implementation. * * @param proxiedBeanType the actual enterprise bean */ public EnterpriseProxyFactory(Class<T> proxiedBeanType, SessionBean<T> bean) { super(bean.getBeanManager().getContextId(), proxiedBeanType, ImmutableSet.<Type> builder().addAll(bean.getTypes()) .addAll(bean.getEjbDescriptor().getRemoteBusinessInterfacesAsClasses()).build(), bean); }
/** * Constructor used directly by {@link #readResolve()}. * * @param bean the session bean * @param reference session object reference or {@code null} to create a new reference */ private EnterpriseBeanProxyMethodHandler(SessionBean<T> bean, SessionObjectReference reference) { this.bean = bean; this.manager = bean.getBeanManager(); this.beanId = bean.getIdentifier(); Map<Class<?>, Class<?>> typeToBusinessInterfaceMap = new HashMap<Class<?>, Class<?>>(); discoverBusinessInterfaces(typeToBusinessInterfaceMap, bean.getEjbDescriptor().getRemoteBusinessInterfacesAsClasses()); discoverBusinessInterfaces(typeToBusinessInterfaceMap, bean.getEjbDescriptor().getLocalBusinessInterfacesAsClasses()); this.typeToBusinessInterfaceMap = ImmutableMap.copyOf(typeToBusinessInterfaceMap); if (reference == null) { this.reference = bean.createReference(); BeanLogger.LOG.createdSessionBeanProxy(bean); } else { this.reference = reference; BeanLogger.LOG.activatedSessionBeanProxy(bean); } }
protected EnterpriseTargetBeanInstance createEnterpriseTargetBeanInstance() { if (bean.getEjbDescriptor().isStateless() || bean.getEjbDescriptor().isSingleton()) { return new InjectionPointPropagatingEnterpriseTargetBeanInstance(bean.getBeanClass(), new EnterpriseBeanProxyMethodHandler<T>(bean), bean.getBeanManager()); } else { return new EnterpriseTargetBeanInstance(bean.getBeanClass(), new EnterpriseBeanProxyMethodHandler<T>(bean)); } }