![]() | ![]() | ![]() | ![]() | ![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | ![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]()
|
Castor JDO and JBoss
Documentation Author(s): Introduction Dependencies Configuring JBoss 3.2.1 Install The Dependencies Create A Datasource Configure Castor Configure Castor JDO MBean Test And Troubleshoot Developing Applications With Castor JDO and JBoss 3.x Frequently Asked Questions IntroductionThis document describes the advantages of using Castor with JBoss, an overview of the JBoss MBean approach and directions on configuring JBoss to use Castor JDO. The advantage of using Castor JDO within JBoss is that you have access to key J2EE features such as JNDI, JDBC datasources and transaction management (JTA). Although it is possible in principle to achieve this with other commercial J2EE servers, a ready-to-use plug-in is available to integrate Castor JDO within JBoss. Once integrated, Castor JDO can be used with session beans and BMP entity beans as an alternative to CMP entity beans and in many cases is faster and more efficient. An example of using Castor JDO with a stateless session bean has been created and is available here. This is a demonstration of the transient entity design pattern, described here.
Castor JDO is integrated with JBoss through the JMX
server environment provided by JBoss. The plug-in consists
of a JMX MBean or managed bean that implements the Castor DataObjects
interface by wrapping a JDO
object. The MBean accomplishes the following tasks at the startup
of JBoss 3.x:
Dependencies
There are two jars needed to use Castor JDO with JBoss:
Configuring JBoss 3.2.1
This section details the steps required to integrate Castor JDO with JBoss 3.x.
In brief, these are:
Install The DependenciesInstalling JBoss 3.x is outside of the scope of this discussion and is adequately covered by the JBoss documentation. Once JBoss is installed it is necessary to copy the two other dependencies (Castor and the Castor plugin) to the lib directory of the JBoss server instance you wish to install Castor for. The following path assumes you wish to install Castor on the "default" server: (JBOSS_HOME/server/default/lib). Create A Datasource
It is desirable to use Castor with a javax.sql.Datasource as this will
allow you to use connection pooling and distributed transactions, assuming
your driver supports these. Datasources are configured by placing a config
file ending in -ds.xml in the deploy directory of the server
instance you wish to use. For example, to configure a Microsoft SQL Server
XADatasource for the default server using the InetSoft Opta 2000 driver
you would place a file with the information below in the JBOSS_HOME/server/default/deploy
directory:
Configure CastorCopy your database.xml and mapping.xml to the configuration directory for your JBoss server instance: for example, JBOSS_HOME/server/default/conf.
Your database.xml should reference the datasource you created in the
previous step. For the datasource above:
Configure Castor JDO MBeanThe JBoss MBean server looks for MBean configuration files in the deploy directory of a server instance: JBOSS_HOME/server/default/deploy. These files will end in -service.xml. The MBean parses the xml file, creates the MBean instance and uses introspection to set properties on the MBean based on the attributes in the configuration.
To configure the JBoss MBean, place a file called castor-jdo-service.xml
in JBOSS_HOME/server/default/deploy with the following contents:
Test And Troubleshoot
To test your configuration, try and start the JBoss server instance you are
attempting to configure. Watch the console carefully for any stacktraces
or other error messages. With any luck, at some stage you should see something
like:
You can also check the status of your datasource by looking for it under the jca entry in the console. Developing Applications With Castor JDO and JBoss 3.x
To do:
Frequently Asked QuestionsCheck the JDO FAQ here for common questions regarding JDO usage. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() ![]() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |