[weld-dev] spec question on 3.5 Resource Beans

Mark Struberg struberg at yahoo.de
Mon Feb 15 19:01:28 EST 2010


Hi!

I don't get it if section 3.5 is only meant as an example on how to map between e.g. a named persistence unit to a @Qualifier defined injection, or if this is now the ONLY way to inject @PersistenceUnits, etc.

In the older versions of the spec it was explicitly defined that (at least in an EE environment) normal injections defined in JSR-250 et al must be supported, e.g.:

private @PersistenceContext(unitName="myUnit") EntityManager myUnitEm;
private @Ressource(lookup="java:global/env/jdbc/CustomerDatasource") Datasource customerDs;

have been perfectly valid and functional in older spec versions.

Is this still allowed/has to be supported (in an EE environment)? Argument for this: "A resource MAY be declared by..."
Or will writing this annotations (without @Produces!) into a bean will not cause any injection by a JSR-299 container?

In case of injecting @PersistenceContext, adding @Produces and a Qualifier imho simply makes them a producer field, so I don't understand why there is any need for a special 'resource bean' in this case. I also do not understand the restriction for disallowing @Named. Of course @Named in the EL sense doesn't make much sense for _any_ @Dependent scoped bean, but @Named is a perfectly valid qualifier also! So it would be perfectly valid to write
private @Inject @Named("specialEm") EntityManager em;

It would also be perfectly possible to provide a EntityManager via a producer method btw, isn't?

Is there any reason why we cannot simply say that injecting EE resources must be provided in an EE container? Then all your neat tricks should simply just work?

txs 4 clarifying,
strub


__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 



More information about the weld-dev mailing list