User: vharcq  
  Date: 01/08/05 06:48:24

  Modified:    src/docs advconfig.xml
  Log:
  Section on resource-ref entry
  
  Revision  Changes    Path
  1.16      +125 -0    manual/src/docs/advconfig.xml
  
  Index: advconfig.xml
  ===================================================================
  RCS file: /cvsroot/jboss/manual/src/docs/advconfig.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- advconfig.xml     2001/07/16 05:17:52     1.15
  +++ advconfig.xml     2001/08/05 13:48:24     1.16
  @@ -45,6 +45,131 @@
                </figure>
        </section>
        <section>
  +             <title>Declaring Resource Reference</title>
  +     <para>Author:<author>
  +                     <firstname>Vincent</firstname>
  +                     <surname>Harcq</surname>
  +             </author>
  +             <email>[EMAIL PROTECTED]</email>
  +     </para>
  +     <section>
  +             <title>Introduction</title>
  +             <para>Resources are mainly used to access SQL DataSource object for 
use in BMP (Bean Managed Persistence)
  +entity beans or session beans.  They can also be used to access other type of 
resources like JavaMail Session
  +for example.</para>
  +             <para>The EJB specification defines how to define deployment 
descriptor entries to define such Resources.
  +JBoss defines an entry in jboss.xml for that purpose that can be seen as an 
indirection of what is done in 
  +ejb-jar.xml to the actual implementation of the resource.</para>
  +     </section>
  +     <section>
  +             <title>ejb-jar.xml</title>
  +             <para>The EJB specification facilitate the access to external 
"resources" through the use of deployment
  +descriptor entries in ejb-jar.xml.  The tag is <![CDATA[<resource-ref> and takes 4 
arguments <description>, 
  +<res-ref-name>, <res-type> and <res-auth>]]>.</para>
  +             <para>The res-ref-name element specifies the name of a resource 
manager connection factory reference.</para>
  +             <para>The res-type element specifies the type of the data source. The 
type is specified by the Java 
  +interface (or class) expected to be implemented by the data source.</para>
  +             <para>The res-auth element specifies whether the enterprise bean code 
signs on programmatically to 
  +the resource manager, or whether the Container will sign on to the resource manager 
on behalf of the bean. 
  +In the latter case, the Container uses information that is supplied by the 
Deployer.  Valid entry are 
  +"Container" and "Application".</para>
  +             <para>Example:
  +<programlisting><![CDATA[
  +    <!-- JDBC DataSources (java:comp/env/jdbc) -->
  +    <resource-ref>
  +        <description>The default DS</description>
  +        <res-ref-name>jdbc/DefaultDS</res-ref-name>
  +        <res-type>javax.sql.DataSource</res-type>
  +        <res-auth>Container</res-auth>
  +    </resource-ref>
  +    <!-- JavaMail Connection Factories (java:comp/env/mail) -->
  +    <resource-ref>
  +        <description>Default Mail</description>
  +        <res-ref-name>mail/DefaultMail</res-ref-name>
  +        <res-type>javax.mail.Session</res-type>
  +        <res-auth>Container</res-auth>
  +    </resource-ref>
  +    <!-- JMS Connection Factories (java:comp/env/jms) -->
  +    <resource-ref>
  +        <description>Default QueueFactory</description>
  +        <res-ref-name>jms/QueFactory</res-ref-name>
  +        <res-type>javax.jms.QueueConnectionFactory</res-type>
  +        <res-auth>Container</res-auth>
  +    </resource-ref>
  +]]></programlisting>
  +</para>
  +     </section>
  +     <section>
  +             <title>jboss.xml</title>
  +             <para>jboss.xml will redirect the res-ref-name entry to the 
implementation of the resource.  This is done
  +in <![CDATA[<resource-ref> that takes 3 arguments: <res-ref-name>, <res-type> and 
<jndi-name>]]>.  The first two
  +generally takes the value of corresponding entry in ejb-jar.xml.</para>
  +             <para>jndi-name points to the general definition of the resource in 
JBoss installation.</para>
  +             <para>Example:
  +<programlisting><![CDATA[
  +    <resource-ref>
  +        <res-ref-name>jdbc/DefaultDS</res-ref-name>
  +        <res-type>javax.sql.DataSource</res-type>
  +        <jndi-name>java:/DefaultDS</jndi-name>
  +    </resource-ref>
  +    <resource-ref>
  +        <res-ref-name>mail/DefaultMail</res-ref-name>
  +        <res-type>javax.mail.Session</res-type>
  +        <jndi-name>java:/Mail</jndi-name>
  +    </resource-ref>
  +    <resource-ref>
  +        <res-ref-name>jms/QueFactory</res-ref-name>
  +        <res-type>javax.jms.QueueConnectionFactory</res-type>
  +        <jndi-name>QueueConnectionFactory</jndi-name>
  +    </resource-ref>
  +]]></programlisting>
  +To access the Resource from your bean, do something like:
  +<programlisting><![CDATA[
  +    InitialContext ic = new InitialContext();
  +    DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/DefaultDS");
  +]]></programlisting>
  +or
  +<programlisting><![CDATA[
  +    InitialContext ic = new InitialContext();
  +    DataSource ds = (DataSource) ic.lookup("jdbc/DefaultDS");
  +]]></programlisting>
  +             </para>
  +     </section>
  +     <section>
  +             <title>JDBC Datasources</title>
  +             <para>For JDBC datasources, it points to the JNDI name bound to the 
Connection Pool.  This is defined in
  +jboss.jcml like:
  +<programlisting><![CDATA[
  +  <mbean code="org.jboss.jdbc.XADataSourceLoader" 
name="DefaultDomain:service=XADataSource,name=DefaultDS">
  +    <attribute name="PoolName">DefaultDS</attribute>
  +    ...
  +  </mbean>
  +]]></programlisting>
  +</para>
  +     </section>
  +     <section>
  +             <title>JavaMail Session</title>
  +             <para>For JavaMail session, it points to the JNDI name bound to the 
JavaMail session.  This is defined in
  +jboss.jcml like:
  +<programlisting><![CDATA[
  +  <mbean code="org.jboss.mail.MailService" name=":service=Mail">
  +    <attribute name="JNDIName">Mail</attribute>
  +    ...
  +  </mbean>
  +]]></programlisting>
  +</para>
  +     </section>
  +     <section>
  +             <title>JMS Connection Factory</title>
  +             <para>This is QueueConnectionFactory for JBoss 2.2 and 
ConnectionFactory for JBoss 2.4.</para>
  +     </section>
  +     <section>
  +             <title>Other</title>
  +             <para>You can define your own Resources as MBean, then use them from 
ejbs.  A example to look at for 
  +more information is <ulink 
url="http://www.jboss.org/jboss-castor.jsp";>Castor</ulink>.</para>
  +     </section>
  +     </section>
  +     <section>
                <title>Specifying the deployment name of your beans</title>
                <para>You have coded your beans. You now want to deploy them and be 
   able to access them from your clients. For this, JBoss will register your beans in 
the JNDI namespace. All you have to tell is the name under which they must be 
registered.</para>
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to