[webbeans-dev] Re: Producer fields on EJBs

Pete Muir pmuir at redhat.com
Mon Apr 6 13:22:39 EDT 2009


On 6 Apr 2009, at 18:00, Kenneth Saks wrote:

>
> On Apr 6, 2009, at 12:31 PM, Pete Muir wrote:
>
>> Carlo, Ken, Andrew,
>>
>> JSR-299 supports the notion of a producer field. By adding the  
>> annotation @Produces to a field, you make it into a bean, which can  
>> be used as the source of injections. The field can also be  
>> associated with a scope. When you first look up an instance of a  
>> bean, the field value is accessed, and stored in the context for  
>> it's lifetime.
>>
>> As we deal with EJB references, we can't directly access the field  
>> value (using reflection) so I think we should use the SPI here.
>>
>> I propose we add a method with this signature to the  
>> SessionObjectReference we previously created for the purpose of  
>> casting/removing EJBs https://svn.jboss.org/repos/webbeans/ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java
>
> There isn't necessarily a one-to-one relationship between an ejb  
> reference and a bean instance.   For stateless session beans, any  
> one of the bean instances can be used for any invocation.
>
> Can't this behavior be handled by the web beans interceptor?  By  
> definition, each interceptor instance has the same life cycle as its  
> associated bean instance, and the bean instance is available via the  
> Interceptor InvocationContext.

I did consider this, but not sure how to retrieve the result  
invocationContext.getTarget() at the time it is needed for accessing  
the producer field. We can't just store it from the construction point  
onwards (serializability) and I can't see a way to access it at some  
other point in the lifecycle - the only way to run an @AroundInvoke is  
to call a method, and in this case which method would you run, and how  
would you guarantee it has no side effects?

>
>
>>
>> /**
>>   * Retrieve the value of a (possibly private) field
>>   *
>>   * @param field
>>   *           the field to retrieve the value of
>>   * @return the retrieved value
>>   * @throws IllegalArgumentException
>>   *            if the field doesn't exist on this session object  
>> instance
>>   */
>>  public Object getFieldValue(Field field);
>>
>> Any comments?
>>
>>
>> On 29 Mar 2009, at 22:57, Pete Muir wrote:
>>
>>> Ok, I would think that some language in the spec to hint at this  
>>> might be good, as instances of session beans elsewhere in the spec  
>>> implies a EJB reference.
>>>
>>> On 29 Mar 2009, at 18:04, Gavin King wrote:
>>>
>>>> Yes, this is a good question - the 299 implementation would need
>>>> direct integration with the EJB container for this. (Not the only
>>>> place this is needed.)
>>>>
>>>>
>>>> On Sat, Mar 28, 2009 at 7:18 PM, Pete Muir <pmuir at redhat.com>  
>>>> wrote:
>>>>> Hey
>>>>>
>>>>> Not quite sure how this is supposed to work as everywhere we  
>>>>> hold a
>>>>> reference (proxy) to the EJB, and therefore don't have access to  
>>>>> the
>>>>> instance and therefore can't get hold of the fields. Any pointers?
>>>>>
>>>>> Thanks!
>>>>>
>>>>>
>>>>> --
>>>>> Pete Muir
>>>>> http://www.seamframework.org
>>>>> http://in.relation.to/Bloggers/Pete
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>> Gavin King
>>>> gavin.king at gmail.com
>>>> http://in.relation.to/Bloggers/Gavin
>>>> http://hibernate.org
>>>> http://seamframework.org
>>>
>>> --
>>> Pete Muir
>>> http://www.seamframework.org
>>> http://in.relation.to/Bloggers/Pete
>>>
>>> _______________________________________________
>>> webbeans-dev mailing list
>>> webbeans-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/webbeans-dev
>>
>> --
>> Pete Muir
>> http://www.seamframework.org
>> http://in.relation.to/Bloggers/Pete
>>
>
> _______________________________________________
> webbeans-dev mailing list
> webbeans-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/webbeans-dev

--
Pete Muir
http://www.seamframework.org
http://in.relation.to/Bloggers/Pete




More information about the weld-dev mailing list