[webbeans-dev] Re: Rough draft proposal for resource injection

Scott Ferguson ferg at caucho.com
Thu Jan 8 13:23:19 EST 2009


On Jan 8, 2009, at 9:53 AM, Gavin King wrote:

> On Fri, Jan 9, 2009 at 4:38 AM, Scott Ferguson <ferg at caucho.com>  
> wrote:
>
>> First, this capability should be implemented as a general Bridge  
>> defined in
>> javax.webbeans.spi.Bridge and define the JavaEE capabilities in  
>> terms of the
>> underlying Bridge.  (Similar in logic to Bean but a different point  
>> in the
>> configuration lifecycle.)  That would improve modularity and allow an
>> eventual migration of the Bridge ownership to the individual JavaEE  
>> specs in
>> a later version.
>
> Hrm, I don't get your comment about configuration lifecycle. Surely
> this Bridge would just be a subtype of Bean?

It might be a subtype of Bean, just like the Decorator is a subtype,  
but its functionality is different because it's used to select a new  
Bean type (i.e. not simple bean).  It's not a bean itself.

Take the following:

   <sqlx:DataSource>
     <ann:Resource>...
   </sqx:DataSource>

This fragment defines a Bean (with the registered type DataSource).   
To create the Bean and process the XML, though, some code needs to  
understand javax.annotation.Resource.  The code that understands  
<ann:Resource> and which generates the DataSource Bean can (and  
should) be encapsulated and modularized.  Nothing in the current spec  
has that capability, i.e. it's not captured by the Bean concept.

To see this, note that <ann:Resource> is currently forbidden by the  
spec, because it's not annotated by something like @BindingType.  In  
other words, the example is doing something unique beyond the  
capabilities of the rest of the spec.

Or, in a different way, the spec definines the behavior of  
ann:Resource, and ejb:EJB, not sqlx:DataSource.   If the spec defined  
sqlx:DataSource directly, it would be a Bean, but because you're  
defining ann:Resource to choose a Bean type for sqlx:DataSource, it's  
something different.

Or, another way, <sqlx:DataSource> is not a simple bean, and the  
<ann:Resource> specifies what kind of Bean it is.

-- Scott


>
>
> I don't understand what we need it for.
>
> I feel like Bean already provides sufficient pluggability...
>
>
>> Second, the JavaEE annotation types should be defined in their own  
>> namespace
>> for modularity and consistency, not the WebBeans namespace.
>>
>> <xsql:DataSource xmlns:xsql="urn:java:javax.sql">
>> <ann:Resource xmlns:ann="urn:java:javax.annotation">
>>    ...
>> </ann:...>
>>
>> <my:Foo xmlns:my="urn:java:com.foo.my">
>> <ejb:EJB xmlns:ejb="urn:java:javax.ejb">
>>
>> <jms:Queue xmlns:jms="urn:java:javax.jms">
>> ...
>
> I'm OK with that if others are.
>
>
>
> -- 
> Gavin King
> gavin.king at gmail.com
> http://in.relation.to/Bloggers/Gavin
> http://hibernate.org
> http://seamframework.org
>
>




More information about the weld-dev mailing list