Skip to main content

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

  • From: Antonio Goncalves <antonio.goncalves@...>
  • To: Bill Shannon <bill.shannon@...>
  • Cc: jsr342-experts@...
  • Subject: [javaee-spec users] [jsr342-experts] Re: resource definition metadata for administered objects
  • Date: Wed, 16 May 2012 09:30:09 +0200
  • List-id: <jsr342-experts.javaee-spec.java.net>

It's a shame. Their usecase is quite legitimate and will become more and more common with Arquillian. They have packaged all their EJBs into a single jar, with an ejb-jar.xml with the datasource. This self-suficient jar can then be tested by Arquillian. In this scenario you don't need a web.xml or an application.xml, but you would like to say "all EJBs defined in this single jar share the same datasource that is defined".

I remember doing EJBs back in 2000 and we would package one EJB into one jar file. Now we are moving to a single war file or, in the case of my customer, one war file with one jar file with all the EJBs. A shame we can't have all EJBs sharing a single component namespace in this kind of scenario.

Antonio

On Tue, May 15, 2012 at 8:31 PM, Bill Shannon <bill.shannon@...> wrote:
This is an inconsistency in the way we've defined the component namespaces from the beginning.

In a war file, all classes share a single component namespace.

In an ejb-jar file, each EJB component gets its own component namespace.

We talked about this when we introduced the new java:module namespace in EE 6 and decided not to "fix" it.

Antonio Goncalves wrote on 05/15/12 08:21:
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 : 

         version="3.1"

    <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@...> 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 | TwitterBlog | LinkedInParis JUG




--
Antonio Goncalves
Software architect and Java Champion

Web site | TwitterBlog | LinkedInParis JUG


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

Antonio Goncalves 05/15/2012

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

Bill Shannon 05/15/2012

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

Antonio Goncalves 05/16/2012

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

Reza Rahman 05/18/2012

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

Werner Keil 05/18/2012

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

Werner Keil 05/18/2012
 
 
Close
loading
Please Confirm
Close