<div dir="ltr"><div><div>Thank you Jozef for your quick reply! <br><br>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). <br><br>After further debugging, below is the calling stack for creating non-cdi interceptors<br><br>
<table></table>BasicInjectionTarget<T>.createNonCdiInterceptor(EnhancedAnnotatedType<T>, BeanManagerImpl) line: 69        <br>InjectionTargetFactoryImpl<T>.chooseInjectionTarget(EnhancedAnnotatedType<T>, Bean<T>, boolean) line: 126        <br>InjectionTargetFactoryImpl<T>.createInjectionTarget(EnhancedAnnotatedType<T>, Bean<T>, boolean) line: 87        <br>InjectionTargetFactoryImpl<T>.createInjectionTarget(Bean<T>, boolean) line: 80        <br>InjectionTargetFactoryImpl<T>.createInterceptorInjectionTarget() line: 75        <br>PlainInterceptorFactory<T>.of(Class<T>, BeanManagerImpl) line: 41        <br>InterceptorMetadataReader$1.load(Class<?>) line: 44        <br>InterceptorMetadataReader$1.load(Object) line: 39        <br>LocalCache$LoadingValueReference<K,V>.loadFuture(K, CacheLoader<? super K,V>) line: 3599        <br>LocalCache$Segment<K,V>.loadSync(K, int, LoadingValueReference<K,V>, CacheLoader<? super K,V>) line: 2379        <br>LocalCache$Segment<K,V>.lockedGetOrLoad(K, int, CacheLoader<? super K,V>) line: 2342        <br>LocalCache$Segment<K,V>.get(K, int, CacheLoader<? super K,V>) line: 2257        <br>LocalCache<K,V>.get(K, CacheLoader<? super K,V>) line: 4000        <br>LocalCache<K,V>.getOrLoad(K) line: 4004        <br>LocalCache$LocalLoadingCache<K,V>.get(K) line: 4874        <br>LoadingCacheUtils.getCacheValue(LoadingCache<K,V>, K) line: 49        <br>LoadingCacheUtils.getCastCacheValue(LoadingCache<K,V>, Object) line: 74        <br>InterceptorMetadataReader.getPlainInterceptorMetadata(Class<T>) line: 64        <br>InterceptionModelInitializer<T>.initClassDeclaredEjbInterceptors() line: 233        <br>InterceptionModelInitializer<T>.initEjbInterceptors() line: 217        <br>InterceptionModelInitializer<T>.init() line: 103        <br>BeanInjectionTarget<T>.buildInterceptionModel(EnhancedAnnotatedType<T>, AbstractInstantiator<T>) line: 93        <br>BeanInjectionTarget<T>.initializeInterceptionModel(EnhancedAnnotatedType<T>) line: 88        <br>BeanInjectionTarget<T>.initializeAfterBeanDiscovery(EnhancedAnnotatedType<T>) line: 98        <br>InjectionTargetInitializationContext<T>.initialize() line: 42        <br>InjectionTargetService.addInjectionTargetToBeInitialized(InjectionTargetInitializationContext<?>) line: 55        <br>InjectionTargetService.addInjectionTargetToBeInitialized(EnhancedAnnotatedType<T>, BasicInjectionTarget<T>) line: 49        <br>InjectionTargetFactoryImpl<T>.initialize(BasicInjectionTarget<T>) line: 145        <br>InjectionTargetFactoryImpl<T>.createInjectionTarget(EnhancedAnnotatedType<T>, Bean<T>, boolean) line: 92        <br>InjectionTargetFactoryImpl<T>.createInjectionTarget(Bean<T>, boolean) line: 80        <br>InjectionTargetFactoryImpl<T>.createInjectionTarget(Bean<T>) line: 70        <br>InjectionTargetFactoryImpl<T>.createInjectionTarget(Bean) line: 54        
<br><br></div>This following line on BasicInjectionTarget uses the DefaultInjector, which does not support resource injection.<br>
<table>
</table><span class="" style="font-size:10pt;font-family:Liberation Sans;color:rgb(26,26,26)"> return new BasicInjectionTarget<T>(type, null, beanManager, DefaultInjector.of(type, null, beanManager), NoopLifecycleCallbackInvoker.<T>getInstance());</span>
<br><br></div>I might have missed your point. Please elaborate a bit more.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 3, 2015 at 6:49 AM, Jozef Hartinger <span dir="ltr"><<a href="mailto:jharting@redhat.com" target="_blank">jharting@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
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:<br>
<br>
beanManager.createInjectionTargetBuilder(type)<br>
.setDecorationEnabled(false)<br>
.setInterceptionEnabled(false)<br>
.setTargetClassLifecycleCallbacksEnabled(false)<br>
.setResourceInjectionEnabled(true)<br>
.build()<div><div class="h5"><br>
<br>
<div>On 06/02/2015 06:15 PM, Emily Jiang
wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<div dir="ltr">
<div>
<div>
<div><br clear="all">
</div>
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.<br>
<br>
</div>
Is there anything I have missed or this is a bug?<br>
</div>
<div>
<div>
<div>-- <br>
<div>Thanks<br>
Emily<br>
=================<br>
Emily Jiang<br>
<a href="mailto:ejiang@apache.org" target="_blank">ejiang@apache.org</a><br>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><pre>_______________________________________________
weld-dev mailing list
<a href="mailto:weld-dev@lists.jboss.org" target="_blank">weld-dev@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/weld-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/weld-dev</a></pre>
</blockquote>
<br>
</div>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Thanks<br>Emily<br>=================<br>Emily Jiang<br><a href="mailto:ejiang@apache.org" target="_blank">ejiang@apache.org</a><br></div>
</div>