No, proxies/subclasses should not be used for non-CDI interceptors. This
depends on which InjectionTarget you use to produce the instances. There
is a special method on InjectionTargetFactory that should be used to
create InjectionTargets for non-CDI interceptors
This special treatment is needed as otherwise the InjectionTarget would
create a standard component instance (possibly intercepted), not
intercepting.
On 05/27/2015 10:43 AM, Emily Jiang wrote:
Will the injectionTarget.produce() produces a Weld proxy for the
non-CDI interceptors then? It seems ejb tck complains about the
proxied non-CDI interceptors. I looked at the cdi interceptors and I
think the instances are real objects not a proxy.
What I meant of "correct constructor with the resolved arguments" is
that I directly call into the correct non-CDI interceptors and get a
real object instead of a proxy.
On Wed, May 27, 2015 at 9:00 AM, Jozef Hartinger <jharting(a)redhat.com
<mailto:jharting@redhat.com>> wrote:
You can use InjectionTarget.produce() to create instances of
non-CDI interceptors as well. The implementation will call the
@Inject constructor passing in the dependencies or call the no-arg
constructor. What "correct constructor with the resolved
arguments" did you mean?
Jozef
On 05/27/2015 01:04 AM, Emily Jiang wrote:
> Thank you Jozef for your help with clarifying this!
>
> By the way, for non-CDI interceptors, though EE7 spec lists these
> interceptors under the category of JavaEE component classes, I
> guess they are different from other other JavaEE component
> classes. For these interceptor instance creation, I guess we
> should not use injectiontarget.produce(). Am I right to say that
> we need to call into the correct constructor with the resolved
> arguments?
>
> On Thu, May 21, 2015 at 1:25 PM, Jozef Hartinger
> <jharting(a)redhat.com <mailto:jharting@redhat.com>> wrote:
>
> On 05/13/2015 12:35 AM, Emily Jiang wrote:
>> A further question on EJB injection,
>>
>> In the Weld reference doc, performing injection on JavaEE
>> component class:
>> To help the integrator, Weld provides
>> WeldManager.fireProcessInjectionTarget() which returns the
>> InjectionTarget to use.
>>
>> The statement was not mentioned when it talks about
>> performing injection on EJBs. My question is that do we need
>> to call the above method to fire the event.
> No, you only need to call this for non-contextual components.
> For session beans this is done by Weld automatically.
>>
>> Another observation with the code snippet on EJB section. It
>> did not mention how the instance was created. I think
>> 'it.produce()' needs to be there before the it.inject().
>>
>> // Obtain the EjbDescriptor for the EJB
>> // You may choose to use this utility method to get the
>> descriptor
>> EjbDescriptor<?> ejbDescriptor =
>> beanManager.getEjbDescriptor(ejbName);
>> // Get an the Bean object
>> Bean<?> bean = beanManager.getBean(ejbDescriptor);
>> // Create the injection target
>> InjectionTarget it =
>> deploymentBeanManager.createInjectionTarget(ejbDescriptor);
>> // Per instance required, create the creational context
>> CreationalContext<?> cc =
>> deploymentBeanManager.createCreationalContext(bean);
>>
>> *.... missing the line... Object instance = it.produce()*
>> // Perform injection and call initializers
>> it.inject(instance, cc);
> Yes, looks like the line is missing.
>
>>
>> Thanks
>> Emily
>>
>>
>>
>> On Fri, May 8, 2015 at 11:29 AM, Emily Jiang
>> <emijiang6(a)googlemail.com <mailto:emijiang6@googlemail.com>>
>> wrote:
>>
>> Thank you Jozef for your helpful response! I have
>> another clarification on the interceptors on JavaEE
>> component classes.
>>
>> EE7 spec states the JavaEE component classes, listed in
>> Table EE.5-1, need to support interceptors. Take servlet
>> for an example, which methods can be intercepted?
>>
>> As the servlet classes are invoked by the container,
>> according to CDI1.2 spec, it seems only
>> service(ServletRequest, ServletResponse) can be
>> intercepted. No other methods can be intercepted.
>>
>> Normally customer applications override doPost or doGet,
>> but they cannot be intercepted. I cannot see any value
>> of support interceptors on Servlet. Anything I missed?
>> Thanks
>> Emily
>>
>> On Thu, May 7, 2015 at 8:22 AM, Jozef Hartinger
>> <jharting(a)redhat.com <mailto:jharting@redhat.com>>
wrote:
>>
>> Hi Emily, comments inline.
>>
>> On 05/06/2015 05:38 PM, Emily Jiang wrote:
>>> I have a few questions on ejb integration on Weld.
>>>
>>> 1)Does Weld handle the instance creation for ejb
>>> (using injectionTarget.produce) or delegate the
>>> instance creation to EJB container? I guess Weld
>>> will create the instead as it can manage
>>> decorators. If not, how can decorators be managed?
>>> Please confirm.
>> Correct. Weld creates EJB instances using
>> InjectionTarget.produce()
>>>
>>> 2) When Weld creates the EJB instance, how can the
>>> other non-CDI aroundconstruct interceptors (such as
>>> the interceptors defined via ejb-jar.xml or
>>> @Interceptors) be passed in? I found out the
>>> WeldCreationContext and AroundConstructCallback but
>>> I cannot find anything mentioned in the weld
>>> reference doc. Is this the right plugin point?
>> Correct, AroundConstructCallback is the API you need
>> to use. The JavaDoc should be helpful. Let me know
>> if anything is not clear. I'll add a note about it
>> to the refdoc.
>>>
>>> 3)If Weld creates the EJB instance, how can all
>>> interceptors (cdi style and ejb style) be invoked?
>>> Will the instance need to be passed back to EJB
>>> container together with all CDI interceptors (get
>>> hold of them via EjbEndpointServiceImpl.java) and
>>> EJB container needs to manage the interceptors
>>> being invoked?
>> For interception type other than @AroundConstruct we
>> leave it up to the EJB implementation to handle
>> interception. Information about CDI interceptors is
>> exposed to the EJB implementation via
>> EjbServices.registerInterceptors()
>>>
>>> 4)In Weld spec, it says you must register the
>>> SessionBeanInterceptor as the inner most
>>> interceptor in the stack for all EJBS. Can you
>>> clarify what inner most means? Does this
>>> interceptor need to be the first EJB interceptor to
>>> be called or the last EJB interceptor to be invoked?
>> Not sure why it says inner most - it should be outer
>> most instead that is it should be called as first so
>> that the @RequestScope is available for the other
>> interceptors called later in the chain.
>>>
>>>
>>> --
>>> Thanks
>>> Emily
>>> =================
>>> Emily Jiang
>>> ejiang(a)apache.org <mailto:ejiang@apache.org>
>>>
>>>
>>> _______________________________________________
>>> weld-dev mailing list
>>> weld-dev(a)lists.jboss.org
<mailto:weld-dev@lists.jboss.org>
>>>
https://lists.jboss.org/mailman/listinfo/weld-dev
>>
>>
>>
>>
>> --
>> Thanks
>> Emily
>> =================
>> Emily Jiang
>> ejiang(a)apache.org <mailto:ejiang@apache.org>
>>
>>
>>
>>
>> --
>> Thanks
>> Emily
>> =================
>> Emily Jiang
>> ejiang(a)apache.org <mailto:ejiang@apache.org>
>
>
>
>
> --
> Thanks
> Emily
> =================
> Emily Jiang
> ejiang(a)apache.org <mailto:ejiang@apache.org>
--
Thanks
Emily
=================
Emily Jiang
ejiang(a)apache.org <mailto:ejiang@apache.org>