Thank you Jozef for your quick reply!
The point is that Weld creates the non-cdi interceptors, so we don't have
control over. We can only control how to create the managed beans, which I
think the defult setting for the injectionTarget are correct (interceptor,
decorator, lifecycle call and resource injection enabled).
After further debugging, below is the calling stack for creating non-cdi
interceptors
BasicInjectionTarget<T>.createNonCdiInterceptor(EnhancedAnnotatedType<T>,
BeanManagerImpl) line: 69
InjectionTargetFactoryImpl<T>.chooseInjectionTarget(EnhancedAnnotatedType<T>,
Bean<T>, boolean) line: 126
InjectionTargetFactoryImpl<T>.createInjectionTarget(EnhancedAnnotatedType<T>,
Bean<T>, boolean) line: 87
InjectionTargetFactoryImpl<T>.createInjectionTarget(Bean<T>, boolean) line:
80
InjectionTargetFactoryImpl<T>.createInterceptorInjectionTarget() line: 75
PlainInterceptorFactory<T>.of(Class<T>, BeanManagerImpl) line: 41
InterceptorMetadataReader$1.load(Class<?>) line: 44
InterceptorMetadataReader$1.load(Object) line: 39
LocalCache$LoadingValueReference<K,V>.loadFuture(K, CacheLoader<? super
K,V>) line: 3599
LocalCache$Segment<K,V>.loadSync(K, int, LoadingValueReference<K,V>,
CacheLoader<? super K,V>) line: 2379
LocalCache$Segment<K,V>.lockedGetOrLoad(K, int, CacheLoader<? super K,V>)
line: 2342
LocalCache$Segment<K,V>.get(K, int, CacheLoader<? super K,V>) line: 2257
LocalCache<K,V>.get(K, CacheLoader<? super K,V>) line: 4000
LocalCache<K,V>.getOrLoad(K) line: 4004
LocalCache$LocalLoadingCache<K,V>.get(K) line: 4874
LoadingCacheUtils.getCacheValue(LoadingCache<K,V>, K) line: 49
LoadingCacheUtils.getCastCacheValue(LoadingCache<K,V>, Object) line: 74
InterceptorMetadataReader.getPlainInterceptorMetadata(Class<T>) line: 64
InterceptionModelInitializer<T>.initClassDeclaredEjbInterceptors() line:
233
InterceptionModelInitializer<T>.initEjbInterceptors() line: 217
InterceptionModelInitializer<T>.init() line: 103
BeanInjectionTarget<T>.buildInterceptionModel(EnhancedAnnotatedType<T>,
AbstractInstantiator<T>) line: 93
BeanInjectionTarget<T>.initializeInterceptionModel(EnhancedAnnotatedType<T>)
line: 88
BeanInjectionTarget<T>.initializeAfterBeanDiscovery(EnhancedAnnotatedType<T>)
line: 98
InjectionTargetInitializationContext<T>.initialize() line: 42
InjectionTargetService.addInjectionTargetToBeInitialized(InjectionTargetInitializationContext<?>)
line: 55
InjectionTargetService.addInjectionTargetToBeInitialized(EnhancedAnnotatedType<T>,
BasicInjectionTarget<T>) line: 49
InjectionTargetFactoryImpl<T>.initialize(BasicInjectionTarget<T>) line: 145
InjectionTargetFactoryImpl<T>.createInjectionTarget(EnhancedAnnotatedType<T>,
Bean<T>, boolean) line: 92
InjectionTargetFactoryImpl<T>.createInjectionTarget(Bean<T>, boolean) line:
80
InjectionTargetFactoryImpl<T>.createInjectionTarget(Bean<T>) line: 70
InjectionTargetFactoryImpl<T>.createInjectionTarget(Bean) line: 54
This following line on BasicInjectionTarget uses the DefaultInjector, which
does not support resource injection.
return new BasicInjectionTarget<T>(type, null, beanManager,
DefaultInjector.of(type, null, beanManager),
NoopLifecycleCallbackInvoker.<T>getInstance());
I might have missed your point. Please elaborate a bit more.
On Wed, Jun 3, 2015 at 6:49 AM, Jozef Hartinger <jharting(a)redhat.com> wrote:
That's expected. The non-cdi interceptors are expected to be
partially
managed by the EE container (resource injection). If you need resource
injection in the non-CDI interceptors you can use InjectionTargetBuilder to
customize this behavior, e.g:
beanManager.createInjectionTargetBuilder(type)
.setDecorationEnabled(false)
.setInterceptionEnabled(false)
.setTargetClassLifecycleCallbacksEnabled(false)
.setResourceInjectionEnabled(true)
.build()
On 06/02/2015 06:15 PM, Emily Jiang wrote:
For managed beans (@ManagedBean classes), they are java EE component
classes. They support both cdi and non-cdi interceptors. When I create a
instance using injectionTarget.produce(), I got hold of the instance with
both cdi and non-cdi interceptors associated. However, the @Resource
injection point on the non-cdi interceptors are not injected when Weld
creates the interceptor instances.
Is there anything I have missed or this is a bug?
--
Thanks
Emily
=================
Emily Jiang
ejiang(a)apache.org
_______________________________________________
weld-dev mailing
listweld-dev@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/weld-dev
--
Thanks
Emily
=================
Emily Jiang
ejiang(a)apache.org