User: vharcq
Date: 01/08/05 07:43:58
Modified: src/docs advconfig.xml
Log:
resource-ref section : java.net.URL and resource-managers
Revision Changes Path
1.17 +96 -16 manual/src/docs/advconfig.xml
Index: advconfig.xml
===================================================================
RCS file: /cvsroot/jboss/manual/src/docs/advconfig.xml,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- advconfig.xml 2001/08/05 13:48:24 1.16
+++ advconfig.xml 2001/08/05 14:43:58 1.17
@@ -66,13 +66,21 @@
<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>
+<itemizedlist>
+ <listitem>
<para>The res-ref-name element specifies the name of a resource
manager connection factory reference.</para>
+ </listitem>
+ <listitem>
<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>
+ </listitem>
+ <listitem>
<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>
+ </listitem>
+</itemizedlist>
<para>Example:
<programlisting><![CDATA[
<!-- JDBC DataSources (java:comp/env/jdbc) -->
@@ -82,6 +90,13 @@
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
+ <!-- URL Connection Factories (java:comp/env/url) -->
+ <resource-ref>
+ <description>The default URL</description>
+ <res-ref-name>url/defaultUrl</res-ref-name>
+ <res-type>java.net.url</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
<!-- JavaMail Connection Factories (java:comp/env/mail) -->
<resource-ref>
<description>Default Mail</description>
@@ -102,28 +117,93 @@
<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>
+in <![CDATA[<resource-ref> that takes different arguments depending on how the tag
is used: <resource-name>,
+<res-ref-name>, <res-type> and <jndi-name>]]>.</para>
+<itemizedlist>
+ <listitem>
+ <para>res-ref-name must always be present and takes the value of
corresponding entry in ejb-jar.xml.</para>
+ </listitem>
+ <listitem>
<para>jndi-name points to the general definition of the resource in
JBoss installation.</para>
+ </listitem>
+ <listitem>
+ <para>res-url is used for java.net.URL type Resource only and define
the URL.</para>
+ </listitem>
+ <listitem>
+ <para>resource-name is there to introduce a new level of indirection
to a Resource Manager.</para>
+ </listitem>
+</itemizedlist>
+ <para>A Resource Manager is defined globally for an EJB JAR inside
<![CDATA[<resource-managers> and takes
+different arguments : <res-name>, <res-url>, <res-jndi-name> and
res-class.]]></para>
+<itemizedlist>
+ <listitem>
+ <para>res-name must always be defined and takes the value of
corresponding resource-name entry of
+resource-ref.</para>
+ </listitem>
+ <listitem>
+ <para>res-jndi-name points to the general definition of the resource
in JBoss installation.</para>
+ </listitem>
+ <listitem>
+ <para>res-url is used for java.net.URL type Resource only and define
the URL.</para>
+ </listitem>
+ <listitem>
+ <para>res-class can be blank, or is the Java type of the
resource.</para>
+ </listitem>
+</itemizedlist>
<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>
+ <enterprise-beans>
+ <session>
+ ...
+ <resource-ref>
+ <res-ref-name>jdbc/DefaultDS</res-ref-name>
+ <resource-name>DefaultDS</jndi-name>
+ </resource-ref>
+ <resource-ref>
+ <res-ref-name>url/defaultUrl</res-ref-name>
+ <res-url>http://www.jboss.org/</res-url>
+ </resource-ref>
+ <resource-ref>
+ <res-ref-name>url/otherUrl</res-ref-name>
+ <resource-name>SourceforgeHomePage</resource-name>
+ </resource-ref>
+ <resource-ref>
+ <res-ref-name>mail/DefaultMail</res-ref-name>
+ <resource-name>DefaultMail</jndi-name>
+ </resource-ref>
+ <resource-ref>
+ <res-ref-name>jms/QueFactory</res-ref-name>
+ <jndi-name>QueueConnectionFactory</jndi-name>
+ </resource-ref>
+ ...
+ </session>
+ </enterprise-beans>
+
+ <resource-managers>
+ <resource-manager res-class="">
+ <res-name>DefaultDS</res-name>
+ <res-jndi-name>java:/DefaultDS</res-jndi-name>
+ </resource-manager>
+ <resource-manager res-class="">
+ <res-name>DefaultMail</res-name>
+ <res-jndi-name>java:/Mail</res-jndi-name>
+ </resource-manager>
+ <resource-manager res-class="java.net.URL">
+ <res-name>otherUrl</res-name>
+ <res-url>http://sourceforge.net/</res-url>
+ </resource-manager>
+ </resource-managers>
+]]></programlisting>
+Note that this example include complexity not necessary in all cases. Resource
Managers does not have to be
+specified. The simple example for JDBC DataSource is:
+<programlisting><![CDATA[
<resource-ref>
- <res-ref-name>jms/QueFactory</res-ref-name>
- <res-type>javax.jms.QueueConnectionFactory</res-type>
- <jndi-name>QueueConnectionFactory</jndi-name>
+ <res-ref-name>jdbc/DefaultDS</res-ref-name>
+ <jndi-name>java:/DefaultDS</jndi-name>
</resource-ref>
]]></programlisting>
-To access the Resource from your bean, do something like:
+</para>
+<para>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");
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development