ExoLab     OpenEJB     OpenJMS     OpenORB     Castor     Tyrex     

  Castor Forums
  Mailing Lists
  CVS / Bugzilla

  Using XML
  Source Generator
  Schema Support
  XML Mapping

  Using JDO
  JDO Config
  JDO Mapping
  Other Features

Advanced JDO
  Trans. & Locks
  Long Trans.
  Nested Attrs.
  Pooling Examples

  The Examples
  3rd Party Tools
  JDO Tests
  XML Tests
  Tips & Tricks
  Full JavaDoc

  Status, Todo
  Project Name


Running The Examples
Castor JDO
Castor DSML
External Examples

Running The Examples

In order to run the examples located in src/examples, there are number of steps that must first take place. these steps are outlined below:

  1. Download the Castor source via either FTP or CVS. If the source has been downloaded via FTP, it must be decompressed. This is dependent on whether a gzipped tarball has been downloaded or a zip file has been downloaded.

    Steps for a gzipped tarball:

    tar zxvf castor-
    gunzip < castor- | tar xvf -

    Steps for a zip file:

    unzip castor-
    jar xvf castor-
    Get a copy of PowerArchiver

  2. If you're using Unix/Linux, the shell scripts must be made executable and the line endings must be changed. Use the following directions:

    1. Make the shell scripts executable:

      chmod +x *.sh

    2. Change the line endings on the shell scripts:

      for i in *.sh; do dos2unix $i $i; done

  3. If it is not set yet, please set the JAVA_HOME environment variable.
  4. Edit src/examples/jdo/database.xml for the database being used. (There are examples for all supported databases in src/tests/jdo.)
  5. Build the examples like so:

    build.[sh|bat] examples

    This will not only build the examples, but will also build the Castor classes.
  6. Add the appropriate classes for the database driver to the CLASSPATH.
  7. Run the examples using the directions in the next section.

The script files example.sh and example.bat can be used to run the provided examples. The first argument is the example package name. For example, to build and run the JDO example:

  build.sh examples
  example.sh jdo

Castor JDO

The JDO sample will test persistence between a set of Java classes (Product, ProductGroup, ProductDetail) and a known SQL schema. You can use the create.sql file to generate the database schema for the purpose of this test.

The mapping between the Java objects and SQL schema is described in the file mapping.xml. The JDBC connection to use is describes in the file database.xml. The provided file uses PostgreSQL as the database server and JDBC driver, you can modify this file for your database server and use any JDBC 1.0 or 2.0 driver.

The database information and mapping are automatically read from the JDO example directory, there is no need to provide any parameters on the command line.

The performance test uses the ODMG engine as well as direct JDBC access. You must provide the JDBC URI and class name to use for this test on the command line.


  example.sh jdo

Castor DSML

Do not run this sample against a production LDAP server unless you are sure it will not affect the information in your directory!

The DSML sample will attempt to import the supplied directory information from the test.xml file using the import policy described in the import.xml. file. It will then run a search against the LDAP server using the search criteria in the search.xml file and dump it to the console.

You must modify search.xml, import.xml and test.xml and adapt them to your LDAP directory structure. The default files assumes the root directory dc=intalio,dc=com and includes some sample LDAP entries.


  test.sh dsml [jndi|mozilla] <host> <root-dn> <root-pwd>

  jndi|mozilla  Selects whether to use the JNDI or Mozilla Directory
	        SDK implementations
  host          The LDAP host name (port number is optional)
  rood-dn       The root DN used for authenticating when importing
  root-pwd      The root password used for authenticating when importing
For example:
  example.sh dsml mozilla ldap.intalio.com dc=intalio,dc=com secret

External Examples

This sections provides a place link external examples of using Castor. If you have an example that you feel would be useful please send us the URL. Also notify us if any links are broken.


Goran Zugic and Duka Krunic of ebXMLsoft Inc. have some samples using Castor XML and Castor JDO. The examples use Castor 0.9.2 and offer good insight in using XML and JDO together.


Copyright © 1999-2004 ExoLab Group. All rights reserved.
Java, EJB, JDBC, JNDI, JTA, Sun, Sun Microsystems are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and in other countries. XML, XML Schema, XSLT and related standards are trademarks or registered trademarks of MIT, INRIA, Keio or others, and a product of the World Wide Web Consortium. All other product names mentioned herein are trademarks of their respective owners.