|  |  |  | License Codehaus OpenEJB OpenJMS OpenORB Tyrex

Old releases
General
Release 1.3
Release 1.3rc1
Release 1.2

Main
Home
About
Features
Download
Dependencies
Reference guide
Publications
JavaDoc
Maven 2 support
Maven 2 archetypes
DTD & Schemas
Recent HTML changes
News Archive
RSS news feed
Project Wiki

Development/Support
Mailing Lists
SVN/JIRA
Contributing
Support
Continuous builds
Prof. services

Related projects
Spring ORM support
Spring XML factories
WS frameworks

XML
XML

XML Code Generator
XML Code Generator

JDO
Introduction
First steps
Using JDO
JDO Config
Types
JDO Mapping
JDO FAQ
JDO Examples
JDO HOW-TOs
Tips & Tricks
Other Features
JDO sample JAR

Tools
Schema generator

Advanced JDO
Caching
OQL
Trans. & Locks
Design
KeyGen
Long Trans.
Nested Attrs.
Pooling Examples
LOBs
Best practice

DDL Generator
Using DDL Generator
Properties
Ant task
Type Mapping

More
The Examples
3rd Party Tools
JDO Tests
XML Tests
Configuration

About
License
User stories
Contributors
Marketplace
Status, Todo
Changelog
Library
Contact
Project Name

## The Castor XML configuration file

News
Introduction
Accessing the properties from within code
Current configuration file

## News

- | Added a section on how to access the properties as defined in the Castor properties file from within code.
- | Release 1.2.1:: Added new `org.exolab.castor.xml.lenient.integer.validation` property to allow configuration of leniency for validation for Java properties generated from `<xs:integer>` types during code generation.
- | Release 1.2:: Access to the <api>org.exolab.castor.util.LocalConfiguration</api> class has been removed completely. To access the properties as used by Castor from code, please refer to the below section.
- | Release 1.1.3: Added special processing of proxied classes. The property org.exolab.castor.xml.proxyInterfaces allows you to specify a list of interfaces that such proxied objects implement. If your object implements one of these interfaces Castor will not use the class itself but its superclass at introspection or to find class mappings and ClassDescriptors.
- | Release 0.9.7: Added new org.exolab.castor.persist.useProxies property to allow configuration of JDBC proxy classes. If enabled, JDBC proxy classes will be used to wrap `java.sql.Connection` and `java.sql.PreparedStatement` instances, to allow for more detailed and complete JDBC statements to be output during logging. When turned off, no logging statements will be generated at all.

## Introduction

Castor uses a configuration file for environmental properties that are shared across all the Castor sub systems. The configuration file is specified as a Java properties file with the name `castor.properties`.

The Castor JAR includes a default configuration file. A configuration file in the Java library directory (e.g. `/jdk1.2/lib`) can be used to override the default configuration file with system-wide properties. In addition, a configuration file can be placed in the classpath and will override both the system wide properties and Castor-default configuration.

When running the provided examples, Castor will use the configuration file located in the examples directory which specifies additional debugging information as well as pretty printing of all produced XML documents.

The following properties are currently supported in the configuration file:

