users@javaee-spec.java.net

[javaee-spec users] [jsr342-experts] Re: resource definition metadata for administered objects

From: Werner Keil <werner.keil_at_gmail.com>
Date: Fri, 18 May 2012 19:17:16 -0300

Antonio/all,

Having the full JDBC level Datasource definition is optional, and for
cobtainers like Tomcat it may be more common to put such information in the
web.xml, but even there I know from projects based on such containers,
there are at least context.xml and server.xml where you may define such
resources.

To be precise, Tomcat has data sources inside a <context> tag, which I
recall also seems present if you define it in the web.xml instead. A global
cobtext applies to all, while you may define them just for a web
application level, too.

Full scale Java EE containers like WebLogic, JBoss or Glassfish have their
own places, and one may only refer to the JNDI name of a datasource in
other files.

JBoss has XML files with a series of <datasources> holding one or more
<datasource> entries, so in those files unless defined elsewhere it's on a
"root" level.
I cannot say, where it makes sense to define that for an individual
session, but to be honest in most EE projects I came across, such location
would only hold the logical DB source name, not its entire definition like
server or JDBC driver.

Here the focus seems the <bean> so I'm not sure, if you'd have more than
one session each with a different source or even DB type?;-) For definion
in other places vendors among us may have to agree on an XML structure,
that makes sense.

Werner
Am 17.05.2012 21:06 schrieb "Reza Rahman" <reza_rahman_at_lycos.com>:

> +1****
>
> ** **
>
> *From:* Antonio Goncalves [mailto:antonio.goncalves_at_gmail.com]
> *Sent:* Tuesday, May 15, 2012 11:21 AM
> *To:* jsr342-experts_at_javaee-spec.java.net
> *Subject:* [jsr342-experts] Re: resource definition metadata for
> administered objects****
>
> ** **
>
> Hi all,****
>
> ** **
>
> I'm coming back to this topic because I'm working for a customer's project
> and here is what I see in the ejb-jar.xml file : ****
>
> ** **
>
> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"****
>
> version="3.1"****
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"****
>
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">****
>
> ** **
>
> <enterprise-beans>****
>
> <session>****
>
> <ejb-name>AccountService</ejb-name>****
>
> <ejb-class>fr.xxx.AccountService</ejb-class>****
>
> *<data-source>*****
>
> <description>H2 DataSource</description>****
>
> <name>java:global/jdbc/H2DS</name>****
>
> <class-name>org.h2.jdbcx.JdbcDataSource</class-name>****
>
> <url>jdbc:h2:~/H2DB;AUTO_SERVER=TRUE</url>****
>
> </data-source>****
>
> </session>****
>
> </enterprise-beans>****
>
> ** **
>
> </ejb-jar>****
>
> ** **
>
> I hadn't pay attention before, but the <data-source> element is nested
> into the <session> element. Which is not the case in the web.xml where
> the <data-source> element is at the root. Why is not <data-source> defined
> at the root ? It should be "the datasource is defined for all EJBs so it's
> at the root of the xml file", no ?****
>
> ** **
>
> Antonio****
>
> ** **
>
> On Tue, Mar 6, 2012 at 2:06 AM, Linda DeMichiel <
> linda.demichiel_at_oracle.com> wrote:****
>
> We've gotten feedback from our internal team, including connector lead,
> that we should also include metadata for connector administered objects.
>
> While I had initially thought that the proposed connector resource
> definition
> metadata was flexible enough to accommodate this (especially since we
> had already covered the most important administered object case, JMS
> destination objects), I agree that it would be clearer for developers if we
> separate out this additional case.
>
> I plan to add a subsection to the spec to cover this in the EDR we submit
> to the JCP. Please let me know asap if you disagree with this.
>
> Draft annotation and XML element are below. I propose that the annotation
> should be added to javax.resource
>
> thanks,
>
> -Linda
>
> -------------------------------------------
>
>
> /**
> * Annotation used to define a Connector administered object to be
> * registered in JNDI.
> *
> * Once defined, an administered object may be referenced
> * by a component using the lookup element of the
> * Resource annotation.
> *
> */
> @Retention(RUNTIME)
> @Target({TYPE})
> public @interface AdministeredObjectDefinition {
>
> /**
> * Description of the administered object.
> */
> String description() default "";
>
> /**
> * JNDI name of the administered object being defined.
> */
> String name();
>
> /**
> * Type of the administered object.
> */
> String className();
>
> /**
> * Name of the resource adapter.
> */
> String resourceAdapterName() default "";
>
> /**
> * Properties of the administered object. These may be
> * vendor-specific properties.
> */
> String[] properties() default {};
> }
>
>
> XML example:
>
> <administered-object>
> <description>Sample Admin Object definition</description>
> <name>java:app/MyAdminObject</name>
> <class-name>com.extraServices.AdminObject</class-name>
> <resource-adapter-name>myESRA</resource-adapter-name>
> <property>
> <name>Property1</name>
> <value>10</value>
> </property>
> <property>
> <name>Property2</name>
> <value>20</value>
> </property>
> </administered-object>
>
> ****
>
>
>
> ****
>
> ** **
>
> --
> Antonio Goncalves
> Software architect and Java Champion
>
> Web site <http://www.antoniogoncalves.org> | Twitter<http://twitter.com/agoncal>|
> Blog <http://feeds.feedburner.com/AntonioGoncalves> | LinkedIn<http://www.linkedin.com/in/agoncal>| Paris
> JUG <http://www.parisjug.org>****
>