OK,
In the jar files (http://www.citeweb.net/sebsahuc/castor-jboss.jar) is 
the Mbean for integrating Castor inside jboss. 

Unfortunately, 
there is quite a lot of things I'm not happy about :

+ At compile time you need the castor library in the classpath. Should we 
use the reflection to avoid this ?

+ The 'database' document must be in the classpath. (database file is the 
config file that contains the DB connection info (use of the JDBC 
resource manager through JNDI ENC) + link to mapping file(s). It's the 
first parameter of the Mlet.

+ Lazing loading of the mapping file. Cannot be done at init or starting 
time of the Mbean because it needs a JDBC connection, and the jdbc ENC is 
not available at this time.

+ The loading is quite long. I believe there is classloader issues, but 
I'm not sure so far. Need investigation...

+ The class is under package jdbc, should be moved. The class name is not 
good also, so any suggestion on these points would be appreciate.

+ There is an small conflict on the XML parser used. Indeed Castor uses 
Xerces by default, while jboss uses Sun's parser. At this point I suggest 
that you -jboss- upgrade to the JAXP library, so that you don't depend on 
any parser. I can submit the diff for that purpose if you want... On the 
other hand, castor permits the use of other SAX parser by placing a 
castor.properties in the classpath (another conf file in the conf 
directory...) and changing one of it values.

+ Need to add 2 lines in org.jboss.ejb.Container to make the link-ref for 
global Resource manager provided by the application assembler. See 
attached java class at lines 489-592 in setupEnvironment() method.



o--------------------o

HOW TO USE IT :

* Put the castor jar in lib/ext directory (available from 
http://castor.exolab.org)

* Add the Mlet in jboss.conf

ARCHIVE="jboss.jar,castor-0.8.8.jar" CODEBASE="../lib/ext/">

where database.xml is the database document needed by the Castor JDO. See 
castor documentation for further info on the content of this file)
and the second parameter is the name given to the database (atribute of 
database.xml). It will serve to set the JNDI name. See below.

* Declare the resource managers in your jboss.xml besides your 
ejb-jar.xml :
jdo/myjdo
jdo.test
[...]

Notice that the jndi name is composed of the second parameter of the Mlet 
(jdo.$DBNAME)

* Declare the resource manager JNDI ENC for the beans in ejb-jar.xml :

[...]
JDO
jdo/myjdo
org.exolab.castor.jdo.JDO
Container

* Get the JDO object in your Session bean as :

a_method () {
InitialContext ic = new InitialContext();
JDO jdo = (JDO) ic.lookup("java:comp/env/jdo/myjdo");
Database db = jdo.getDatabase();
db.create (obj1);
[...]
db.remove(obj2)
[...] 
whatever action on db
}




Any comments or questions, please go ahead, I'm ready :-)


Sebastien Sahuc


Reply via email to