User: vharcq
Date: 01/06/24 02:59:00
Modified: src/docs customizingjaws.xml
Log:
Chapter 5 : added ONE example
Match the doco with the example.
Revision Changes Path
1.11 +99 -89 manual/src/docs/customizingjaws.xml
Index: customizingjaws.xml
===================================================================
RCS file: /cvsroot/jboss/manual/src/docs/customizingjaws.xml,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- customizingjaws.xml 2001/06/23 16:12:29 1.10
+++ customizingjaws.xml 2001/06/24 09:59:00 1.11
@@ -56,12 +56,25 @@
<para>If you want to know everything about jaws.xml, see the Jaws.xml DTD.
The
general structure of the jaws.xml can be found here. All parts of
this file are optional: you only provide what you need!</para>
+<para>
+ The full source code to accompany this chapter can be found
+ in zip format (documentation-example.zip) or tar/gzip
(documentation-example.tar.gz) format
+ from the file section of the documentation section
+ on <ulink
url="http://www.jboss.org/doco_files/">http://www.jboss.org/doco_files/</ulink>.</para>
+ <para>Download this file and extract it to any directory. Open a DOS/Shell
box under the "build"
+subdirectory. Now specify 3 environment variables JBOSS_HOME, ANT_HOME and
JAVA_HOME that must refer
+respectively to the JBoss installation directory, the Ant installation directory
and the JDK installation
+directory.</para>
+ <para>Run "build cmp-jaws-compile" from the "build/" subdirectory.
This will create a ejb jar
+"documentation-example/build-examples/cmp-jaws/ejb/class.jar". Drop it in the
"deploy" directory of your
+JBoss installation. This example shows all possibilities described in this
chapter. You may wqnt to change
+the files as you read this chapter, simply rebuild in EJB jar and deploy it to see
the changes.</para>
</section>
<section>
<title>Specifying a datasource</title>
<para>A datasource is, mainly, a database plus a driver plus a connection
pool. By
default, jboss uses the Hypersonic datasource. To add another
-datasource, you have to declare it as a JMX MLet: see <xref
linkend="jdbc-database"/>.</para>
+datasource, you have to declare it as a JMX MLet: see Chapter 3.</para>
<para>The second ARG of this MLet is the JNDI name of the datasource, i.e.
the name
you have to use to access it. To tell JAWS to use this
datasource, simply add in your jaws.xml file a <![CDATA[ <datasource> tag
@@ -132,12 +145,12 @@
</listitem>
</itemizedlist>
<para>For instance, if you want to use the Postgres Database that you have
deployed
-in jboss.conf under the name MyPostgresPool, this is how
+in jboss.conf under the name InstantDB, this is how
your jaws.xml file should look like:</para>
<programlisting><![CDATA[
<jaws>
- <datasource>MyPostgresPool</datasource>
- <type-mapping>PostgreSQL</type-mapping>
+ <datasource>InstantDB</datasource>
+ <type-mapping>InstantDB</type-mapping>
...
</jaws>
@@ -216,14 +229,14 @@
]]></programlisting>
<para>Settings for a bean: to set an option for a particular bean, do it in
the
corresponding <![CDATA[ <entity> section. For example, if you want JAWS to
-drop the table for your CustomerBean only, your xml file will contain:
+drop the table for your ClassBean only, your xml file will contain:
]]></para>
<programlisting><![CDATA[
<jaws>
...
<enterprise-beans>
<entity>
- <ejb-name>CustomerBean</ejb-name>
+ <ejb-name>ClassBean</ejb-name>
<remove-table>true</remove-table>
</entity>
</enterprise-beans>
@@ -251,61 +264,58 @@
]]></para>
<section>
<title>Example 1</title>
- <para>You create an entity bean that will represent a customer. You
+ <para>You create an entity bean that will represent a class. You
already have the table in your database, it was created using the
following SQL statement:</para>
- <para>CREATE TABLE CUSTOMER (NAME VARCHAR(20), ADDRESS VARCHAR(100), PHONE
VARCHAR(20));</para>
+ <para>CREATE TABLE CLASS (ID INTEGER, TEACHER VARCHAR(100), STUDENTNBR
INTEGER);</para>
<para>This is how the your xml file will look like:</para>
<programlisting><![CDATA[
- <jaws>
- <enterprise-beans>
- <entity>
- <ejb-name>CustomerBean</ejb-name>
- <table-name>CUSTOMER</table-name>
- <create-table>false</create-table>
- <cmp-field>
- <field-name>customerName</field-name>
- <column-name>NAME</column-name>
- </cmp-field>
- <cmp-field>
- <field-name>address</field-name>
- <column-name>ADDRESS</column-name>
- </cmp-field>
- <cmp-field>
- <field-name>phoneNumber</field-name>
- <column-name>PHONE</column-name>
- </cmp-field>
- </entity>
- </enterprise-beans>
- ...
- </jaws>
-
+<jaws>
+ <enterprise-beans>
+ <entity>
+ <ejb-name>ClassBean</ejb-name>
+ <table-name>CLASS</table-name>
+ <create-table>false</create-table>
+ <cmp-field>
+ <field-name>classId</field-name>
+ <column-name>ID</column-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>teacherName</field-name>
+ <column-name>TEACHER</column-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>studentCount</field-name>
+ <column-name>STUDENTNBR</column-name>
+ </cmp-field>
+ </entity>
+ </enterprise-beans>
+</jaws>
]]></programlisting>
</section>
<section>
<title>Example 2</title>
- <para>Your bank account bean has a String field to hold the VISA card
-number. You don't want to use the default mapping for a String
-(VARCHAR(256)) since a VISA Card number is not that long. Your xml file will
+ <para>Your Class bean has a String field to hold the Teacher name.
+ You don't want to use the default mapping for a String
+(VARCHAR(256)) since a name is not that long. Your xml file will
look like this:</para>
<programlisting><![CDATA[
- <jaws>
- <enterprise-beans>
- <entity>
- <ejb-name>Account</ejb-name>
- <cmp-field>
- <field-name>cardNumber</field-name>
- <column-name>VISA</column-name>
- <jdbc-type>VARCHAR</jdbc-type>
- <sql-type>VARCHAR(16)</sql-type>
- </cmp-field>
- ...
- </entity>
- </enterprise-beans>
- ...
- </jaws>
-
+<jaws>
+ <enterprise-beans>
+ <entity>
+ <ejb-name>ClassBean</ejb-name>
+ ...
+ <cmp-field>
+ <field-name>teacherName</field-name>
+ <column-name>TEACHER</column-name>
+ <jdbc-type>VARCHAR</jdbc-type>
+ <sql-type>VARCHAR(100)</sql-type>
+ </cmp-field>
+ ...
+ </entity>
+ </enterprise-beans>
+</jaws>
]]></programlisting>
<para>Note that the contents of the <![CDATA[ <ejb-name> tag and of all
the
]]><![CDATA[ <field-name> tags must match the ones declared in
@@ -345,54 +355,54 @@
<para>Example: you want to select classes with a mininum number of
students. Your
Class bean has the following structure:</para>
<programlisting><![CDATA[
- <ejb-jar>
- <enterprise-beans>
- <entity>
- <ejb-name>ClassBean</ejb-name>
- ...
- <prim-key-class>java.lang.String</prim-key-class>
- ...
- <cmp-field>
- <field-name>classId</field-name>
- </cmp-field>
- <cmp-field>
- <field-name>teacherName</field-name>
- </cmp-field>
- <cmp-field>
- <field-name>studentCount</field-name>
- </cmp-field>
- <primkey-field>classId</primkey-field>
- ...
- </entity>
- </enterprise-beans>
- ...
- </ejb-jar>
+<ejb-jar>
+ <display-name>Class</display-name>
+ <enterprise-beans>
+
+ <entity>
+ <description>Models a Class</description>
+ <ejb-name>ClassBean</ejb-name>
+ <home>org.jboss.docs.cmp.jaws.interfaces.ClassHome</home>
+ <remote>org.jboss.docs.cmp.jaws.interfaces.Class</remote>
+ <ejb-class>org.jboss.docs.cmp.jaws.bean.ClassBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.Integer</prim-key-class>
+ <reentrant>False</reentrant>
+ <cmp-field><field-name>classId</field-name></cmp-field>
+ <cmp-field><field-name>teacherName</field-name></cmp-field>
+ <cmp-field><field-name>studentCount</field-name></cmp-field>
+ <primkey-field>classId</primkey-field>
+ </entity>
+
+ </enterprise-beans>
+ ...
+</ejb-jar>
]]></programlisting>
<para>You want to define a method in ClassHome:</para>
- <programlisting> public Collection findBigClasses(int minStudentCount,
String teacher)
- throws FinderException;
+ <programlisting>
+public Collection findBigClasses(Integer minStudentCount, String teacher)
+throws FinderException, RemoteException;
</programlisting>
<para>Your jaws.xml file will contain the following:</para>
<programlisting><![CDATA[
- <jaws>
- <enterprise-beans>
- <entity>
- <ejb-name>ClassBean</ejb-name>
- <finder>
- <name>findBigClasses</name>
- <query>studentCount > {0} AND teacherName = {1}</query>
- <order>studentCount DESC</order>
- </finder>
- </entity>
- </enterprise-beans>
- ...
- </jaws>
-
+<jaws>
+ <enterprise-beans>
+ <entity>
+ <ejb-name>ClassBean</ejb-name>
+ ...
+ <finder>
+ <name>findBigClasses</name>
+ <query>studentCount > {0} AND teacherName = {1}</query>
+ <order>studentCount DESC</order>
+ </finder>
+ </entity>
+ </enterprise-beans>
+</jaws>
]]></programlisting>
<para>Then a call to findBigClasses(100, "Jones") will generate</para>
<programlisting>SELECT classId FROM ClassBean
- WHERE studentCount > 100 AND teacherName = Jones
+ WHERE studentCount > 100 AND teacherName = 'Jones'
ORDER BY studentCount DESC;</programlisting>
</section>
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development