public static Method doResolveViewMethod(final Bean<?> component, final Method declaredMethod) { if (!(component instanceof CdiEjbBean)) { return declaredMethod; } final CdiEjbBean cdiEjbBean = (CdiEjbBean) component; final BeanContext beanContext = cdiEjbBean.getBeanContext(); for (final Class intface : beanContext.getBusinessLocalInterfaces()) { try { return intface.getMethod(declaredMethod.getName(), declaredMethod.getParameterTypes()); } catch (final NoSuchMethodException ignore) { // no-op } } return null; }
private static void validateDisposeMethods(final CdiEjbBean<?> bean) { if (!bean.getBeanContext().isLocalbean()) { for (final Method m : bean.getBeanContext().getBeanClass().getMethods()) { if (m.getDeclaringClass().equals(Object.class)) { continue; } if (m.getParameterTypes().length > 0) { for (final Annotation[] a : m.getParameterAnnotations()) { for (final Annotation ann : a) { if (ann.annotationType().equals(Disposes.class) && doResolveViewMethod(bean, m) == null) { throw new WebBeansConfigurationException("@Disposes is forbidden on non business EJB methods"); } } } } } } }
private static void validateDisposeMethods(final CdiEjbBean<?> bean) { if (!bean.getBeanContext().isLocalbean()) { for (final Method m : bean.getBeanContext().getBeanClass().getMethods()) { if (m.getDeclaringClass().equals(Object.class)) { continue; } if (m.getParameterTypes().length > 0) { for (final Annotation[] a : m.getParameterAnnotations()) { for (final Annotation ann : a) { if (ann.annotationType().equals(Disposes.class) && doResolveViewMethod(bean, m) == null) { throw new WebBeansConfigurationException("@Disposes is forbidden on non business EJB methods"); } } } } } } }
private static void validateObserverMethods(final CdiEjbBean<?> bean, final Map<ObserverMethod<?>, AnnotatedMethod<?>> methods) { final BeanContext beanContext = bean.getBeanContext(); if (beanContext.isLocalbean()) { return; } for (final Map.Entry<ObserverMethod<?>, AnnotatedMethod<?>> m : methods.entrySet()) { final Method method = m.getValue().getJavaMember(); if (!Modifier.isStatic(method.getModifiers()) && doResolveViewMethod(bean, method) == null) { throw new WebBeansConfigurationException("@Observes " + method + " neither in the ejb view of ejb " + bean.getBeanContext().getEjbName() + " nor static"); } } }
private static void validateObserverMethods(final CdiEjbBean<?> bean, final Map<ObserverMethod<?>, AnnotatedMethod<?>> methods) { final BeanContext beanContext = bean.getBeanContext(); if (beanContext.isLocalbean()) { return; } for (final Map.Entry<ObserverMethod<?>, AnnotatedMethod<?>> m : methods.entrySet()) { final Method method = m.getValue().getJavaMember(); if (!Modifier.isStatic(method.getModifiers()) && doResolveViewMethod(bean, method) == null) { throw new WebBeansConfigurationException("@Observes " + method + " neither in the ejb view of ejb " + bean.getBeanContext().getEjbName() + " nor static"); } } }
public static Method doResolveViewMethod(final Bean<?> component, final Method declaredMethod) { if (!(component instanceof CdiEjbBean)) { return declaredMethod; } final CdiEjbBean cdiEjbBean = (CdiEjbBean) component; final BeanContext beanContext = cdiEjbBean.getBeanContext(); for (final Class intface : beanContext.getBusinessLocalInterfaces()) { try { return intface.getMethod(declaredMethod.getName(), declaredMethod.getParameterTypes()); } catch (final NoSuchMethodException ignore) { // no-op } } for (final Class intface : beanContext.getBusinessRemoteInterfaces()) { try { return intface.getMethod(declaredMethod.getName(), declaredMethod.getParameterTypes()); } catch (final NoSuchMethodException ignore) { // no-op } } return null; }
private static void validateScope(final CdiEjbBean<?> bean) { final Class<? extends Annotation> scope = bean.getScope(); final BeanType beanType = bean.getBeanContext().getComponentType(); if (BeanType.STATELESS.equals(beanType) && !Dependent.class.equals(scope)) { throw new WebBeansConfigurationException("@Stateless can only be @Dependent"); } if (BeanType.SINGLETON.equals(beanType) && !Dependent.class.equals(scope) && !ApplicationScoped.class.equals(scope)) { throw new WebBeansConfigurationException("@Singleton can only be @Dependent or @ApplicationScoped"); } }
private static void validateScope(final CdiEjbBean<?> bean) { final Class<? extends Annotation> scope = bean.getScope(); final BeanType beanType = bean.getBeanContext().getComponentType(); if (BeanType.STATELESS.equals(beanType) && !Dependent.class.equals(scope)) { throw new WebBeansConfigurationException("@Stateless can only be @Dependent"); } if (BeanType.SINGLETON.equals(beanType) && !Dependent.class.equals(scope) && !ApplicationScoped.class.equals(scope)) { throw new WebBeansConfigurationException("@Singleton can only be @Dependent or @ApplicationScoped"); } }
@Override public void defineInterceptorStack(final Bean<T> bean, final AnnotatedType<T> annotatedType, final WebBeansContext webBeansContext) { super.defineInterceptorStack(bean, isDynamicBean(bean) ? (AnnotatedType<T>) webBeansContext.getAnnotatedElementFactory() .newAnnotatedType(CdiEjbBean.class.cast(bean).getBeanContext().getManagedClass()) : annotatedType, webBeansContext); }
public NewCdiEjbBean(final CdiEjbBean<T> that) { super(that.getBeanContext(), that.getWebBeansContext(), that.getBeanContext().getManagedClass(), that.getAnnotatedType(), new NewEjbInjectionTargetFactory<T>(that.getAnnotatedType(), that.getWebBeansContext(), that.getInjectionTarget())); this.id = that.getId() + "NewBean"; initInternals(); }
private static void validateProduceMethods(final CdiEjbBean<?> bean, final Set<ProducerMethodBean<?>> methods) { final BeanContext beanContext = bean.getBeanContext(); if (beanContext.isLocalbean()) { return; } for (final ProducerMethodBean<?> m : methods) { final Method method = m.getCreatorMethod(); if (doResolveViewMethod(bean, method) == null) { throw new WebBeansConfigurationException("@Produces " + method + " not in the ejb view of ejb " + beanContext.getEjbName()); } } }
private static void validateProduceMethods(final CdiEjbBean<?> bean, final Set<ProducerMethodBean<?>> methods) { final BeanContext beanContext = bean.getBeanContext(); if (beanContext.isLocalbean()) { return; } for (final ProducerMethodBean<?> m : methods) { final Method method = m.getCreatorMethod(); if (doResolveViewMethod(bean, method) == null) { throw new WebBeansConfigurationException("@Produces " + method + " not in the ejb view of ejb " + beanContext.getEjbName()); } } }
public NewCdiEjbBean(final CdiEjbBean<T> that) { super(that.getBeanContext(), that.getWebBeansContext(), that.getBeanContext().getManagedClass(), that.getAnnotatedType(), new NewEjbInjectionTargetFactory<T>(that.getAnnotatedType(), that.getWebBeansContext(), that.getInjectionTarget()), new BeanAttributesImpl<T>(that)); this.id = that.getId() + "NewBean"; initInternals(); }
final BeanContext beanContext = cdiEjbBean.getBeanContext(); final Provider provider = webBeansContext.getNormalScopeProxyFactory().getInstanceProvider(beanContext.getClassLoader(), cdiEjbBean);
final BeanContext beanContext = cdiEjbBean.getBeanContext(); final Provider provider = webBeansContext.getNormalScopeProxyFactory().getInstanceProvider(beanContext.getClassLoader(), cdiEjbBean);
isDependentAndStateful = isDependent && stateful; if (webBeansContext.getBeanManagerImpl().isPassivatingScope(getScope()) && stateful) { if (!getBeanContext().isPassivable()) { throw new DefinitionException( getBeanContext().getBeanClass() + " is a not apssivation-capable @Stateful with a scope " + getScope().getSimpleName() + " which need passivation");
final Class<?> proxyClass = Class.class.cast(Reflections.get(cdiEjbBean.getInjectionTarget(), "proxyClass")); if (proxyClass != null) { // means interception final InterceptorResolutionService.BeanInterceptorInfo interceptorInfo = cdiEjbBean.getBeanContext().get(InterceptorResolutionService.BeanInterceptorInfo.class); if (interceptorInfo.getDecorators() != null && !interceptorInfo.getDecorators().isEmpty()) { final InterceptorDecoratorProxyFactory pf = webBeansContext.getInterceptorDecoratorProxyFactory();
final Class<?> proxyClass = Class.class.cast(Reflections.get(cdiEjbBean.getInjectionTarget(), "proxyClass")); if (proxyClass != null) { // means interception final InterceptorResolutionService.BeanInterceptorInfo interceptorInfo = cdiEjbBean.getBeanContext().get(InterceptorResolutionService.BeanInterceptorInfo.class); if (interceptorInfo.getDecorators() != null && !interceptorInfo.getDecorators().isEmpty()) { final InterceptorDecoratorProxyFactory pf = webBeansContext.getInterceptorDecoratorProxyFactory();