[weld-dev] standard servlet context attribute for the BeanManager

Emmanuel Bernard emmanuel at hibernate.org
Wed Mar 24 03:38:28 EDT 2010


But how do you solve that in SE? Or even in a web environment, more  
and more web environment are getting away from the servlet API imposed  
constraint.

On 24 mars 2010, at 07:56, David Allen <drallendc at gmail.com> wrote:

> Hi Dan,
>
> This sounds good.  Should this be submitted to the Expert Group?
>
> - David
>
> Am Montag, den 22.03.2010, 15:46 -0400 schrieb Dan Allen:
>> At the last Seam team meeting, the issue came up (once again) of how
>> to get the BeanManager from a non-contextual resource. The reality is
>> that there are certain lifecycle classes in Java EE that did not
>> get categorized as components (e.g., PhaseListener) and therefore do
>> not support injection. They are "outside" of CDI. We are working on  
>> an
>> SPI for JSF to make these classes CDI beans, but there will always be
>> other cases.
>>
>>
>> In the current version of the spec, the standard way of looking up  
>> the
>> BeanManager is to use JNDI. However, JNDI is not consistently
>> supported in environments for which we want to write portable
>> extensions (whether we like it or not, people use servlet  
>> containers).
>> Weld puts the BeanManager in a servlet context attribute equal to the
>> FQCN of BeanManager. Pete suggested that we submit a change request  
>> to
>> have this location standardized when running in a servlet  
>> environment.
>>
>>
>> With this change, the BeanManager can be obtained as follows:
>>
>>
>> BeanManager manager = (BeanManager)
>> getServletContext().getAttribute(BeanManager.class.getName());
>>
>>
>> This requires no change in Weld, since Weld is already doing this.
>>
>>
>> -Dan
>>
>> -- 
>> Dan Allen
>> Senior Software Engineer, Red Hat | Author of Seam in Action
>> Registered Linux User #231597
>>
>> http://mojavelinux.com
>> http://mojavelinux.com/seaminaction
>> http://www.google.com/profiles/dan.j.allen
>>
>> _______________________________________________
>> weld-dev mailing list
>> weld-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/weld-dev
>
>
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev


More information about the weld-dev mailing list