Name | Description | Values | Default | Since
org.exolab.castor.xml.introspector.primitive.nodetype | Property specifying the type of XML node to use for primitive values, either `element` or `attribute` | `element` or `attribute` | `attribute` | -
org.exolab.castor.parser | Property specifying the class name of the SAX XML parser to use. | - | - | -
org.exolab.castor.parser.validation | Specifies whether to perform XML document validation by default. | `true` and `false` | `false` | -
org.exolab.castor.parser.namespaces | Specifies whether to support XML namespaces by default. | `false` and `true` | `false` | -
org.exolab.castor.xml.nspackages | Specifies a list of XML namespace to Java package mappings. | - | - | -
org.exolab.castor.xml.naming | Property specifying the 'type' of the XML naming conventions to use. Values of this property must be either `mixed`, `lower`, or the name of a class which extends XMLNaming. | `mixed`, `lower`, or the name of a class which extends XMLNaming | `lower` | -
org.castor.xml.java.naming | Property specifying the 'type' of the Java naming conventions to use. Values of this property must be either `null` or the name of a class which extends JavaNaming. | `null` or the name of a class which extends JavaNaming | `null` | -
org.exolab.castor.marshalling.validation | Specifies whether to use validation during marshalling. | `false` or `true` | `true` | -
org.exolab.castor.indent | Specifies whether XML documents (as generated at marshalling) should use indentation or not. | `false` or `true` | `false` | -
org.exolab.castor.sax.features | Specifies additional features for the XML parser. | A comma separated list of SAX (parser) features (that might or might not be supported by the specified SAX parser). | - | -
org.exolab.castor.sax.features-to-disable | Specifies features to be disbaled on the underlying SAX parser. | A comma separated list of SAX (parser) features to be disabled. | - | 1.0.4
org.exolab.castor.regexp | Specifies the regular expression validator to use. | A class that implements RegExpValidator. | - | -
org.exolab.castor.xml.strictelements | Specifies whether to apply strictness to elements when unmarshalling. When enabled, the existence of elements in the XML document, which cannot be mapped to a class, causes a {@link SAXException} to be thrown. If set to false, these 'unknown' elements are ignored. | `false` or `true` | `true` | -
org.exolab.castor.xml.loadPackageMappings | Specifies whether the ClassDescriptorResolver should (automatically) search for and consult with package mapping files (`.castor.xml`) to retrieve class descriptor information | `false` or `true` | `true` | 1.0.2
org.exolab.castor.xml.serializer.factory | Specifying what XML serializers factory to use. | A class name | org.exolab.castor.xml.XercesXMLSerializerFactory | 1.0
org.exolab.castor.xml.lenient.sequence.order | Specifies whether sequence order validation should be lenient. | `false` or `true` | `false` | 1.1
org.exolab.castor.xml.lenient.id.validation | Specifies whether id/href validation should be lenient. | `false` or `true` | `false` | 1.1
org.exolab.castor.xml.proxyInterfaces | Specifies whether or not to search for an proxy interface at marshalling. If property is not empty the objects to be marshalled will be searched if they implement one of the given interface names. If the interface is implemented, the superclass will be marshalled instead of the class itself. | A list of proxy interfaces | - | 1.1.3
org.exolab.castor.xml.lenient.integer.validation | Specifies whether validation for Java properties generated from <xs:integer> should be lenient, i.e. allow for `int`s as well. | `false` or `true` | `false` | 1.2.1

## Accessing the properties from within code

As of Castor 1.1, it is possible to read and set the value of properties programmatically using the `getProperty(String)` and `setProperty(String,String)` on the following classes:

- | <api>org.exolab.castor.xml.Unmarshaller
- | <api>org.exolab.castor.xml.Marshaller
- | <api>org.exolab.castor.xml.XMLContext

Whilst using the setter methods on the first two classes will change the settings of the respective instances only, using the `setProperty()` method on the `<api>XMLContext` class will change the configuration globally, and affect all `<api>Unmarshaller` and `<api>Marshaller` instances created thereafter using the `createUnmarshaller()` and `createMarshaller()` methods.

## Current configuration file

