Ejemplo n.º 1
0
 @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.ejbNotFound(proxyClass, e);
   }
 }
Ejemplo n.º 2
0
 protected EnterpriseTargetBeanInstance createEnterpriseTargetBeanInstance() {
   return new InjectionPointPropagatingEnterpriseTargetBeanInstance(
       bean.getBeanClass(), new EnterpriseBeanProxyMethodHandler<T>(bean), bean.getBeanManager());
 }