[prev in list] [next in list] [prev in thread] [next in thread]
List: xml-cocoon-docs
Subject: [WIKI-UPDATE] OJBWithJDO Mon Jul 28 16:00:03 2003
From: stevenn () outerthought ! org
Date: 2003-07-28 14:00:04
[Download RAW message or body]
Page: http://wiki.cocoondev.org/Wiki.jsp?page=OJBWithJDO , version: 1 on Mon Jul 28 \
13:15:01 2003 by AntonioGallardo
New page created:
+ !!Using OJB with JDO in Cocoon
+
+ This is a "howto" about using OJB-JDO in Cocoon.
+
+ In this Howto we will show how to set a simple example of using OJB-JDO with \
Cocoon. + The example uses PostgreSQL database, but you can change it to use another \
RDMS. +
+ !Introduction
+ __ObJectRelationalBridge__ (OJB) is an Object/Relational mapping tool that allows
+ transparent persistence for Java Objects against relational databases.
+
+ OJB has 3 methods for access to Databases:
+ # PersistentBroker
+ # ODMG
+ #JDO.
+
+ Since JDO is the recommended succesor of ODMG, we will try to show how to
+ start using JDO with Cocoon
+
+ !Scenario
+ * We need to interact with a table that manage user's info. The table is called \
__auth_user__. The table primary key is autofilled with a sequence called \
__auth_users_seq__. +
+ * We have already installed and running Cocoon.
+
+ !Environment
+ * Red Hat Linux 9
+ * Sun J2SDK 1.4.2
+ * Tomcat 4.1.24
+ * Cocoon 2.1 (CVS 28-Jul-3003
+ * PostgreSQL 7.3.2
+ * OJB-JDO 1.0rc4 (CVS 28-Jul-2003)
+
+ !Solution
+
+ 1. Download OJB 1.0rc4 from http://db.apache.org/builds/ojb/
+ * Be sure you the binaries has JDORI support.
+ * The command to build from sources with JDORI support is: {{ bin/build.sh \
with-jdori jar }} +
+ * __Note__: ''Before building see 2.''
+
+ 2. Download the [JDO libraries|http://java.sun.com/products/jdo]:
+ * jdo.jar - for the OjbStore JDORI Plugin only.
+ * jdori.jar - for the OjbStore JDORI Plugin only.
+
+ 3. Create the __auth_user__ table and the __auth_user_seq__ sequence in your \
__test__ database. + * See __posgres.sql__ for PostgreSQL
+
+ 4. Create a file __auth_user.jdo__
+ * This file contains the mapping between the beans and database columns for JDO
+
+ 5. Compile and __enhance__ the __auth_user.java__ bean.
+ * See __auth_user.java__.
+ * The classes imported in step 1. and 2. are needed, include it in your classpath.
+ * Put the ONLY the output class into \
"TOMCAT_HOME/webapps/cocoon/WEB-INF/classes/test" +
+ 6. Create a file __repository.xml__ in "TOMCAT_HOME/webapps/cocoon/WEB-INF/classes"
+ *This file contains info about your DB and credentials (jdbc driver, username and \
password). +
+ 7. Copy files __repository.dtd__ and __OJB.properties__ in \
"TOMCAT_HOME/webapps/cocoon/WEB-INF/classes" +
+ 8. Copy the following files from the OJB distribution to \
"TOMCAT_HOME/webapps/cocoon/WEB-INF/lib": + {{{
+ antlr.jar
+ jdori.jar
+ commons-dbcp.jar
+ commons-pool.jar
+ db-ojb-1.0.rc4.jar
+ jdo.jar
+ }}}
+ *Please also include your database driver. As we are working with postgres...
+
+ **__pg73jdbc3.jar__
+
+ 9. Copy __adduser.xml__ and __sitemap.xmap__ into \
"TOMCAT_HOME/webapps/cocoon/ojbdemo" +
+ !Test
+ Open __http://localhost:8080/cocoon/ojbdemo/adduser__\\
+ If all goes well, a record is added to your database.\\
+ If you press the refresh button in your browser you will get an error because you \
are trying to insert + a new record with the same usr_login. (The column is UNIQUE).
+
+ !Links
+ *__OJB Website:__ http://db.apache.org/ojb/ \\
+ *__Quickstart:__ http://db.apache.org/ojb/quickstart.html
+
+ !Notes
+ * This is a first attemp to integrate OJB-JDO with Cocoon. I am also a OJB newbie. \
But after a week studing about OJB and JDO I think OJB with JDO is a good way to fill \
the current "model" gap in the MVC design. + * Currently I am trying to create a \
component that will create a __PersistentManagerFactory__ just once for all the \
application.\\ + The idea is that any request can "get" the global factory and ask \
his own PersistentManager. This is the correct way. After that we can use JDO as the \
"model" using java classes. +
+ !Readers comments.
+
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic