protected <X> void createObserverMethods(AbstractClassBean<X> declaringBean, EnhancedAnnotatedType<? super X> annotatedClass) { for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.getObserverMethods(annotatedClass)) { createObserverMethod(declaringBean, method, false); } for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.getAsyncObserverMethods(annotatedClass)) { createObserverMethod(declaringBean, method, true); } }
protected <X> void createProducerMethods(AbstractClassBean<X> declaringBean, EnhancedAnnotatedType<X> type) { for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.filterMethods(type.getDeclaredEnhancedMethods(Produces.class))) { // create method for now // specialization and PBA processing is handled later createProducerMethod(declaringBean, method); } }
public static <T> List<AnnotatedMethod<? super T>> getPostConstructMethods(final EnhancedAnnotatedType<T> type) { return getMethods(type, new AbstractLifecycleEventCallbackMethodListBuilder<T>() { @Override public Collection<EnhancedAnnotatedMethod<?, ? super T>> getAllMethods(EnhancedAnnotatedType<T> type) { return type.getEnhancedMethods(PostConstruct.class); } @Override protected void duplicateMethod(EnhancedAnnotatedMethod<?, ? super T> method) { throw UtilLogger.LOG.tooManyPostConstructMethods(type); } @Override protected EnhancedAnnotatedMethod<?, ? super T> processLevelResult(EnhancedAnnotatedMethod<?, ? super T> method) { BeanLogger.LOG.foundOnePostConstructMethod(method, type); return method; } }); }
protected void validateDecorator(Decorator<?> decorator, Collection<CommonBean<?>> specializedBeans, BeanManagerImpl manager) { throw ValidatorLogger.LOG.noDecoratedTypes(decorator); throw ValidatorLogger.LOG.interceptorOrDecoratorMustBeDependent(decorator); if (!Decorators.isPassivationCapable(decorator)) { if (Instance.class.equals(parameterizedDelegateType.getRawType()) || Provider.class.equals(parameterizedDelegateType.getRawType())) { throw ValidatorLogger.LOG.builtinBeanWithNonserializableDecorator(decorator, Instance.class.getName()); validateRIBean((CommonBean<?>) decorator, manager, specializedBeans); if (!BeanMethods.getObserverMethods(annotated).isEmpty() || !BeanMethods.getAsyncObserverMethods(annotated).isEmpty()) { throw ValidatorLogger.LOG.decoratorsCannotHaveObserverMethods(decorator); while (annotated != null && annotated.getJavaClass() != Object.class) { if (!annotated.getDeclaredEnhancedMethods(Produces.class).isEmpty()) { throw ValidatorLogger.LOG.decoratorsCannotHaveProducerMethods(decorator); if (!annotated.getDeclaredEnhancedFields(Produces.class).isEmpty()) { throw ValidatorLogger.LOG.decoratorsCannotHaveProducerFields(decorator); validateGeneralBean(decorator, manager); Decorators.findDelegateInjectionPoint(annotated, decorator.getInjectionPoints());
protected void validateInterceptor(Interceptor<?> interceptor, BeanManagerImpl manager) { if (interceptor instanceof InterceptorImpl<?>) { EnhancedAnnotatedType<?> annotated = ((InterceptorImpl<?>) interceptor).getEnhancedAnnotated(); if (!BeanMethods.getObserverMethods(annotated).isEmpty() || !BeanMethods.getAsyncObserverMethods(annotated).isEmpty()) { throw ValidatorLogger.LOG.interceptorsCannotHaveObserverMethods(interceptor); } if (!interceptor.getScope().equals(Dependent.class)) { throw ValidatorLogger.LOG.interceptorOrDecoratorMustBeDependent(interceptor); } while (annotated != null && annotated.getJavaClass() != Object.class) { if (!annotated.getDeclaredEnhancedMethods(Produces.class).isEmpty()) { throw ValidatorLogger.LOG.interceptorsCannotHaveProducerMethods(interceptor); } if (!annotated.getDeclaredEnhancedFields(Produces.class).isEmpty()) { throw ValidatorLogger.LOG.interceptorsCannotHaveProducerFields(interceptor); } if (!annotated.getDeclaredEnhancedMethodsWithAnnotatedParameters(Disposes.class).isEmpty()) { throw ValidatorLogger.LOG.interceptorsCannotHaveDisposerMethods(interceptor); } annotated = annotated.getEnhancedSuperclass(); } } for (InjectionPoint injectionPoint : interceptor.getInjectionPoints()) { validateInjectionPoint(injectionPoint, manager); } }
protected <X> void createDisposalMethods(AbstractClassBean<X> declaringBean, EnhancedAnnotatedType<X> annotatedClass) { for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.filterMethods(annotatedClass .getDeclaredEnhancedMethodsWithAnnotatedParameters(Disposes.class))) { DisposalMethod<? super X, ?> disposalBean = DisposalMethod.of(manager, method, declaringBean); getEnvironment().addDisposesMethod(disposalBean); } }
public static <T> Collection<EnhancedAnnotatedMethod<?, ? super T>> getAsyncObserverMethods(final EnhancedAnnotatedType<T> type) { return filterMethods(type.getEnhancedMethodsWithAnnotatedParameters(ObservesAsync.class)); }
/** * Get all methods of a given kind using a given {@link MethodListBuilder}. */ private static <T, R> R getMethods(EnhancedAnnotatedType<T> type, MethodListBuilder<T, R> builder) { Collection<EnhancedAnnotatedMethod<?, ? super T>> methods = filterMethods(builder.getAllMethods(type)); for (Class<? super T> clazz = type.getJavaClass(); clazz != null && clazz != Object.class; clazz = clazz.getSuperclass()) { builder.levelStart(clazz); for (EnhancedAnnotatedMethod<?, ? super T> method : methods) { if (method.getJavaMember().getDeclaringClass().equals(clazz)) { builder.processMethod(method); } } builder.levelFinish(); } return builder.create(); }
protected <X> void createObserverMethods(RIBean<X> declaringBean, BeanManagerImpl beanManager, EnhancedAnnotatedType<? super X> annotatedClass, Set<ObserverInitializationContext<?, ?>> observerMethodInitializers) { for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.getObserverMethods(annotatedClass)) { createObserverMethod(declaringBean, beanManager, method, observerMethodInitializers, false); } for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.getAsyncObserverMethods(annotatedClass)) { createObserverMethod(declaringBean, beanManager, method, observerMethodInitializers, true); } }
public DefaultLifecycleCallbackInvoker(EnhancedAnnotatedType<T> type) { this.accessiblePostConstructMethods = initMethodList(BeanMethods.getPostConstructMethods(type)); this.accessiblePreDestroyMethods = initMethodList(BeanMethods.getPreDestroyMethods(type)); }
protected <X> void createObserverMethods(AbstractClassBean<X> declaringBean, EnhancedAnnotatedType<? super X> annotatedClass) { for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.getObserverMethods(annotatedClass)) { createObserverMethod(declaringBean, method); } }
public DefaultInjector(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanManagerImpl beanManager) { this.injectableFields = InjectionPointFactory.instance().getFieldInjectionPoints(bean, type, beanManager); this.initializerMethods = BeanMethods.getInitializerMethods(bean, type, beanManager); }
public static Map<InterceptionType, List<Method>> buildMethodMap(EnhancedAnnotatedType<?> type, boolean forTargetClass, BeanManagerImpl manager) { ImmutableMap.Builder<InterceptionType, List<Method>> builder = null; for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes()) { List<Method> value = BeanMethods.getInterceptorMethods(type, interceptionType, forTargetClass); if (!value.isEmpty()) { if (builder == null) { builder = ImmutableMap.builder(); } builder.put(interceptionType, value); } } if (builder == null) { return Collections.emptyMap(); } return builder.build(); } }
protected <X> void createObserverMethods(RIBean<X> declaringBean, BeanManagerImpl beanManager, EnhancedAnnotatedType<? super X> annotatedClass, Set<ObserverInitializationContext<?, ?>> observerMethodInitializers) { for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.getObserverMethods(annotatedClass)) { createObserverMethod(declaringBean, beanManager, method, observerMethodInitializers); } }
protected void validateDecorator(Decorator<?> decorator, Collection<CommonBean<?>> specializedBeans, BeanManagerImpl manager) { throw ValidatorLogger.LOG.noDecoratedTypes(decorator); throw ValidatorLogger.LOG.interceptorOrDecoratorMustBeDependent(decorator); if (!Decorators.isPassivationCapable(decorator)) { if (Instance.class.equals(parameterizedDelegateType.getRawType()) || Provider.class.equals(parameterizedDelegateType.getRawType())) { throw ValidatorLogger.LOG.builtinBeanWithNonserializableDecorator(decorator, Instance.class.getName()); validateRIBean((CommonBean<?>) decorator, manager, specializedBeans); if (!BeanMethods.getObserverMethods(annotated).isEmpty() || !BeanMethods.getAsyncObserverMethods(annotated).isEmpty()) { throw ValidatorLogger.LOG.decoratorsCannotHaveObserverMethods(decorator); while (annotated != null && annotated.getJavaClass() != Object.class) { if (!annotated.getDeclaredEnhancedMethods(Produces.class).isEmpty()) { throw ValidatorLogger.LOG.decoratorsCannotHaveProducerMethods(decorator); if (!annotated.getDeclaredEnhancedFields(Produces.class).isEmpty()) { throw ValidatorLogger.LOG.decoratorsCannotHaveProducerFields(decorator); validateGeneralBean(decorator, manager); Decorators.findDelegateInjectionPoint(annotated, decorator.getInjectionPoints());
protected void validateInterceptor(Interceptor<?> interceptor, BeanManagerImpl manager) { if (interceptor instanceof InterceptorImpl<?>) { EnhancedAnnotatedType<?> annotated = ((InterceptorImpl<?>) interceptor).getEnhancedAnnotated(); if (!BeanMethods.getObserverMethods(annotated).isEmpty() || !BeanMethods.getAsyncObserverMethods(annotated).isEmpty()) { throw ValidatorLogger.LOG.interceptorsCannotHaveObserverMethods(interceptor); } if (!interceptor.getScope().equals(Dependent.class)) { throw ValidatorLogger.LOG.interceptorOrDecoratorMustBeDependent(interceptor); } while (annotated != null && annotated.getJavaClass() != Object.class) { if (!annotated.getDeclaredEnhancedMethods(Produces.class).isEmpty()) { throw ValidatorLogger.LOG.interceptorsCannotHaveProducerMethods(interceptor); } if (!annotated.getDeclaredEnhancedFields(Produces.class).isEmpty()) { throw ValidatorLogger.LOG.interceptorsCannotHaveProducerFields(interceptor); } if (!annotated.getDeclaredEnhancedMethodsWithAnnotatedParameters(Disposes.class).isEmpty()) { throw ValidatorLogger.LOG.interceptorsCannotHaveDisposerMethods(interceptor); } annotated = annotated.getEnhancedSuperclass(); } } for (InjectionPoint injectionPoint : interceptor.getInjectionPoints()) { validateInjectionPoint(injectionPoint, manager); } }
protected <X> void createDisposalMethods(AbstractClassBean<X> declaringBean, EnhancedAnnotatedType<X> annotatedClass) { for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.filterMethods(annotatedClass .getDeclaredEnhancedMethodsWithAnnotatedParameters(Disposes.class))) { DisposalMethod<? super X, ?> disposalBean = DisposalMethod.of(manager, method, declaringBean); getEnvironment().addDisposesMethod(disposalBean); } }
public static <T> Collection<EnhancedAnnotatedMethod<?, ? super T>> getObserverMethods(final EnhancedAnnotatedType<T> type) { return filterMethods(type.getEnhancedMethodsWithAnnotatedParameters(Observes.class)); }
/** * Get all methods of a given kind using a given {@link MethodListBuilder}. */ private static <T, R> R getMethods(EnhancedAnnotatedType<T> type, MethodListBuilder<T, R> builder) { Collection<EnhancedAnnotatedMethod<?, ? super T>> methods = filterMethods(builder.getAllMethods(type)); for (Class<? super T> clazz = type.getJavaClass(); clazz != null && clazz != Object.class; clazz = clazz.getSuperclass()) { builder.levelStart(clazz); for (EnhancedAnnotatedMethod<?, ? super T> method : methods) { if (method.getJavaMember().getDeclaringClass().equals(clazz)) { builder.processMethod(method); } } builder.levelFinish(); } return builder.create(); }
protected <X> void createObserverMethods(RIBean<X> declaringBean, BeanManagerImpl beanManager, EnhancedAnnotatedType<? super X> annotatedClass, Set<ObserverInitializationContext<?, ?>> observerMethodInitializers) { for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.getObserverMethods(annotatedClass)) { createObserverMethod(declaringBean, beanManager, method, observerMethodInitializers, false); } for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.getAsyncObserverMethods(annotatedClass)) { createObserverMethod(declaringBean, beanManager, method, observerMethodInitializers, true); } }