Hi Linda,
> I'm not sure whether your interpretation is in agreement with what
> I've written. Can you confirm?
Unfortunately, no... I won't speak for David's situation with OpenEJB and
TomEE, but from a WebSphere perspective, this interpretation puts us in a
pickle... WebSphere provides default bindings based on the name of the
resource. So, something like this would map to two separate datasources
due to the default bindings that WebSphere utilized prior to Java EE 7:
@Resource
DataSource myDS;
@Resource
DataSource myDStoo;
With your stated interpretation, both of these datasources (myDS and
myDStoo) would map to the same datasource that is defined at
"java:comp/DefaultDataSource", correct?
I believe your interpretation and expectation, Linda. I just wonder
whether Werner and David had the same interpretation... Maybe I'm the
only one in left field. Thanks.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Kevin Sutter, Java EE and Java Persistence API (JPA) architect
mail: sutter_at_us.ibm.com, Kevin Sutter/Rochester/IBM
http://webspherepersistence.blogspot.com/
phone: tl-553-3620 (office), 507-253-3620 (office)
http://openjpa.apache.org/
Linda DeMichiel <linda.demichiel_at_oracle.com> wrote on 06/05/2013 06:09:45
PM:
> From: Linda DeMichiel <linda.demichiel_at_oracle.com>
> To: jsr342-experts_at_javaee-spec.java.net,
> Date: 06/05/2013 06:10 PM
> Subject: [jsr342-experts] Re: Clarification on Default resources
>
> Hi Kevin,
>
> On 6/4/2013 2:07 PM, Kevin Sutter wrote:
> > Hi,
> > The discussion about the Default resources in the Java EE 7 spec
> pre-dates my involvement, so I'm looking for some
> > clarification. I've reviewed the discussion in the archives and an
> associated JIRA, but I still have questions...
> >
> > https://java.net/projects/javaee-spec/lists/jsr342-experts/
> archive/2012-03/message/56
> > https://java.net/projects/javaee-spec/lists/jsr342-experts/
> archive/2012-03/message/70
> > https://java.net/jira/browse/JAVAEE_SPEC-4
> >
> > I was especially interested in David Blevin's replies as they
> relate to OpenEJB and TomEE since it sounds like they
> > already provide default resource bindings similar to WebSphere.
> >
> > My basic question centers around this example. From the spec, are
> these two @Resource injections supposed to resolve to
> > the same datasource?
> >
>
> Yes.
>
> > __at_Resource_(lookup="java:comp/DefaultDataSource")
> > DataSource myDS;
> > __at_Resource_
> > DataSource myDS;
> >
> > My reading of the spec would indicate that the latter example
> (plain @Resource) would default to the product's default
> > datasource. The use of the word "product" is key in my
> understanding. If the product already provides a default mapping,
> > then the plain @Resource could continue to default to the behavior
> as prescribed by the product. But, if the product
> > does not currently provide a default mapping, then the plain
> @Resource could default to the newly defined resource
> > located at java:comp/DefaultDataSource. And, Werner's final
> comment seems to support that interpretation:
>
> If the product already (i.e., pre JavaEE 7) supported a default
> mapping, then the expectation would be
> that the two code snippets above would under Java EE 7 both refer to
> that same default data source.
>
> >
> > "Thanks, that sounds like the most flexible approach. While not
> confusing those who are fine with the default
> > lookup, others who may require alternatives there can overwrite it."
> >
>
> The spec requires the product to support the default mapping, but is
> silent on the possibility of
> the overwriting of the mapping, e.g., by the administrator or
> deployer. However, in the absence of such
> hypothetical overwriting, the expectation of the spec is that the
> two uses of @Resource above reference
> the same default datasource.
>
> > Is my interpretation accurate? Thanks for the input.
>
> I'm not sure whether your interpretation is in agreement with what
> I've written. Can you confirm?
>
> thanks,
>
> -Linda
>
> >
> >
>
----------------------------------------------------------------------------------------------------------------------------------------------------------------
> > Kevin Sutter, Java EE and Java Persistence API (JPA) architect
> > mail: sutter_at_us.ibm.com, Kevin Sutter/Rochester/IBM http://
> webspherepersistence.blogspot.com/
> > phone: tl-553-3620 (office), 507-253-3620 (office) http://
> openjpa.apache.org/
>