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

Scott Ferguson ferg at caucho.com
Thu Jan 8 12:38:17 EST 2009


On Jan 8, 2009, at 5:47 AM, Gavin King wrote:

> Everyone, please take a look at section 3.6 of this spec draft, which
> defines a proposal for EE resource injection.
>
> Basically, what I've proposed is that web beans would let you rewrite
> the following:
>
>   @Resource(mappedName="customerDatabase") Datasource ds;
>
> as:
>
>   @CustomerDatabase Datasource ds;
>
>   <javaxsql:Datasource>
>      <Resource>
>         <mappedName>customerDatabase</mappedName>
>      </Resource>
>      <myapp:CustomerDatabase/>
>   </javaxsql:Datasource>

I'd like to see two changes.

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.

The implementation would define ResourceBridgeImpl and EjbBridgeImpl  
to recognize the types its responsible for and define config items/ 
annotations (presumably reusing the current annotations.)

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">
   ...

etc.

That way, the Resource, EJB, etc. are defined in terms of underlying  
WebBeans capabilities, not baked into the spec.

-- Scott

>
>
> and:
>
>   @EJB(ejbLink="somejar#Foo") Foo foo;
>
> as:
>
>   @Current Foo foo;
>
>   <myapp:Foo>
>      <EJB>
>         <ejbLink>somejar#Foo</ejbLink>
>      </EJB>
>   </myapp:Foo>
>
> and:
>
>   @WebServiceRef(name="barbar", wsdlLocation="barbarbar") Bar bar;
>
> as:
>
>   @Current Bar bar;
>
>   <myapp:Bar>
>      <WebServiceRef>
>         <name>barbar</name>
>         <wsdlLocation>barbarbar</wsdLocation>
>      </WebServiceRef>
>   </myapp:Bar>
>
> So this proposal is just basically an indirection around the
> pre-existing semantics of Java EE injection, that gives you all the
> nice Web Beans typesafety.
>
> This seems a really nice, easy way to define this stuff, and I love
> how the XML looks.
>
> -- 
> Gavin King
> gavin.king at gmail.com
> http://in.relation.to/Bloggers/Gavin
> http://hibernate.org
> http://seamframework.org
> <Web Beans 20090109.pdf>




More information about the weld-dev mailing list