@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);
   }
 }
 private void validateDecorator(Decorator<?> decorator) {
   Set<Annotation> qualifiers = decorator.getDelegateQualifiers();
   if (decorator.getDelegateType() == null) {
     throw BeanLogger.LOG.decoratorMethodReturnsNull("getDelegateType", decorator);
   }
   Bindings.validateQualifiers(
       qualifiers, getBeanManager(), decorator, "Decorator.getDelegateQualifiers");
   if (decorator.getDecoratedTypes() == null) {
     throw BeanLogger.LOG.decoratorMethodReturnsNull("getDecoratedTypes", decorator);
   }
 }
Exemple #3
0
 protected static Type getFacadeType(InjectionPoint injectionPoint) {
   Type genericType = injectionPoint.getType();
   if (genericType instanceof ParameterizedType) {
     return ((ParameterizedType) genericType).getActualTypeArguments()[0];
   } else {
     throw new IllegalStateException(BeanLogger.LOG.typeParameterMustBeConcrete(injectionPoint));
   }
 }
 private void validateBean(Bean<?> bean) {
   if (bean.getBeanClass() == null) {
     throw BeanLogger.LOG.beanMethodReturnsNull("getBeanClass", bean);
   }
   if (bean.getInjectionPoints() == null) {
     throw BeanLogger.LOG.beanMethodReturnsNull("getInjectionPoints", bean);
   }
   if (bean instanceof PassivationCapable) {
     PassivationCapable passivationCapable = (PassivationCapable) bean;
     if (passivationCapable.getId() == null) {
       throw BeanLogger.LOG.passivationCapableBeanHasNullId(bean);
     }
   }
   if (bean instanceof Interceptor<?>) {
     validateInterceptor((Interceptor<?>) bean);
   } else if (bean instanceof Decorator<?>) {
     validateDecorator((Decorator<?>) bean);
   }
 }
Exemple #5
0
 private void readObject(ObjectInputStream stream) throws InvalidObjectException {
   throw BeanLogger.LOG.proxyRequired();
 }