/** * check if the given class has any non-private, non-static final method * @return the method name or <code>null</code> if there is no such method. */ private String hasNonPrivateFinalMethod(Class<?> beanClass) { if (beanClass == Object.class) { return null; } // we also need to check the methods of the parent classes String finalMethodName = hasNonPrivateFinalMethod(beanClass.getSuperclass()); if (finalMethodName != null) { return finalMethodName; } Method[] methods = SecurityUtil.doPrivilegedGetDeclaredMethods(beanClass); for (Method m : methods) { int modifiers = m.getModifiers(); if (Modifier.isFinal(modifiers) && !Modifier.isPrivate(modifiers) && !Modifier.isStatic(modifiers) && !m.isSynthetic() && !m.isBridge()) { return m.getName(); } } return null; }
/** * If bean is passivation capable, it validate all of its dependencies. * @throws org.apache.webbeans.exception.WebBeansConfigurationException if not satisfy passivation dependencies */ public <T> void validatePassivationCapable(OwbBean<T> bean) { if (isPassivationCapable(bean)) { if (EnterpriseBeanMarker.class.isInstance(bean)) { validatePassivationCapableDependencies(bean, bean.getInjectionPoints()); if (BeanInterceptorInfoProvider.class.isInstance(bean)) { validatePassivationCapableInterceptorInfo(bean, BeanInterceptorInfoProvider.class.cast(bean).interceptorInfo()); } return; } if (!(bean instanceof ProducerMethodBean)) { validatePassivationCapableDependencies(bean, bean.getInjectionPoints()); } if (bean.getProducer() instanceof InjectionTargetImpl) { InjectionTargetImpl<T> injectionTarget = (InjectionTargetImpl<T>)bean.getProducer(); BeanInterceptorInfo interceptorInfo = injectionTarget.getInterceptorInfo(); validatePassivationCapableInterceptorInfo(bean, interceptorInfo); } } }
private <T> void validatePassivationCapableInterceptorInfo(OwbBean<T> bean, BeanInterceptorInfo interceptorInfo) { if (interceptorInfo != null) { for (Interceptor<?> ejbInterceptor: interceptorInfo.getEjbInterceptors()) { validatePassivationCapableDependency(bean, ejbInterceptor); } for (Interceptor<?> cdiInterceptor: interceptorInfo.getCdiInterceptors()) { validatePassivationCapableDependency(bean, cdiInterceptor); } for (Decorator<?> decorators: interceptorInfo.getDecorators()) { validatePassivationCapableDependency(bean, decorators); } } }
private <T> void validatePassivationCapableDependency(Bean<T> bean, Bean<?> dependentBean) { if (!isPassivationCapable(dependentBean)) { String type = dependentBean instanceof Interceptor? "Interceptor ": "Decorator "; throw new WebBeansDeploymentException( "Passivation capable beans must satisfy passivation capable dependencies. " + "Bean : " + bean.toString() + " does not satisfy. " + type + dependentBean.toString() + " is not passivation capable"); } validatePassivationCapableDependencies(bean, dependentBean.getInjectionPoints()); }
/** * {@inheritDoc} */ public M getBean() { M bean = (M) new ManagedBean<>(webBeansContext, WebBeansType.MANAGED, annotatedType, beanAttributes, annotatedType.getJavaClass()); bean.setEnabled(webBeansContext.getWebBeansUtil().isBeanEnabled(beanAttributes, annotatedType, bean.getStereotypes())); webBeansContext.getWebBeansUtil().checkManagedBeanCondition(annotatedType); WebBeansUtil.checkGenericType(annotatedType.getJavaClass(), beanAttributes.getScope()); webBeansContext.getWebBeansUtil().validateBeanInjection(bean); UnproxyableResolutionException lazyException = webBeansContext.getDeploymentValidationService().validateProxyable(bean, ignoreFinalMethods); if (lazyException == null) { return bean; } return (M) new UnproxyableBean<>(webBeansContext, WebBeansType.MANAGED, beanAttributes, annotatedType, annotatedType.getJavaClass(), lazyException); } }
webBeansContext.getDeploymentValidationService().validatePassivationCapable((OwbBean<?>)beanObj);
.validateProxyable(producerFieldBean, processBeanAttributes.isIgnoreFinalMethods()); if (lazyException != null) // should we use UnproxyableBean there too? if not required by TCK, better to fail eagerly
.validateProxyable(producerMethodBean, processBeanAttributes.isIgnoreFinalMethods()); if (lazyException != null) // should we use UnproxyableBean there too? if not required by TCK, better to fail eagerly
String finalMethodName = hasNonPrivateFinalMethod(beanClass); if (finalMethodName != null)