This is a copy of the current Castor configuration file as shipped with the Castor XML JAR file.

    # THE CASTOR PROPERTIES FILE
    # This file specifies values for Castor run-time which may be configured
    # by the user.
    # $Id: conf-lib.xml 7076 2007-07-24 22:03:25Z rjoachim $

    # This section defines Backwards compatibility switches.
    #
    # Hashtable/Map default mapping.
    # For backward compatibility with 0.9.5.2 and earlier.
    #
    #org.exolab.castor.xml.saveMapKeys=false

    # Defines the default XML parser to be used by Castor.
    # The parser must implement org.xml.sax.Parser.
    #
    org.exolab.castor.parser=org.apache.xerces.parsers.SAXParser

    # Defines the (default) XML serializer factory to use by Castor, which must
    # implement org.exolab.castor.xml.SerializerFactory;
    # Default is org.exolab.castor.xml.XercesXMLSerializerFactory
    org.exolab.castor.xml.serializer.factory=org.exolab.castor.xml.XercesXMLSerializerFactory

    # Defines the NodeType for use with Java primitive types (int, long, boolean,
    # etc). This value is only used by the Introspector.  Valid values are either
    # "attribute" or "element". By default, all primitives are marshaled as
    # attributes. Uncomment the following line to change the NodeType to element.
    #
    #org.exolab.castor.xml.introspector.primitive.nodetype=element

    # Defines the Naming "style" or conventions to use when creating XML names
    # from Java class or field names.
    # Valid values are as follows:
    # -----------------------------------------------------------------
    # lower (default)  |  All names are lowercase with hyphens
    #                  |  separating words.
    #                  |
    #                  |  Example: personInfo = person-info
    # -----------------------------------------------------------------
    # mixed            |  All names are mixed case, with Uppercase
    #                  |  character as the first letter of a new word.
    #                  |
    #                  |  Example: personInfo = personInfo
    #                  |  Example: FooBar     = fooBar
    # -----------------------------------------------------------------
    # {Any ClassName}  |  Any Class which implements
    #                  |  org.exolab.castor.xml.XMLNaming
    # -----------------------------------------------------------------
    #
    # By default, all names are treated as the "lower" option.  To preserve the
    # Java mixed-case conventions, uncomment the following line.
    #
    #org.exolab.castor.xml.naming=mixed

    ###############################
    # REGULAR EXPRESSION EVALUATORS
    #
    # Defines the Regular Expression Evaluator to be used by Castor.
    # The evaluator must implement org.exolab.castor.util.RegExpEvaluator.
    #
    # Uncomment the following to basically suppress Regular expressions evaluation:
    #org.exolab.castor.regexp=org.exolab.castor.xml.util.AlwaysTrueRegExpEvaluator
    #
    # An implementation which uses the Jakarta RegExp library:
    #org.exolab.castor.regexp=org.exolab.castor.util.JakartaRegExpEvaluator
    #
    # An implementation which uses the Jakarta ORO library:
    org.exolab.castor.regexp=org.exolab.castor.util.JakartaOroEvaluator

    # True if all documents should be indented on output by default.
    # Defaults to false.
    #
    #org.exolab.castor.indent=true

    # True if xml documents should be validated by the SAX Parser
    # Defaults to false.
    #
    org.exolab.castor.parser.validation=false

    # True for parser to support Namespaces.
    # Defaults to false.
    #
    org.exolab.castor.parser.namespaces=false

    # True if all documents should be validated by the marshaling framework
    # Defaults to true.
    #
    org.exolab.castor.marshalling.validation=true

    # Comma separated list of SAX 2 features that should be enabled for the
    # default parser.
    #
    #org.exolab.castor.sax.features=

    # Comma separated list of SAX 2 features that should be disabled for the
    # default parser.
    #
    #org.exolab.castor.sax.features-to-disable

    # True if debugging output should be generated.
    # Defaults to false.
    #
    org.exolab.castor.debug=false

    # Property specifying whether or not to search for an proxy interface at marshalling.
    # If property is not empty the objects to be marshalled will be searched if they
    # implement one of the given interface names. If the interface is implemented the
    # superclass will be marshalled instead of the class itself.
    #
    #org.exolab.castor.xml.proxyInterfaces=\
    #  net.sf.cglib.proxy.Factory, \
    #  org.hibernate.proxy.HibernateProxy

    # List of collection handlers for Java 1.1 and Java 1.2 run-times:
    #
    org.exolab.castor.mapping.collections=\
      org.exolab.castor.mapping.loader.J1CollectionHandlers,\
      org.exolab.castor.mapping.loader.J2CollectionHandlers

    # List of persistence factories for the supported database servers:
    #
    org.exolab.castor.jdo.engines=\
      org.exolab.castor.jdo.drivers.OracleFactory,\
      org.exolab.castor.jdo.drivers.PostgreSQLFactory,\
      org.exolab.castor.jdo.drivers.SybaseFactory,\
      org.exolab.castor.jdo.drivers.SQLServerFactory,\
      org.exolab.castor.jdo.drivers.DB2Factory,\
      org.exolab.castor.jdo.drivers.InformixFactory,\
      org.exolab.castor.jdo.drivers.HsqlFactory,\
      org.exolab.castor.jdo.drivers.InstantDBFactory,\
      org.exolab.castor.jdo.drivers.InterbaseFactory,\
      org.exolab.castor.jdo.drivers.MySQLFactory,\
      org.exolab.castor.jdo.drivers.SapDbFactory,\
      org.exolab.castor.jdo.drivers.GenericFactory,\
      org.exolab.castor.jdo.drivers.DerbyFactory,\
      org.castor.jdo.drivers.PointbaseFactory,\
      org.castor.jdo.drivers.ProgressFactory

    # List of key generator factories:
    #
    org.exolab.castor.jdo.keyGeneratorFactories=\
      org.exolab.castor.jdo.keygen.MaxKeyGeneratorFactory,\
      org.exolab.castor.jdo.keygen.HighLowKeyGeneratorFactory,\
      org.exolab.castor.jdo.keygen.IdentityKeyGeneratorFactory,\
      org.exolab.castor.jdo.keygen.SequenceKeyGeneratorFactory,\
      org.exolab.castor.jdo.keygen.UUIDKeyGeneratorFactory

    # Collection handlers for the source code generator:
    #
    org.exolab.castor.builder.type.j2=\
      org.exolab.castor.builder.FieldInfoFactoryJ2
    org.exolab.castor.builder.type.j1=\
      org.exolab.castor.builder.FieldInfoFactory
    org.exolab.castor.builder.type.odmg=\
      org.exolab.castor.builder.FieldInfoFactoryODMG30

    # Configures the default time zone to apply to dates/times fetched from
    # database fields (if not already part of the data).  Specify same format as
    # in java.util.TimeZone.getTimeZone, or the empty string to use the computer's
    # local time zone. Please see http://de.wikipedia.org/wiki/Zeitzone for
    # detailed information about time zones.
    #
    org.exolab.castor.jdo.defaultTimeZone=
    #org.exolab.castor.jdo.defaultTimeZone=GMT-8:00

    # List of TxSynchronizeable implementations:
    #
    #org.exolab.castor.persist.TxSynchronizable=

    # Sets the buffer size in bytes for fetching LOBs (this is dependent upon
    # the JDBC driver implementation).  The value below == 5k.
    #
    org.exolab.castor.jdo.lobBufferSize=5120

    # True if database configuration should be initalization
    # when loading it (default: true).
    #
    #org.exolab.castor.jdo.DatabaseInitializeAtLoad=true

    # True if proxy classes should be used for JDBC connections and
    # prepared statements.
    # Defaults to true.
    #
    org.exolab.castor.persist.useProxies=false

    # MappingLoader implementations:
    #
    org.castor.mapping.loaderFactories=\
      org.castor.mapping.JDOMappingLoaderFactory,\
      org.castor.mapping.XMLMappingLoaderFactory

    # Cache implementations:
    #
    org.castor.cache.Factories=\
      org.castor.cache.simple.NoCacheFactory,\
      org.castor.cache.simple.TimeLimitedFactory,\
      org.castor.cache.simple.CountLimitedFactory,\
      org.castor.cache.simple.UnlimitedFactory,\
      org.castor.cache.distributed.FKCacheFactory,\
      org.castor.cache.distributed.JcsCacheFactory,\
      org.castor.cache.distributed.JCacheFactory,\
      org.castor.cache.distributed.CoherenceCacheFactory,\
      org.castor.cache.distributed.OsCacheFactory,\
      org.castor.cache.hashbelt.FIFOHashbeltFactory,\
      org.castor.cache.hashbelt.LRUHashbeltFactory,\
      org.castor.cache.distributed.EHCacheFactory,\
      org.castor.cache.distributed.GigaspacesCacheFactory

    # TransactionManagerFactory implementations:
    #
    org.castor.transactionmanager.Factories=\
      org.castor.transactionmanager.WebSphereTransactionManagerFactory,\
      org.castor.transactionmanager.WebSphere5TransactionManagerFactory,\
      org.castor.transactionmanager.WebSphere51TransactionManagerFactory,\
      org.castor.transactionmanager.LocalTransactionManagerFactory,\
      org.castor.transactionmanager.JNDIENCTransactionManagerFactory,\
      org.castor.transactionmanager.JOTMTransactionManagerFactory

    # Selects whether the TransactionManager should be initialized at registration,
    # or lazily when requested for the first time.
    # Defaults to false.
    #
    org.castor.transactionmanager.InitializeAtRegistration=false

    # Instructs Castor JDO to use the JDBC 3.0-specific features to obtain
    # the generated value of an identity column.
    # Defaults to false.
    #
    org.castor.jdo.use.jdbc30=false

    # Specifies whether to use ANSI-compliant SQL for MS SQL Server.
    # Defaults to false.
    #
    org.exolab.castor.jdo.sqlserver.ansi-compliant=false

    # Specifyies whether the ClassDescriptorResolver should (automatically) search
    # for and consult with package mapping files (.castor.xml) to retrieve class
    # descriptor information; on by default.
    # Defaults to true.
    #
    #org.exolab.castor.xml.loadPackageMappings=false

<notice> Copyright © 1999-2005 ExoLab Group, Intalio Inc., and Contributors. All rights reserved. </notice>
<notice> 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. </notice>