Hi Emily,
thanks for your patience :-) You are right that this is a bug in Weld. I
filed https://issues.jboss.org/browse/WELD-1963 to track this issue.
Jozef
On 06/03/2015 03:41 PM, Emily Jiang wrote:
Hi Jozef,
The non-CDI interceptor was created by Weld when I called
injectionTarget.produce() on a ManagedBean class. I have no control of
it. Please see above for the stack. The stack shows the creation
sequence (managed bean creation -> non-cdi interceptor creation). I
used the following snippet to create injection Target for the ManagedBean.
Bean<T> bean = getBean(); // returns null for managed bean
with dependent scope
AnnotatedType<T> annotatedType =
beanManager.createAnnotatedType(clazz);
InjectionTargetFactory<T> itf=
beanManager.getInjectionTargetFactory(annotatedType);
injectionTarget = itf.createInjectionTarget(bean);
injectionTarget.produce(context); //produce an instance
with all non-cdi and cdi interceptors... but the non-cdi interceptors
without any ee injection
Thanks
Emily
On Wed, Jun 3, 2015 at 2:02 PM, Jozef Hartinger <[email protected]
<mailto:[email protected]>> wrote:
Oops, sorry. Ignore my last e-mail. How do you obtain the
InjectionTarget for the non-CDI interceptor?
On 06/03/2015 12:52 PM, Emily Jiang wrote:
Jozef,
The PlainInterceptorFactory is weld class. Here is the stack when
we created an instance for a managed bean class (@ManagedBean) by
calling injectionTarget.produce(); You are not asking me to
override PlainInterceptorFactory, right?
Caused by: java.lang.Exception
at
org.jboss.weld.injection.producer.BasicInjectionTarget.createNonCdiInterceptor(BasicInjectionTarget.java:69)
at
org.jboss.weld.manager.InjectionTargetFactoryImpl.chooseInjectionTarget(InjectionTargetFactoryImpl.java:126)
at
org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:87)
at
org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:80)
at
org.jboss.weld.manager.InjectionTargetFactoryImpl.createInterceptorInjectionTarget(InjectionTargetFactoryImpl.java:75)
at
org.jboss.weld.interceptor.reader.PlainInterceptorFactory.of(PlainInterceptorFactory.java:41)
at
org.jboss.weld.interceptor.reader.InterceptorMetadataReader$1.load(InterceptorMetadataReader.java:44)
at
org.jboss.weld.interceptor.reader.InterceptorMetadataReader$1.load(InterceptorMetadataReader.java:39)
at
com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3599)
at
com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2379)
at
com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2342)
at
com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2257)
at com.google.common.cache.LocalCache.get(LocalCache.java:4000)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4004)
at
com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4874)
at
org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:49)
at
org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValue(LoadingCacheUtils.java:74)
at
org.jboss.weld.interceptor.reader.InterceptorMetadataReader.getPlainInterceptorMetadata(InterceptorMetadataReader.java:64)
at
org.jboss.weld.injection.producer.InterceptionModelInitializer.initClassDeclaredEjbInterceptors(InterceptionModelInitializer.java:233)
at
org.jboss.weld.injection.producer.InterceptionModelInitializer.initEjbInterceptors(InterceptionModelInitializer.java:217)
at
org.jboss.weld.injection.producer.InterceptionModelInitializer.init(InterceptionModelInitializer.java:103)
at
org.jboss.weld.injection.producer.BeanInjectionTarget.buildInterceptionModel(BeanInjectionTarget.java:93)
at
org.jboss.weld.injection.producer.BeanInjectionTarget.initializeInterceptionModel(BeanInjectionTarget.java:88)
at
org.jboss.weld.injection.producer.BeanInjectionTarget.initializeAfterBeanDiscovery(BeanInjectionTarget.java:98)
at
org.jboss.weld.injection.producer.InjectionTargetInitializationContext.initialize(InjectionTargetInitializationContext.java:42)
at
org.jboss.weld.injection.producer.InjectionTargetService.addInjectionTargetToBeInitialized(InjectionTargetService.java:55)
at
org.jboss.weld.injection.producer.InjectionTargetService.addInjectionTargetToBeInitialized(InjectionTargetService.java:49)
at
org.jboss.weld.manager.InjectionTargetFactoryImpl.initialize(InjectionTargetFactoryImpl.java:145)
at
org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:92)
at
org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:80)
at
org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:70)
at
org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:54)
On Wed, Jun 3, 2015 at 10:50 AM, Jozef Hartinger
<[email protected] <mailto:[email protected]>> wrote:
What I meant was that your PlainInterceptorFactory should in
this case, instead of calling
createInterceptorInjectionTarget(), call
beanManager.createInjectionTargetBuilder(type)
.setDecorationEnabled(false)
.setInterceptionEnabled(false)
.setTargetClassLifecycleCallbacksEnabled(false)
.setResourceInjectionEnabled(true)
.build()
The InjectionTarget you get should be the same except for
resource injection which will be provided by Weld.
Jozef
On 06/03/2015 11:25 AM, Emily Jiang wrote:
I might have missed your point. Please elaborate a bit more.
--
Thanks
Emily
=================
Emily Jiang
[email protected] <mailto:[email protected]>
--
Thanks
Emily
=================
Emily Jiang
[email protected] <mailto:[email protected]>
_______________________________________________
weld-dev mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/weld-dev