Index: cpa/src/main/java/org/exolab/castor/persist/KeyGeneratorFactoryRegistry.java
===================================================================
--- cpa/src/main/java/org/exolab/castor/persist/KeyGeneratorFactoryRegistry.java (revision 8022)
+++ cpa/src/main/java/org/exolab/castor/persist/KeyGeneratorFactoryRegistry.java (working copy)
@@ -49,8 +49,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
import org.exolab.castor.persist.spi.KeyGeneratorFactory;
/**
@@ -105,9 +105,10 @@
*/
private static synchronized void load() {
if (_factories.isEmpty()) {
- Configuration config = CPAConfiguration.getInstance();
- Object[] objects = config.getObjectArray(
- CPAConfiguration.KEYGENERATOR_FACTORIES, config.getApplicationClassLoader());
+ AbstractProperties properties = CPAProperties.getInstance();
+ Object[] objects = properties.getObjectArray(
+ CPAProperties.KEYGENERATOR_FACTORIES,
+ properties.getApplicationClassLoader());
for (int i = 0; i < objects.length; i++) {
KeyGeneratorFactory factory = (KeyGeneratorFactory) objects[i];
_factories.put(factory.getName(), factory);
Index: cpa/src/main/java/org/castor/cpa/persistence/convertor/TypeConvertor.java
===================================================================
--- cpa/src/main/java/org/castor/cpa/persistence/convertor/TypeConvertor.java (revision 8022)
+++ cpa/src/main/java/org/castor/cpa/persistence/convertor/TypeConvertor.java (working copy)
@@ -15,7 +15,7 @@
*/
package org.castor.cpa.persistence.convertor;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
/**
* Interface for a type convertor. A type convertor converts a Java object from one
@@ -32,9 +32,9 @@
/**
* Configure the converter with given configuration.
*
- * @param configuration Configuration to use.
+ * @param properties Properties to use.
*/
- void configure(Configuration configuration);
+ void configure(AbstractProperties properties);
/**
* Initialize the converter with the given parameter. If no parameter is available the method
Index: cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToShort.java
===================================================================
--- cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToShort.java (revision 8022)
+++ cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToShort.java (working copy)
@@ -15,7 +15,7 @@
*/
package org.castor.cpa.persistence.convertor;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
/**
* Convert Boolean to Short.
@@ -47,7 +47,7 @@
/**
* {@inheritDoc}
*/
- public void configure(final Configuration configuration) { }
+ public void configure(final AbstractProperties properties) { }
/**
* {@inheritDoc}
Index: cpa/src/main/java/org/exolab/castor/jdo/engine/JDOMappingLoader.java
===================================================================
--- cpa/src/main/java/org/exolab/castor/jdo/engine/JDOMappingLoader.java (revision 8022)
+++ cpa/src/main/java/org/exolab/castor/jdo/engine/JDOMappingLoader.java (working copy)
@@ -61,9 +61,9 @@
import org.castor.cache.Cache;
import org.castor.cache.simple.CountLimited;
import org.castor.cache.simple.TimeLimited;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
import org.castor.core.util.Messages;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.cpa.CPAProperties;
import org.castor.cpa.persistence.convertor.AbstractSimpleTypeConvertor;
import org.castor.cpa.persistence.convertor.TypeConvertorRegistry;
import org.castor.jdo.engine.SQLTypeInfos;
@@ -185,8 +185,8 @@
public JDOMappingLoader(final ClassLoader loader) {
super(loader);
- Configuration config = CPAConfiguration.getInstance();
- _typeConvertorRegistry = new TypeConvertorRegistry(config);
+ AbstractProperties properties = CPAProperties.getInstance();
+ _typeConvertorRegistry = new TypeConvertorRegistry(properties);
}
/**
Index: cpactf/src/test/java/org/castor/cpa/test/test2177/Test2177.java
===================================================================
--- cpactf/src/test/java/org/castor/cpa/test/test2177/Test2177.java (revision 8026)
+++ cpactf/src/test/java/org/castor/cpa/test/test2177/Test2177.java (working copy)
@@ -3,8 +3,8 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
import org.castor.cpa.test.framework.CPATestCase;
import org.castor.cpa.test.framework.xml.types.DatabaseEngineType;
import org.exolab.castor.jdo.Database;
@@ -41,8 +41,8 @@
protected void setUp() throws Exception {
super.setUp();
- Configuration cfg = getConfiguration();
- _memConvertors = cfg.getString(CPAConfiguration.TYPE_CONVERTORS);
+ AbstractProperties properties = getProperties();
+ _memConvertors = properties.getString(CPAProperties.TYPE_CONVERTORS);
StringBuffer convertors = new StringBuffer();
convertors.append(_memConvertors);
@@ -50,12 +50,12 @@
convertors.append(FromCustomTypeConvertor.class.getName());
convertors.append(", ");
convertors.append(ToCustomTypeConvertor.class.getName());
- cfg.put(CPAConfiguration.TYPE_CONVERTORS, convertors.toString());
+ properties.put(CPAProperties.TYPE_CONVERTORS, convertors.toString());
}
protected void tearDown() throws Exception {
- Configuration cfg = getConfiguration();
- cfg.put(CPAConfiguration.TYPE_CONVERTORS, _memConvertors);
+ AbstractProperties properties = getProperties();
+ properties.put(CPAProperties.TYPE_CONVERTORS, _memConvertors);
super.tearDown();
}
Index: cpactf/src/old/java/ctf/jdo/tc20x/TestTimezone.java
===================================================================
--- cpactf/src/old/java/ctf/jdo/tc20x/TestTimezone.java (revision 8025)
+++ cpactf/src/old/java/ctf/jdo/tc20x/TestTimezone.java (working copy)
@@ -34,8 +34,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
import org.exolab.castor.jdo.Database;
import org.exolab.castor.jdo.PersistenceException;
@@ -60,10 +60,10 @@
public void testDate() throws Exception {
LOG.debug("user.timezone = " + System.getProperty("user.timezone"));
- Configuration config = CPAConfiguration.newInstance();
- String testTimezone = config.getString(CPAConfiguration.DEFAULT_TIMEZONE,
+ AbstractProperties properties = CPAProperties.newInstance();
+ String testTimezone = properties.getString(CPAProperties.DEFAULT_TIMEZONE,
System.getProperty("user.timezone"));
- LOG.debug(CPAConfiguration.DEFAULT_TIMEZONE + " = " + testTimezone);
+ LOG.debug(CPAProperties.DEFAULT_TIMEZONE + " = " + testTimezone);
Database database = _category.getDatabase();
@@ -171,10 +171,10 @@
public void testTime() throws Exception {
LOG.debug("user.timezone = " + System.getProperty("user.timezone"));
- Configuration config = CPAConfiguration.newInstance();
- String testTimezone = config.getString(CPAConfiguration.DEFAULT_TIMEZONE,
+ AbstractProperties properties = CPAProperties.newInstance();
+ String testTimezone = properties.getString(CPAProperties.DEFAULT_TIMEZONE,
System.getProperty("user.timezone"));
- LOG.debug(CPAConfiguration.DEFAULT_TIMEZONE + " = " + testTimezone);
+ LOG.debug(CPAProperties.DEFAULT_TIMEZONE + " = " + testTimezone);
Database database = _category.getDatabase();
@@ -279,10 +279,10 @@
public void testTimestamp() throws Exception {
LOG.debug("user.timezone = " + System.getProperty("user.timezone"));
- Configuration config = CPAConfiguration.newInstance();
- String testTimezone = config.getString(CPAConfiguration.DEFAULT_TIMEZONE,
+ AbstractProperties properties = CPAProperties.newInstance();
+ String testTimezone = properties.getString(CPAProperties.DEFAULT_TIMEZONE,
System.getProperty("user.timezone"));
- LOG.debug(CPAConfiguration.DEFAULT_TIMEZONE + " = " + testTimezone);
+ LOG.debug(CPAProperties.DEFAULT_TIMEZONE + " = " + testTimezone);
Database database = _category.getDatabase();
Index: cpa/src/main/java/org/exolab/castor/jdo/engine/SQLStatementCreate.java
===================================================================
--- cpa/src/main/java/org/exolab/castor/jdo/engine/SQLStatementCreate.java (revision 8022)
+++ cpa/src/main/java/org/exolab/castor/jdo/engine/SQLStatementCreate.java (working copy)
@@ -32,9 +32,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
import org.castor.core.util.Messages;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.cpa.CPAProperties;
import org.castor.jdo.engine.ConnectionFactory;
import org.castor.jdo.engine.DatabaseRegistry;
import org.castor.jdo.engine.SQLTypeInfos;
@@ -82,8 +82,8 @@
_keyGen = getKeyGenerator(engine, factory);
- Configuration config = CPAConfiguration.getInstance();
- _useJDBC30 = config.getBoolean(CPAConfiguration.USE_JDBC30, false);
+ AbstractProperties properties = CPAProperties.getInstance();
+ _useJDBC30 = properties.getBoolean(CPAProperties.USE_JDBC30, false);
_lookupStatement = new SQLStatementLookup(engine, factory);
Index: cpa/src/main/java/org/castor/cpa/CPAProperties.java
===================================================================
--- cpa/src/main/java/org/castor/cpa/CPAProperties.java (revision 8022)
+++ cpa/src/main/java/org/castor/cpa/CPAProperties.java (working copy)
@@ -17,98 +17,98 @@
*/
package org.castor.cpa;
-import org.castor.core.CoreConfiguration;
-import org.castor.core.util.CastorConfiguration;
-import org.castor.core.util.Configuration;
-import org.castor.xml.XMLConfiguration;
+import org.castor.core.CoreProperties;
+import org.castor.core.util.CastorProperties;
+import org.castor.core.util.AbstractProperties;
+import org.castor.xml.XMLProperties;
/**
- * Castor configuration of CPA modul.
+ * Properties of CPA modul.
*
* @version $Id: Configuration.java,v 1.8 2006/03/08 17:25:52 jens Exp $
* @author Ralf Joachim
* @since 1.1.3
*/
-public final class CPAConfiguration extends Configuration {
+public final class CPAProperties extends AbstractProperties {
//--------------------------------------------------------------------------
- /** Path to Castor configuration of core modul. */
+ /** Path to Castor properties of core modul. */
private static final String FILEPATH = "/org/castor/cpa/";
- /** Name of Castor configuration of core modul. */
+ /** Name of Castor properties of core modul. */
private static final String FILENAME = "castor.cpa.properties";
- /** A static configuration instance to be used during migration to a none static one. */
+ /** A static properties instance to be used during migration to a none static one. */
// TODO Remove property after support for static configuration has been terminated.
- private static Configuration _instance = null;
+ private static AbstractProperties _instance = null;
//--------------------------------------------------------------------------
/**
- * Get the one and only static CPA configuration.
+ * Get the one and only static CPA properties.
*
- * @return One and only configuration instance for Castor CPA modul.
- * @deprecated Don't limit your applications flexibility by using a static configuration. Use
- * your own configuration instance created with one of the newInstance() methods
+ * @return One and only properties instance for Castor CPA modul.
+ * @deprecated Don't limit your applications flexibility by using static properties. Use
+ * your own properties instance created with one of the newInstance() methods
* instead.
*/
- // TODO Remove method after support for static configuration has been terminated.
- public static synchronized Configuration getInstance() {
+ // TODO Remove method after support for static properties has been terminated.
+ public static synchronized AbstractProperties getInstance() {
if (_instance == null) { _instance = newInstance(); }
return _instance;
}
/**
- * Factory method for a default CPA configuration instance. Application and domain class
- * loaders will be initialized to the one used to load the Configuration class. The
- * configuration instance returned will be a CastorConfiguration with a CPAConfiguration, a
- * XMLConfiguration and a CoreConfiguration instance as parents. The CastorConfiguration
- * holding user specific properties is the only one that can be modified by put() and remove()
- * methods. CPAConfiguration, XMLConfiguration and CoreConfiguration are responsble to deliver
- * Castor's default values if they have not been overwritten by the user.
+ * Factory method for a default CPA properties instance. Application and domain class
+ * loaders will be initialized to the one used to load this class. The properties instance
+ * returned will be a CastorProperties with a CPAProperties, a XMLProperties and a
+ * CoreProperties instance as parents. The CastorProperties holding user specific properties
+ * is the only one that can be modified by put() and remove() methods. CPAProperties,
+ * XMLProperties and CoreProperties are responsble to deliver Castor's default values if they
+ * have not been overwritten by the user.
*
- * @return Configuration instance for Castor CPA modul.
+ * @return Properties instance for Castor CPA modul.
*/
- public static Configuration newInstance() {
- Configuration core = new CoreConfiguration();
- Configuration cpa = new CPAConfiguration(core);
- Configuration xml = new XMLConfiguration(cpa);
- Configuration castor = new CastorConfiguration(xml);
+ public static AbstractProperties newInstance() {
+ AbstractProperties core = new CoreProperties();
+ AbstractProperties cpa = new CPAProperties(core);
+ AbstractProperties xml = new XMLProperties(cpa);
+ AbstractProperties castor = new CastorProperties(xml);
return castor;
}
/**
- * Factory method for a CPA configuration instance that uses the specified class loaders. The
- * configuration instance returned will be a CastorConfiguration with a CPAConfiguration, a
- * XMLConfiguration and a CoreConfiguration instance as parents. The CastorConfiguration
+ * Factory method for a CPA properties instance that uses the specified class loaders. The
+ * properties instance returned will be a CastorProperties with a CPAProperties, a
+ * XMLProperties and a CoreProperties instance as parents. The CastorProperties
* holding user specific properties is the only one that can be modified by put() and remove()
- * methods. CPAConfiguration, XMLConfiguration and CoreConfiguration are responsble to deliver
+ * methods. CPAProperties, XMLProperties and CoreProperties are responsble to deliver
* Castor's default values if they have not been overwritten by the user.
*
* @param app Classloader to be used for all classes of Castor and its required libraries.
* @param domain Classloader to be used for all domain objects.
- * @return Configuration instance for Castor CPA modul.
+ * @return Properties instance for Castor CPA modul.
*/
- public static Configuration newInstance(final ClassLoader app, final ClassLoader domain) {
- Configuration core = new CoreConfiguration(app, domain);
- Configuration cpa = new CPAConfiguration(core);
- Configuration xml = new XMLConfiguration(cpa);
- Configuration castor = new CastorConfiguration(xml);
+ public static AbstractProperties newInstance(final ClassLoader app, final ClassLoader domain) {
+ AbstractProperties core = new CoreProperties(app, domain);
+ AbstractProperties cpa = new CPAProperties(core);
+ AbstractProperties xml = new XMLProperties(cpa);
+ AbstractProperties castor = new CastorProperties(xml);
return castor;
}
//--------------------------------------------------------------------------
/**
- * Construct a configuration with given parent. Application and domain class loaders will be
+ * Construct properties with given parent. Application and domain class loaders will be
* initialized to the ones of the parent.
*
* Note: This constructor is not intended for public use. Use one of the newInstance() methods
* instead.
*
- * @param parent Parent configuration.
+ * @param parent Parent properties.
*/
- public CPAConfiguration(final Configuration parent) {
+ public CPAProperties(final AbstractProperties parent) {
super(parent);
loadDefaultProperties(FILEPATH, FILENAME);
}
Property changes on: cpa/src/main/java/org/castor/cpa/CPAProperties.java
___________________________________________________________________
Added: svn:mergeinfo
Index: xml/src/main/java/org/exolab/castor/util/ChangeLog2XML.java
===================================================================
--- xml/src/main/java/org/exolab/castor/util/ChangeLog2XML.java (revision 8022)
+++ xml/src/main/java/org/exolab/castor/util/ChangeLog2XML.java (working copy)
@@ -23,7 +23,7 @@
import java.util.ArrayList;
import org.castor.xml.InternalContext;
-import org.castor.xml.XMLConfiguration;
+import org.castor.xml.XMLProperties;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.XMLContext;
@@ -223,7 +223,7 @@
file = new File(DEFAULT_OUTPUT);
FileWriter writer = new FileWriter(file);
- xmlContext.setProperty(XMLConfiguration.USE_INDENTATION, true);
+ xmlContext.setProperty(XMLProperties.USE_INDENTATION, true);
Marshaller marshaller = xmlContext.createMarshaller();
marshaller.setWriter(writer);
Index: cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToString.java
===================================================================
--- cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToString.java (revision 8022)
+++ cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToString.java (working copy)
@@ -15,7 +15,7 @@
*/
package org.castor.cpa.persistence.convertor;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
/**
* Convert Boolean to String.
@@ -47,7 +47,7 @@
/**
* {@inheritDoc}
*/
- public void configure(final Configuration configuration) { }
+ public void configure(final AbstractProperties properties) { }
/**
* {@inheritDoc}
Index: core/src/main/java/org/castor/core/util/ConfigurationException.java
===================================================================
--- core/src/main/java/org/castor/core/util/ConfigurationException.java (revision 8022)
+++ core/src/main/java/org/castor/core/util/ConfigurationException.java (working copy)
@@ -1,71 +0,0 @@
-/*
- * Copyright 2007 Ralf Joachim
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Id: Configuration.java 6907 2007-03-28 21:24:52Z rjoachim $
- */
-package org.castor.core.util;
-
-import org.castor.core.exceptions.CastorRuntimeException;
-
-/**
- * ConfigurationException is an unchecked exception thrown when Configuration can not be loaded
- * or if configuration property can't be converted to the requested type.
- *
- * @version $Id: Configuration.java,v 1.8 2006/03/08 17:25:52 jens Exp $
- * @author Ralf Joachim
- * @since 1.1.3
- */
-public final class ConfigurationException extends CastorRuntimeException {
- /** SerialVersionUID */
- private static final long serialVersionUID = 4446761026170253291L;
-
- /**
- * Constructs a new ConfigurationException without a message. The cause is not initialized
- * but may subsequently be initialized by a call to initCause(Throwable).
- */
- public ConfigurationException() {
- super();
- }
-
- /**
- * Constructs a new ConfigurationException with the specified detail message. The cause is
- * not initialized but may subsequently be initialized by a call to initCause(Throwable).
- *
- * @param message The detail message.
- */
- public ConfigurationException(final String message) {
- super(message);
- }
-
- /**
- * Constructs a new ConfigurationException with the specified cause and the detail message
- * of the cause. This constructor is useful for exceptions that are wrappers for others.
- *
- * @param cause The cause.
- */
- public ConfigurationException(final Throwable cause) {
- super(cause);
- }
-
- /**
- * Constructs a new ConfigurationException with the specified detail message and cause.
- *
- * @param message The detail message.
- * @param cause The cause.
- */
- public ConfigurationException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
Index: cpa/src/main/java/org/castor/jdo/engine/SQLTypeInfos.java
===================================================================
--- cpa/src/main/java/org/castor/jdo/engine/SQLTypeInfos.java (revision 8022)
+++ cpa/src/main/java/org/castor/jdo/engine/SQLTypeInfos.java (working copy)
@@ -32,8 +32,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
import org.exolab.castor.mapping.MappingException;
/**
@@ -124,8 +124,8 @@
private static final TimeZone TIME_ZONE;
static {
- Configuration config = CPAConfiguration.getInstance();
- String zone = config.getString(CPAConfiguration.DEFAULT_TIMEZONE);
+ AbstractProperties properties = CPAProperties.getInstance();
+ String zone = properties.getString(CPAProperties.DEFAULT_TIMEZONE);
if ((zone == null) || (zone.length() == 0)) {
TIME_ZONE = TimeZone.getDefault();
} else {
Index: src/bugs/xml/c1342/Test1342.java
===================================================================
--- src/bugs/xml/c1342/Test1342.java (revision 8022)
+++ src/bugs/xml/c1342/Test1342.java (working copy)
@@ -6,7 +6,7 @@
import junit.framework.TestCase;
import net.sf.cglib.proxy.Factory;
-import org.castor.xml.XMLConfiguration;
+import org.castor.xml.XMLProperties;
import org.exolab.castor.mapping.Mapping;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
@@ -145,7 +145,7 @@
*/
public void testMarshalSimpleBeanProxy() throws Exception {
XMLContext xmlContext = new XMLContext();
- xmlContext.setProperty(XMLConfiguration.PROXY_INTERFACES, "net.sf.cglib.proxy.Factory");
+ xmlContext.setProperty(XMLProperties.PROXY_INTERFACES, "net.sf.cglib.proxy.Factory");
Mapping mapping = xmlContext.createMapping();
mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm());
@@ -199,7 +199,7 @@
*/
public void testMarshalReferingBeanProxy() throws Exception {
XMLContext xmlContext = new XMLContext();
- xmlContext.setProperty(XMLConfiguration.PROXY_INTERFACES, "net.sf.cglib.proxy.Factory");
+ xmlContext.setProperty(XMLProperties.PROXY_INTERFACES, "net.sf.cglib.proxy.Factory");
Mapping mapping = xmlContext.createMapping();
mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm());
Index: xml/src/main/java/org/exolab/castor/mapping/loader/CollectionHandlers.java
===================================================================
--- xml/src/main/java/org/exolab/castor/mapping/loader/CollectionHandlers.java (revision 8022)
+++ xml/src/main/java/org/exolab/castor/mapping/loader/CollectionHandlers.java (working copy)
@@ -54,8 +54,8 @@
import java.util.StringTokenizer;
import java.util.Vector;
-import org.castor.core.util.Configuration;
-import org.castor.xml.XMLConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.xml.XMLProperties;
import org.exolab.castor.mapping.CollectionHandler;
import org.exolab.castor.mapping.MappingException;
@@ -251,8 +251,8 @@
Method method;
allInfo = new Vector();
- Configuration configuration = XMLConfiguration.newInstance();
- tokenizer = new StringTokenizer(configuration.getString(XMLConfiguration.COLLECTION_HANDLERS_FOR_JAVA_11_OR_12, ""), ", ");
+ AbstractProperties properties = XMLProperties.newInstance();
+ tokenizer = new StringTokenizer(properties.getString(XMLProperties.COLLECTION_HANDLERS_FOR_JAVA_11_OR_12, ""), ", ");
// Joachim 2007-09-01 old local configuration is dead!
// LocalConfiguration config = LocalConfiguration.getInstance();
// tokenizer = new StringTokenizer( config.getProperty( "org.exolab.castor.mapping.collections", "" ), ", " );
Index: xml/src/test/java/org/castor/xml/XMLPropertiesTest.java
===================================================================
--- xml/src/test/java/org/castor/xml/XMLPropertiesTest.java (revision 8022)
+++ xml/src/test/java/org/castor/xml/XMLPropertiesTest.java (working copy)
@@ -15,61 +15,57 @@
*/
package org.castor.xml;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
import junit.framework.Assert;
import junit.framework.TestCase;
/**
- * The XMLConfiguration test has one goal - check if the proper defaults
+ * The XMLProperties test has one goal - check if the proper defaults
* are in place.
*
* @author Joachim Grueneis, jgrueneis_at_gmail_dot_com
* @version $Id$
*/
-public class XMLConfigurationTest extends TestCase {
- private static final Log LOG = LogFactory.getLog(XMLConfigurationTest.class);
+public class XMLPropertiesTest extends TestCase {
+ private AbstractProperties _properties;
- private Configuration _configuration;
-
- public XMLConfigurationTest(final String name) {
+ public XMLPropertiesTest(final String name) {
super(name);
}
public void setUp() {
- _configuration = XMLConfiguration.newInstance();
+ _properties = XMLProperties.newInstance();
Assert.assertNotNull(
- "Configuration must exist after call to newInstance()", _configuration);
+ "Properties must exist after call to newInstance()", _properties);
Assert.assertNotNull(
"Application class loader must not be null",
- _configuration.getApplicationClassLoader());
+ _properties.getApplicationClassLoader());
Assert.assertNotNull(
"Domain class loader must not be null",
- _configuration.getDomainClassLoader());
+ _properties.getDomainClassLoader());
}
public void testNewInstanceClassLoaderClassLoader() {
- Configuration c = XMLConfiguration.newInstance(null, null);
+ AbstractProperties properties = XMLProperties.newInstance(null, null);
Assert.assertNotNull(
- "Configuration must exist after call to newInstance()", c);
+ "Properties must exist after call to newInstance()", properties);
// Assert.assertNotNull(
// "Application class loader must not be null",
-// c.getApplicationClassLoader());
+// properties.getApplicationClassLoader());
// Assert.assertNotNull(
// "Domain class loader must not be null",
-// c.getDomainClassLoader());
+// properties.getDomainClassLoader());
}
public void testGetBooleanString() {
- Boolean notExistingProperty = _configuration.getBoolean("Something which doesn't exist");
+ Boolean notExistingProperty = _properties.getBoolean("Something which doesn't exist");
Assert.assertNull("A not existing property needs to return null", notExistingProperty);
}
public void testGetBooleanStringBoolean() {
boolean notExistingPropertyWithDefault =
- _configuration.getBoolean("Something which doesn't exist", true);
+ _properties.getBoolean("Something which doesn't exist", true);
Assert.assertTrue(
"A not existing property with default true",
notExistingPropertyWithDefault);
@@ -80,25 +76,25 @@
*/
public void testDefaults() {
Boolean loadPackageMapping =
- _configuration.getBoolean(XMLConfiguration.LOAD_PACKAGE_MAPPING);
+ _properties.getBoolean(XMLProperties.LOAD_PACKAGE_MAPPING);
Assert.assertEquals(
"load package mapping is expected to be set to: true",
Boolean.TRUE, loadPackageMapping);
- String serialzierFactory = _configuration.getString(XMLConfiguration.SERIALIZER_FACTORY);
+ String serialzierFactory = _properties.getString(XMLProperties.SERIALIZER_FACTORY);
Assert.assertEquals(
"check serializer factory default",
"org.exolab.castor.xml.XercesJDK5XMLSerializerFactory",
serialzierFactory);
- Boolean strictElements = _configuration.getBoolean(XMLConfiguration.STRICT_ELEMENTS);
+ Boolean strictElements = _properties.getBoolean(XMLProperties.STRICT_ELEMENTS);
Assert.assertEquals("strict elements default", Boolean.FALSE, strictElements);
Boolean marshallingValidation =
- _configuration.getBoolean(XMLConfiguration.MARSHALLING_VALIDATION);
+ _properties.getBoolean(XMLProperties.MARSHALLING_VALIDATION);
Assert.assertEquals("marshallingValidation", Boolean.TRUE, marshallingValidation);
- Boolean useIntrospection = _configuration.getBoolean(XMLConfiguration.USE_INTROSPECTION);
+ Boolean useIntrospection = _properties.getBoolean(XMLProperties.USE_INTROSPECTION);
Assert.assertEquals("useIntrospection", Boolean.TRUE, useIntrospection);
}
}
Property changes on: xml/src/test/java/org/castor/xml/XMLPropertiesTest.java
___________________________________________________________________
Added: svn:mergeinfo
Index: xml/src/test/java/org/exolab/castor/xml/TestUnmarshaller.java
===================================================================
--- xml/src/test/java/org/exolab/castor/xml/TestUnmarshaller.java (revision 8022)
+++ xml/src/test/java/org/exolab/castor/xml/TestUnmarshaller.java (working copy)
@@ -22,7 +22,7 @@
import junit.framework.TestCase;
import org.castor.xml.InternalContext;
-import org.castor.xml.XMLConfiguration;
+import org.castor.xml.XMLProperties;
/**
* Test case for testing various pieces of functionality of {@link Unmarshaller}.
@@ -61,14 +61,14 @@
assertNotNull(unmarshaller);
String lenientSequenceValidation =
- unmarshaller.getProperty(XMLConfiguration.LENIENT_SEQUENCE_ORDER);
+ unmarshaller.getProperty(XMLProperties.LENIENT_SEQUENCE_ORDER);
assertNotNull(lenientSequenceValidation);
assertEquals("false", lenientSequenceValidation);
- unmarshaller.setProperty(XMLConfiguration.LENIENT_SEQUENCE_ORDER, "true");
+ unmarshaller.setProperty(XMLProperties.LENIENT_SEQUENCE_ORDER, "true");
lenientSequenceValidation =
- unmarshaller.getProperty(XMLConfiguration.LENIENT_SEQUENCE_ORDER);
+ unmarshaller.getProperty(XMLProperties.LENIENT_SEQUENCE_ORDER);
assertNotNull(lenientSequenceValidation);
assertEquals("true", lenientSequenceValidation);
}
Index: cpa/src/test/java/org/castor/transactionmanager/TestTransactionManagerFactoryRegistry.java
===================================================================
--- cpa/src/test/java/org/castor/transactionmanager/TestTransactionManagerFactoryRegistry.java (revision 8022)
+++ cpa/src/test/java/org/castor/transactionmanager/TestTransactionManagerFactoryRegistry.java (working copy)
@@ -21,8 +21,8 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
/**
* @author Ralf Joachim
@@ -49,18 +49,18 @@
if (DISABLE_LOGGING) { logger.setLevel(Level.FATAL); }
assertEquals("org.castor.transactionmanager.Factories",
- CPAConfiguration.TRANSACTION_MANAGER_FACTORIES);
+ CPAProperties.TRANSACTION_MANAGER_FACTORIES);
Object temp = new TransactionManagerFactoryDummy();
- Configuration config = CPAConfiguration.newInstance();
- Object mem = config.getObject(CPAConfiguration.TRANSACTION_MANAGER_FACTORIES);
- config.put(CPAConfiguration.TRANSACTION_MANAGER_FACTORIES,
+ AbstractProperties properties = CPAProperties.newInstance();
+ Object mem = properties.getObject(CPAProperties.TRANSACTION_MANAGER_FACTORIES);
+ properties.put(CPAProperties.TRANSACTION_MANAGER_FACTORIES,
"org.castor.transactionmanager.LocalTransactionManagerFactory, "
+ TransactionManagerFactoryDummy.class.getName());
TransactionManagerFactoryRegistry registry;
- registry = new TransactionManagerFactoryRegistry(config);
+ registry = new TransactionManagerFactoryRegistry(properties);
String[] names = registry.getTransactionManagerFactoryNames();
assertEquals(2, names.length);
@@ -83,7 +83,7 @@
fail("Unexpected TransactionManagerAcquireException.");
}
- config.put(CPAConfiguration.TRANSACTION_MANAGER_FACTORIES, mem);
+ properties.put(CPAProperties.TRANSACTION_MANAGER_FACTORIES, mem);
logger.setLevel(level);
}
Index: cpactf/src/test/java/org/castor/cpa/test/test954/Test954.java
===================================================================
--- cpactf/src/test/java/org/castor/cpa/test/test954/Test954.java (revision 8026)
+++ cpactf/src/test/java/org/castor/cpa/test/test954/Test954.java (working copy)
@@ -26,8 +26,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
import org.castor.cpa.test.framework.CPATestCase;
import org.castor.cpa.test.framework.xml.types.DatabaseEngineType;
import org.castor.jdo.conf.JdoConf;
@@ -75,8 +75,8 @@
protected void setUp() throws Exception {
super.setUp();
- Configuration cfg = getConfiguration();
- boolean useProxies = cfg.getBoolean(CPAConfiguration.USE_JDBC_PROXIES, true);
+ AbstractProperties properties = getProperties();
+ boolean useProxies = properties.getBoolean(CPAProperties.USE_JDBC_PROXIES, true);
AbstractConnectionFactory factory = null;
Index: cpa/src/main/java/org/castor/cpa/persistence/convertor/AbstractDateTypeConvertor.java
===================================================================
--- cpa/src/main/java/org/castor/cpa/persistence/convertor/AbstractDateTypeConvertor.java (revision 8022)
+++ cpa/src/main/java/org/castor/cpa/persistence/convertor/AbstractDateTypeConvertor.java (working copy)
@@ -17,7 +17,7 @@
import java.text.SimpleDateFormat;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
/**
* Abstract base class to convert from one type to another without any configuration
@@ -93,7 +93,7 @@
/**
* {@inheritDoc}
*/
- public final void configure(final Configuration configuration) { }
+ public final void configure(final AbstractProperties properties) { }
//-----------------------------------------------------------------------------------
}
Index: xml/src/main/java/org/exolab/castor/xml/Introspector.java
===================================================================
--- xml/src/main/java/org/exolab/castor/xml/Introspector.java (revision 8022)
+++ xml/src/main/java/org/exolab/castor/xml/Introspector.java (working copy)
@@ -56,7 +56,7 @@
import org.castor.xml.InternalContext;
import org.castor.xml.JavaNaming;
-import org.castor.xml.XMLConfiguration;
+import org.castor.xml.XMLProperties;
import org.castor.xml.XMLNaming;
import org.exolab.castor.mapping.CollectionHandler;
import org.exolab.castor.mapping.FieldHandler;
@@ -221,9 +221,9 @@
_javaNaming = _internalContext.getJavaNaming();
_xmlNaming = _internalContext.getXMLNaming();
setPrimitiveNodeType(_internalContext.getPrimitiveNodeType());
- _wrapCollectionsInContainer = _internalContext.getBooleanProperty(XMLConfiguration.WRAP_COLLECTIONS_PROPERTY).booleanValue();
+ _wrapCollectionsInContainer = _internalContext.getBooleanProperty(XMLProperties.WRAP_COLLECTIONS_PROPERTY).booleanValue();
_saveMapKeys =
- _internalContext.getBooleanProperty(XMLConfiguration.SAVE_MAP_KEYS).booleanValue();
+ _internalContext.getBooleanProperty(XMLProperties.SAVE_MAP_KEYS).booleanValue();
}
} //-- init
Index: cpactf/src/old/java/ctf/jdo/tc0x/TestSynchronizable.java
===================================================================
--- cpactf/src/old/java/ctf/jdo/tc0x/TestSynchronizable.java (revision 8022)
+++ cpactf/src/old/java/ctf/jdo/tc0x/TestSynchronizable.java (working copy)
@@ -51,15 +51,15 @@
import jdo.JDOCategory;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
import org.exolab.castor.jdo.Database;
import org.exolab.castor.jdo.OQLQuery;
import org.exolab.castor.jdo.PersistenceException;
import org.exolab.castor.jdo.QueryResults;
public final class TestSynchronizable extends CastorTestCase {
- private static ArrayList _synchronizables = new ArrayList();
+ private static ArrayList _synchronizables = new ArrayList();
private JDOCategory _category;
private Database _db;
@@ -85,9 +85,9 @@
* Get a JDO database
*/
public void setUp() throws PersistenceException, SQLException {
- Configuration config = CPAConfiguration.getInstance();
- _oldProperty = config.getObject(CPAConfiguration.TX_SYNCHRONIZABLE);
- config.put(CPAConfiguration.TX_SYNCHRONIZABLE, SynchronizableImpl.class.getName());
+ AbstractProperties properties = CPAProperties.getInstance();
+ _oldProperty = properties.getObject(CPAProperties.TX_SYNCHRONIZABLE);
+ properties.put(CPAProperties.TX_SYNCHRONIZABLE, SynchronizableImpl.class.getName());
_db = _category.getDatabase();
}
@@ -160,11 +160,11 @@
_synchronizables.clear();
_db.close();
- Configuration config = CPAConfiguration.getInstance();
+ AbstractProperties properties = CPAProperties.getInstance();
if (_oldProperty != null) {
- config.put(CPAConfiguration.TX_SYNCHRONIZABLE, _oldProperty);
+ properties.put(CPAProperties.TX_SYNCHRONIZABLE, _oldProperty);
} else {
- config.remove(CPAConfiguration.TX_SYNCHRONIZABLE);
+ properties.remove(CPAProperties.TX_SYNCHRONIZABLE);
}
}
}
Index: core/src/main/java/org/castor/core/util/CastorConfiguration.java
===================================================================
--- core/src/main/java/org/castor/core/util/CastorConfiguration.java (revision 8022)
+++ core/src/main/java/org/castor/core/util/CastorConfiguration.java (working copy)
@@ -1,51 +0,0 @@
-/*
- * Copyright 2007 Ralf Joachim
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Id: Configuration.java 6907 2007-03-28 21:24:52Z rjoachim $
- */
-package org.castor.core.util;
-
-
-/**
- * Castor configuration holding user properties.
- *
- * @version $Id: Configuration.java,v 1.8 2006/03/08 17:25:52 jens Exp $
- * @author Ralf Joachim
- * @since 1.1.3
- */
-public final class CastorConfiguration extends Configuration {
- //--------------------------------------------------------------------------
-
- /** Name of common Castor configuration file. */
- private static final String FILENAME = "castor.properties";
-
- //--------------------------------------------------------------------------
-
- /**
- * Construct a configuration with given parent. Application and domain class loaders will be
- * initialized to the ones of the parent.
- *
- * Note: This constructor is not intended for public use. Use one of the newInstance() methods
- * instead.
- *
- * @param parent Parent configuration.
- */
- public CastorConfiguration(final Configuration parent) {
- super(parent);
- loadUserProperties(FILENAME);
- }
-
- //--------------------------------------------------------------------------
-}
Index: cpa/src/main/java/org/castor/jdo/engine/DatabaseRegistry.java
===================================================================
--- cpa/src/main/java/org/castor/jdo/engine/DatabaseRegistry.java (revision 8022)
+++ cpa/src/main/java/org/castor/jdo/engine/DatabaseRegistry.java (working copy)
@@ -22,9 +22,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
import org.castor.core.util.Messages;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.cpa.CPAProperties;
import org.castor.jdo.conf.Database;
import org.castor.jdo.conf.DatabaseChoice;
import org.castor.jdo.conf.JdoConf;
@@ -168,8 +168,8 @@
throws MappingException {
// Do we need to initialize database now or should we
// wait until we want to use it.
- Configuration cfg = CPAConfiguration.getInstance();
- boolean init = cfg.getBoolean(CPAConfiguration.INITIALIZE_AT_LOAD, true);
+ AbstractProperties properties = CPAProperties.getInstance();
+ boolean init = properties.getBoolean(CPAProperties.INITIALIZE_AT_LOAD, true);
// Load the JDO configuration file from the specified input source.
// databases = JDOConfLoader.getDatabases(baseURI, resolver);
Index: xml/src/main/java/org/castor/mapping/MappingLoaderRegistry.java
===================================================================
--- xml/src/main/java/org/castor/mapping/MappingLoaderRegistry.java (revision 8022)
+++ xml/src/main/java/org/castor/mapping/MappingLoaderRegistry.java (working copy)
@@ -23,8 +23,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.CoreConfiguration;
-import org.castor.core.util.Configuration;
+import org.castor.core.CoreProperties;
+import org.castor.core.util.AbstractProperties;
import org.exolab.castor.mapping.MappingException;
import org.exolab.castor.mapping.MappingLoader;
@@ -48,11 +48,11 @@
/**
* Creates an instance of this registry, loading the mapping loader
* factories from the castor.properties file.
- * @param config Configuration.
+ * @param properties Properties.
*/
- public MappingLoaderRegistry(final Configuration config) {
- Object[] objects = config.getObjectArray(
- CoreConfiguration.MAPPING_LOADER_FACTORIES, getClass().getClassLoader());
+ public MappingLoaderRegistry(final AbstractProperties properties) {
+ Object[] objects = properties.getObjectArray(
+ CoreProperties.MAPPING_LOADER_FACTORIES, getClass().getClassLoader());
for (int i = 0; i < objects.length; i++) {
_mappingLoaderFactories.add(objects[i]);
}
Index: core/src/main/java/org/castor/core/util/PropertiesException.java
===================================================================
--- core/src/main/java/org/castor/core/util/PropertiesException.java (revision 8022)
+++ core/src/main/java/org/castor/core/util/PropertiesException.java (working copy)
@@ -20,52 +20,52 @@
import org.castor.core.exceptions.CastorRuntimeException;
/**
- * ConfigurationException is an unchecked exception thrown when Configuration can not be loaded
+ * PropertiesException is an unchecked exception thrown when properties can not be loaded
* or if configuration property can't be converted to the requested type.
*
* @version $Id: Configuration.java,v 1.8 2006/03/08 17:25:52 jens Exp $
* @author Ralf Joachim
* @since 1.1.3
*/
-public final class ConfigurationException extends CastorRuntimeException {
+public final class PropertiesException extends CastorRuntimeException {
/** SerialVersionUID */
private static final long serialVersionUID = 4446761026170253291L;
/**
- * Constructs a new ConfigurationException without a message. The cause is not initialized
+ * Constructs a new PropertiesException without a message. The cause is not initialized
* but may subsequently be initialized by a call to initCause(Throwable).
*/
- public ConfigurationException() {
+ public PropertiesException() {
super();
}
/**
- * Constructs a new ConfigurationException with the specified detail message. The cause is
+ * Constructs a new PropertiesException with the specified detail message. The cause is
* not initialized but may subsequently be initialized by a call to initCause(Throwable).
*
* @param message The detail message.
*/
- public ConfigurationException(final String message) {
+ public PropertiesException(final String message) {
super(message);
}
/**
- * Constructs a new ConfigurationException with the specified cause and the detail message
+ * Constructs a new PropertiesException with the specified cause and the detail message
* of the cause. This constructor is useful for exceptions that are wrappers for others.
*
* @param cause The cause.
*/
- public ConfigurationException(final Throwable cause) {
+ public PropertiesException(final Throwable cause) {
super(cause);
}
/**
- * Constructs a new ConfigurationException with the specified detail message and cause.
+ * Constructs a new PropertiesException with the specified detail message and cause.
*
* @param message The detail message.
* @param cause The cause.
*/
- public ConfigurationException(final String message, final Throwable cause) {
+ public PropertiesException(final String message, final Throwable cause) {
super(message, cause);
}
}
Property changes on: core/src/main/java/org/castor/core/util/PropertiesException.java
___________________________________________________________________
Added: svn:mergeinfo
Index: xml/src/main/java/org/exolab/castor/xml/util/XMLParserUtils.java
===================================================================
--- xml/src/main/java/org/exolab/castor/xml/util/XMLParserUtils.java (revision 8022)
+++ xml/src/main/java/org/exolab/castor/xml/util/XMLParserUtils.java (working copy)
@@ -8,9 +8,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
import org.castor.core.util.Messages;
-import org.castor.xml.XMLConfiguration;
+import org.castor.xml.XMLProperties;
import org.exolab.castor.xml.OutputFormat;
import org.exolab.castor.xml.Serializer;
import org.exolab.castor.xml.XMLSerializerFactory;
@@ -177,13 +177,14 @@
return parser;
}
- public static Parser getParser(final Configuration configuration, final String features) {
+ public static Parser getParser(final AbstractProperties properties, final String features) {
Parser parser = null;
- Boolean validation = configuration.getBoolean(XMLConfiguration.PARSER_VALIDATION);
- Boolean namespaces = configuration.getBoolean(XMLConfiguration.NAMESPACES);
- String parserClassName = configuration.getString(XMLConfiguration.PARSER);
+ Boolean validation = properties.getBoolean(XMLProperties.PARSER_VALIDATION);
+ Boolean namespaces = properties.getBoolean(XMLProperties.NAMESPACES);
+ String parserClassName = properties.getString(XMLProperties.PARSER);
if ((parserClassName == null) || (parserClassName.length() == 0)) {
- SAXParser saxParser = XMLParserUtils.getSAXParser(validation.booleanValue(), namespaces.booleanValue());
+ SAXParser saxParser = XMLParserUtils.getSAXParser(
+ validation.booleanValue(), namespaces.booleanValue());
if (saxParser != null) {
try {
parser = saxParser.getParser();
@@ -206,8 +207,8 @@
if (parser instanceof XMLReader) {
XMLReader xmlReader = (XMLReader) parser;
XMLParserUtils.setFeaturesOnXmlReader(
- configuration.getString(XMLConfiguration.PARSER_FEATURES, features),
- configuration.getString(XMLConfiguration.PARSER_FEATURES_DISABLED, ""),
+ properties.getString(XMLProperties.PARSER_FEATURES, features),
+ properties.getString(XMLProperties.PARSER_FEATURES_DISABLED, ""),
validation.booleanValue(),
namespaces.booleanValue(),
xmlReader);
@@ -219,25 +220,22 @@
/**
* @see org.castor.xml.InternalContext#getSerializer()
*/
- public static Serializer getSerializer(final Configuration configuration) {
+ public static Serializer getSerializer(final AbstractProperties properties) {
Serializer serializer = getSerializerFactory(
- configuration.getString(
- XMLConfiguration.SERIALIZER_FACTORY)).getSerializer();
- serializer.setOutputFormat(getOutputFormat(configuration));
+ properties.getString(XMLProperties.SERIALIZER_FACTORY)).getSerializer();
+ serializer.setOutputFormat(getOutputFormat(properties));
return serializer;
}
/**
* @see org.castor.xml.InternalContext#getOutputFormat()
*/
- public static OutputFormat getOutputFormat(final Configuration configuration) {
+ public static OutputFormat getOutputFormat(final AbstractProperties properties) {
- boolean indent = configuration.getBoolean(XMLConfiguration.USE_INDENTATION, false);
+ boolean indent = properties.getBoolean(XMLProperties.USE_INDENTATION, false);
OutputFormat format = getSerializerFactory(
- configuration.getString(
- XMLConfiguration.SERIALIZER_FACTORY))
- .getOutputFormat();
+ properties.getString(XMLProperties.SERIALIZER_FACTORY)).getOutputFormat();
format.setMethod(OutputFormat.XML);
format.setIndenting(indent);
Index: src/doc/release-notes.xml
===================================================================
--- src/doc/release-notes.xml (revision 8032)
+++ src/doc/release-notes.xml (working copy)
@@ -63,7 +63,7 @@
- To specify the location of a Castor XM property file by using + To specify the location of a Castor XML property file by using a system property, please use ....
@@ -73,6 +73,27 @@String to Boolean.
@@ -47,7 +47,7 @@
/**
* {@inheritDoc}
*/
- public void configure(final Configuration configuration) { }
+ public void configure(final AbstractProperties properties) { }
/**
* {@inheritDoc}
Index: core/src/main/java/org/castor/core/util/Configuration.java
===================================================================
--- core/src/main/java/org/castor/core/util/Configuration.java (revision 8022)
+++ core/src/main/java/org/castor/core/util/Configuration.java (working copy)
@@ -1,728 +0,0 @@
-/*
- * Copyright 2007 Ralf Joachim
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Id: Configuration.java 6907 2007-03-28 21:24:52Z rjoachim $
- */
-package org.castor.core.util;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Abstract base class to hold Castor configuration properties.
- *
- * @version $Id: Configuration.java,v 1.8 2006/03/08 17:25:52 jens Exp $
- * @author Ralf Joachim
- * @since 1.1.3
- */
-public abstract class Configuration {
-
- /**
- * Name of the system property that can be used to specify the location
- * of user properties.
- */
- private static final String USER_PROPERTIES_SYSTEM_PROPERTY =
- "org.castor.user.properties.location";
-
- /**
- * The Jakarta Commons
- * Logging instance used for all logging.
- */
- private static final Log LOG = LogFactory.getLog(Configuration.class);
-
- /**
- * {@link ClassLoader} to be used for all classes of Castor and its required
- * libraries.
- */
- private final ClassLoader _applicationClassLoader;
-
- /**
- * {@link ClassLoader} to be used for all domain objects that are
- * marshalled/unmarshalled or loaded from the database.
- */
- private final ClassLoader _domainClassLoader;
-
- /**
- * Parent configuration.
- */
- private final Configuration _parent;
-
- private final Map _map = new HashMap();
-
- /**
- * Default constructor. Application and domain class loaders will be initialized to the one
- * used to load the Configuration class. No parent configuration will be set.
- */
- protected Configuration() {
- this(null, null);
- }
-
- /**
- * Construct a configuration that uses the specified class loaders. No parent configuration
- * will be set.
- *
- * @param app Classloader to be used for all classes of Castor and its required libraries.
- * @param domain Classloader to be used for all domain objects.
- */
- protected Configuration(final ClassLoader app, final ClassLoader domain) {
- _applicationClassLoader = (app != null) ? app : getClass().getClassLoader();
- _domainClassLoader = (domain != null) ? domain : getClass().getClassLoader();
-
- _parent = null;
- }
-
- /**
- * Construct a configuration with given parent. Application and domain class loaders will be
- * initialized to the ones of the parent.
- *
- * @param parent Parent configuration.
- */
- protected Configuration(final Configuration parent) {
- _applicationClassLoader = parent.getApplicationClassLoader();
- _domainClassLoader = parent.getDomainClassLoader();
-
- _parent = parent;
- }
-
- /**
- * Get classloader to be used for all classes of Castor and its required libraries.
- *
- * @return Classloader to be used for all classes of Castor and its required libraries.
- */
- public final ClassLoader getApplicationClassLoader() {
- return _applicationClassLoader;
- }
-
- /**
- * Get classloader to be used for all domain objects that are marshalled/unmarshalled or
- * loaded from the database.
- *
- * @return Classloader to be used for all domain objects.
- */
- public final ClassLoader getDomainClassLoader() {
- return _domainClassLoader;
- }
-
- /**
- * Load module configuration from default locations.
- * true if properties could be loaded, false otherwise.
- */
- private boolean loadFromClassPath(final Properties properties, final String filename) {
- InputStream classPathStream = null;
- try {
- URL url = getClass().getResource(filename);
- if (url != null) {
- classPathStream = url.openStream();
- properties.load(classPathStream);
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Configuration loaded from classpath: " + filename);
- }
-
- return true;
- }
- return false;
- } catch (Exception ex) {
- LOG.warn("Failed to load configuration from classpath: " + filename, ex);
- return false;
- } finally {
- if (classPathStream != null) {
- try {
- classPathStream.close();
- } catch (IOException e) {
- LOG.warn("Failed to close configuration from classpath: " + filename);
- }
- }
- }
- }
-
- /**
- * Load properties with given filename from Java library directory and merge them into
- * the given properties.
- *
- * @param properties Properties to merge the loaded ones into.
- * @param filename Name of the properties file to load from Java library directory.
- * @return true if properties could be loaded, false otherwise.
- */
- private boolean loadFromJavaHome(final Properties properties, final String filename) {
- try {
- String javaHome = System.getProperty("java.home");
- if (javaHome == null) { return false; }
- return loadFromFile(properties, new File(new File(javaHome, "lib"), filename));
- } catch (SecurityException ex) {
- LOG.warn("Security policy prevented access to system property 'java.home'.", ex);
- return false;
- }
- }
-
- /**
- * Load properties with given filename from local working directory and merge them into
- * the given properties.
- *
- * @param properties Properties to merge the loaded ones into.
- * @param filename Name of the properties file to load from local working directory.
- * @return true if properties could be loaded, false otherwise.
- */
- private boolean loadFromWorkingDirectory(final Properties properties, final String filename) {
- return loadFromFile(properties, new File(filename));
- }
-
- /**
- * Load properties with given file and merge them into the given properties.
- *
- * @param properties Properties to merge the loaded ones into.
- * @param file Properties file to load.
- * @return true if properties could be loaded, false otherwise.
- */
- private boolean loadFromFile(final Properties properties, final File file) {
- InputStream fileStream = null;
- try {
- if (file.exists() && file.canRead()) {
- fileStream = new FileInputStream(file);
- properties.load(fileStream);
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Configuration file loaded: " + file);
- }
-
- return true;
- }
- return false;
- } catch (SecurityException ex) {
- LOG.warn("Security policy prevented access to configuration file: " + file, ex);
- return false;
- } catch (Exception ex) {
- LOG.warn("Failed to load configuration file: " + file, ex);
- return false;
- } finally {
- if (fileStream != null) {
- try {
- fileStream.close();
- } catch (IOException e) {
- LOG.warn("Failed to close configuration file: " + file);
- }
- }
- }
- }
-
- /**
- * Put given value associated with given key into the properties map of this configuration. If
- * the configuration previously associated the key to another value the previous value will be
- * returned. If a mapping for the key previously exist in the parent configuration only, the
- * method returns null and not the value of the parent. This allows to distingush
- * if the mapping existed in this configuration or one of its parents.
- * NullPointerException will be thrown if the given value is
- * null.
- *
- * @param key Key of the property to put into configuration.
- * @param value Value to put into configuration associated with the given key..
- * @return Object in this configuration that previously has been associated with the given key.
- */
- public final synchronized Object put(final String key, final Object value) {
- if (value == null) { throw new NullPointerException(); }
- return _map.put(key, value);
- }
-
- /**
- * Remove any value previously associated with the given key from this configuration. The value
- * previously associated with the key int this configuration will be returned. If a mapping
- * for the key existed in the parent configuration only, the method returns null
- * and not the value of the parent. This allows to distingush if the mapping existed in this
- * configuration or one of its parents.
- * null as one of the parents may still contain a mapping for the key that
- * was hidden by the mapping in this configuration.
- *
- * @param key Key of the property to remove from configuration.
- * @return Object in this configuration that previously has been associated with the given key.
- */
- public final synchronized Object remove(final String key) {
- return _map.remove(key);
- }
-
- /**
- * Searches for the property with the specified key in this property map. If the key is not
- * found in this property map, the parent property map, and its parents, recursively, are then
- * checked.
- * null will be returned.
- *
- * @param key Key of the property to get from configuration.
- * @return Object in this property map with the specified key value.
- */
- protected synchronized Object get(final String key) {
- Object value = _map.get(key);
- if ((value == null) && (_parent != null)) {
- value = _parent.get(key);
- }
- return value;
- }
-
- /**
- * Searches for the property with the specified key in this property map. If the key is not
- * found in this property map, the parent property map, and its parents, recursively, are then
- * checked.
- * null will be returned. For all other types and
- * string values a ConfigurationException will be thrown. This behaviour is intended for those
- * usecases that need distinguish between values that are missconfigured or not specified at
- * all.
- *
- * @param key Property key.
- * @return Boolean value in this property map with the specified key value.
- */
- public final Boolean getBoolean(final String key) {
- Object objectValue = get(key);
-
- if (objectValue == null) {
- return null;
- } else if (objectValue instanceof Boolean) {
- return (Boolean) objectValue;
- } else if (objectValue instanceof String) {
- String stringValue = (String) objectValue;
- if ("true".equalsIgnoreCase(stringValue)) {
- return Boolean.TRUE;
- } else if ("false".equalsIgnoreCase(stringValue)) {
- return Boolean.FALSE;
- }
- }
-
- Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value can not be converted to boolean: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
- }
-
- /**
- * Searches for the property with the specified key in this property map. If the key is not
- * found in this property map, the parent property map, and its parents, recursively, are then
- * checked.
- * null will be returned. For all other types and
- * string values a ConfigurationException will be thrown. This behaviour is intended for those
- * usecases that need distinguish between values that are missconfigured or not specified at
- * all.
- *
- * @param key Property key.
- * @return Integer value in this property map with the specified key value.
- */
- public final Integer getInteger(final String key) {
- Object objectValue = get(key);
-
- if (objectValue == null) {
- return null;
- } else if (objectValue instanceof Integer) {
- return (Integer) objectValue;
- } else if (objectValue instanceof String) {
- try {
- return Integer.valueOf((String) objectValue);
- } catch (NumberFormatException ex) {
- Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value can not be converted to int: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
- }
- }
-
- Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value can not be converted to int: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
- }
-
- /**
- * Searches for the property with the specified key in this property map. If the key is not
- * found in this property map, the parent property map, and its parents, recursively, are then
- * checked.
- * null will be returned. For all other types a ConfigurationException will be
- * thrown.
- *
- * @param key Property key.
- * @return String value in this property map with the specified key value.
- */
- public final String getString(final String key) {
- Object objectValue = get(key);
-
- if (objectValue == null) {
- return null;
- } else if (objectValue instanceof String) {
- return (String) objectValue;
- }
-
- Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value is not a string: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
- }
-
- /**
- * Searches for the property with the specified key in this property map. If the key is not
- * found in this property map, the parent property map, and its parents, recursively, are then
- * checked.
- * null will be returned. For all other
- * types a ConfigurationException will be thrown.
- *
- * @param key Property key.
- * @return String array in this property map with the specified key value.
- */
- public final String[] getStringArray(final String key) {
- Object objectValue = get(key);
-
- if (objectValue == null) {
- return null;
- } else if (objectValue instanceof String[]) {
- return (String[]) objectValue;
- } else if (objectValue instanceof String) {
- return ((String) objectValue).split(",");
- }
-
- Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value is not a String[]: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
- }
-
- /**
- * Searches for the property with the specified key in this property map. If the key is not
- * found in this property map, the parent property map, and its parents, recursively, are then
- * checked.
- * null will be returned. For all other types and if loading of the
- * class fails a ConfigurationException will be thrown.
- *
- * @param key Property key.
- * @param loader Class loader to load classes with.
- * @return Class in this property map with the specified key value.
- */
- public final Class getClass(final String key, final ClassLoader loader) {
- Object objectValue = get(key);
-
- if (objectValue == null) {
- return null;
- } else if (objectValue instanceof Class) {
- return (Class) objectValue;
- } else if (objectValue instanceof String) {
- String classname = (String) objectValue;
- try {
- return loader.loadClass(classname);
- } catch (ClassNotFoundException ex) {
- Object[] args = new Object[] {key, classname};
- String msg = "Could not find class of configuration value: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
- }
- }
-
- Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value is not a Class: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
- }
-
- /**
- * Searches for the property with the specified key in this property map. If the key is not
- * found in this property map, the parent property map, and its parents, recursively, are then
- * checked.
- * null will be returned. For all other
- * types and if loading of one of the classes fails a ConfigurationException will be thrown.
- *
- * @param key Property key.
- * @param loader Class loader to load classes with.
- * @return Class array in this property map with the specified key value.
- */
- public final Class[] getClassArray(final String key, final ClassLoader loader) {
- Object objectValue = get(key);
-
- if (objectValue == null) {
- return null;
- } else if (objectValue instanceof Class[]) {
- return (Class[]) objectValue;
- } else if (objectValue instanceof String) {
- String[] classnames = ((String) objectValue).split(",");
- Class[] classes = new Class[classnames.length];
- for (int i = 0; i < classnames.length; i++) {
- try {
- classes[i] = loader.loadClass(classnames[i]);
- } catch (ClassNotFoundException ex) {
- Object[] args = new Object[] {key, new Integer(i), classnames[i]};
- String msg = "Could not find class of configuration value: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
- }
- }
- return classes;
- }
-
- Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value is not a Class[]: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
- }
-
- /**
- * Searches for the property with the specified key in this property map. If the key is not
- * found in this property map, the parent property map, and its parents, recursively, are then
- * checked.
- * null will be returned.
- *
- * @param key Property key.
- * @return Object in this property map with the specified key value.
- */
- public final Object getObject(final String key) {
- return get(key);
- }
-
- /**
- * Searches for the property with the specified key in this property map. If the key is not
- * found in this property map, the parent property map, and its parents, recursively, are then
- * checked.
- * null will be returned. For all other types and if loading or instantiation of
- * one of the classes fails a ConfigurationException will be thrown.
- *
- * @param key Property key.
- * @param loader Class loader to load classes with.
- * @return Class array in this property map with the specified key value.
- */
- public final Object[] getObjectArray(final String key, final ClassLoader loader) {
- Object objectValue = get(key);
-
- if (objectValue == null) {
- return null;
- } else if (objectValue instanceof Object[]) {
- return (Object[]) objectValue;
- } else if (objectValue instanceof String) {
- List objects = new ArrayList();
- String[] classnames = ((String) objectValue).split(",");
- for (int i = 0; i < classnames.length; i++) {
- String classname = classnames[i];
- try {
- if ((classname != null) && !"".equals(classname.trim())) {
- classname = classname.trim();
- objects.add(loader.loadClass(classname).newInstance());
- }
- } catch (ClassNotFoundException ex) {
- Object[] args = new Object[] {key, new Integer(i), classname};
- String msg = "Could not find configured class: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
- } catch (IllegalAccessException ex) {
- Object[] args = new Object[] {key, new Integer(i), classname};
- String msg = "Could not instantiate configured class: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
- } catch (InstantiationException ex) {
- Object[] args = new Object[] {key, new Integer(i), classname};
- String msg = "Could not instantiate configured class: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
- } catch (ExceptionInInitializerError ex) {
- Object[] args = new Object[] {key, new Integer(i), classname};
- String msg = "Could not instantiate configured class: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
- } catch (SecurityException ex) {
- Object[] args = new Object[] {key, new Integer(i), classname};
- String msg = "Could not instantiate configured class: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
- }
- }
- return objects.toArray();
- }
-
- Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value is not an Object[]: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
- }
-
-}
Index: xml/src/test/java/org/castor/mapping/TestMappingLoaderRegistry.java
===================================================================
--- xml/src/test/java/org/castor/mapping/TestMappingLoaderRegistry.java (revision 8022)
+++ xml/src/test/java/org/castor/mapping/TestMappingLoaderRegistry.java (working copy)
@@ -20,8 +20,8 @@
import junit.framework.TestCase;
-import org.castor.core.CoreConfiguration;
-import org.castor.core.util.Configuration;
+import org.castor.core.CoreProperties;
+import org.castor.core.util.AbstractProperties;
import org.exolab.castor.mapping.MappingLoader;
/**
@@ -30,14 +30,14 @@
public class TestMappingLoaderRegistry extends TestCase {
public final void testGetInstance() throws Exception {
- Configuration config = new CoreConfiguration();
- MappingLoaderRegistry registry = new MappingLoaderRegistry(config);
+ AbstractProperties properties = new CoreProperties();
+ MappingLoaderRegistry registry = new MappingLoaderRegistry(properties);
assertNotNull(registry);
}
public final void testEnlistMappingLoaders() throws Exception {
- Configuration config = new CoreConfiguration();
- MappingLoaderRegistry registry = new MappingLoaderRegistry(config);
+ AbstractProperties properties = new CoreProperties();
+ MappingLoaderRegistry registry = new MappingLoaderRegistry(properties);
assertNotNull(registry);
Collection factories = registry.getMappingLoaderFactories();
@@ -64,8 +64,8 @@
}
public final void testGetXMLMappingLoader() throws Exception {
- Configuration config = new CoreConfiguration();
- MappingLoaderRegistry registry = new MappingLoaderRegistry(config);
+ AbstractProperties properties = new CoreProperties();
+ MappingLoaderRegistry registry = new MappingLoaderRegistry(properties);
assertNotNull(registry);
MappingLoader mappingLoader = registry.getMappingLoader(
Index: codegen/src/main/java/org/exolab/castor/builder/BuilderConfiguration.java
===================================================================
--- codegen/src/main/java/org/exolab/castor/builder/BuilderConfiguration.java (revision 8022)
+++ codegen/src/main/java/org/exolab/castor/builder/BuilderConfiguration.java (working copy)
@@ -59,11 +59,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
import org.castor.core.util.Messages;
import org.castor.xml.JavaNaming;
import org.castor.xml.JavaNamingImpl;
-import org.castor.xml.XMLConfiguration;
+import org.castor.xml.XMLProperties;
/**
* The configuration for the SourceGenerator.
@@ -670,7 +670,7 @@
}
}
- Configuration rtconf = XMLConfiguration.newInstance();
+ AbstractProperties rtconf = XMLProperties.newInstance();
// Parse XML namespace and package list from both castor.properties and
// castorbuilder.properties
@@ -853,7 +853,7 @@
// Complain if not found.
InputStream resourceStream = null;
try {
- resourceStream = Configuration.class.getResourceAsStream(resourceName);
+ resourceStream = AbstractProperties.class.getResourceAsStream(resourceName);
properties.load(resourceStream);
//-- debug information:
Index: cpa/src/main/java/org/castor/transactionmanager/TransactionManagerFactoryRegistry.java
===================================================================
--- cpa/src/main/java/org/castor/transactionmanager/TransactionManagerFactoryRegistry.java (revision 8022)
+++ cpa/src/main/java/org/castor/transactionmanager/TransactionManagerFactoryRegistry.java (working copy)
@@ -20,8 +20,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
/**
* Registry for {@link TransactionManagerFactory} implementations obtained from the
@@ -49,14 +49,14 @@
/**
* Construct an instance of TransactionManagerFactoryRegistry that loads the
* {@link TransactionManagerFactory} implementations specified in the given
- * LocalConfiguration.
+ * properties.
*
- * @param config The LocalConfiguration.
+ * @param properties The properties.
*/
- public TransactionManagerFactoryRegistry(final Configuration config) {
- ClassLoader loader = config.getApplicationClassLoader();
- Object[] objects = config.getObjectArray(
- CPAConfiguration.TRANSACTION_MANAGER_FACTORIES, loader);
+ public TransactionManagerFactoryRegistry(final AbstractProperties properties) {
+ ClassLoader loader = properties.getApplicationClassLoader();
+ Object[] objects = properties.getObjectArray(
+ CPAProperties.TRANSACTION_MANAGER_FACTORIES, loader);
for (int i = 0; i < objects.length; i++) {
TransactionManagerFactory factory = (TransactionManagerFactory) objects[i];
_factories.put(factory.getName(), factory);
Index: core/src/main/java/org/castor/core/util/AbstractProperties.java
===================================================================
--- core/src/main/java/org/castor/core/util/AbstractProperties.java (revision 8022)
+++ core/src/main/java/org/castor/core/util/AbstractProperties.java (working copy)
@@ -39,7 +39,7 @@
* @author Ralf Joachim
* @since 1.1.3
*/
-public abstract class Configuration {
+public abstract class AbstractProperties {
/**
* Name of the system property that can be used to specify the location
@@ -52,7 +52,7 @@
* The Jakarta Commons
* Logging instance used for all logging.
*/
- private static final Log LOG = LogFactory.getLog(Configuration.class);
+ private static final Log LOG = LogFactory.getLog(AbstractProperties.class);
/**
* {@link ClassLoader} to be used for all classes of Castor and its required
@@ -67,28 +67,27 @@
private final ClassLoader _domainClassLoader;
/**
- * Parent configuration.
+ * Parent properties.
*/
- private final Configuration _parent;
+ private final AbstractProperties _parent;
private final Map _map = new HashMap();
/**
* Default constructor. Application and domain class loaders will be initialized to the one
- * used to load the Configuration class. No parent configuration will be set.
+ * used to load the concrete properties class. No parent properties will be set.
*/
- protected Configuration() {
+ protected AbstractProperties() {
this(null, null);
}
/**
- * Construct a configuration that uses the specified class loaders. No parent configuration
- * will be set.
+ * Construct properties that uses the specified class loaders. No parent properties will be set.
*
* @param app Classloader to be used for all classes of Castor and its required libraries.
* @param domain Classloader to be used for all domain objects.
*/
- protected Configuration(final ClassLoader app, final ClassLoader domain) {
+ protected AbstractProperties(final ClassLoader app, final ClassLoader domain) {
_applicationClassLoader = (app != null) ? app : getClass().getClassLoader();
_domainClassLoader = (domain != null) ? domain : getClass().getClassLoader();
@@ -96,12 +95,12 @@
}
/**
- * Construct a configuration with given parent. Application and domain class loaders will be
+ * Construct properties with given parent. Application and domain class loaders will be
* initialized to the ones of the parent.
*
- * @param parent Parent configuration.
+ * @param parent Parent properties.
*/
- protected Configuration(final Configuration parent) {
+ protected AbstractProperties(final AbstractProperties parent) {
_applicationClassLoader = parent.getApplicationClassLoader();
_domainClassLoader = parent.getDomainClassLoader();
@@ -128,48 +127,48 @@
}
/**
- * Load module configuration from default locations.
+ * Load module properties from default locations.
* null and not the value of the parent. This allows to distingush
- * if the mapping existed in this configuration or one of its parents.
+ * if the mapping existed in this properties or one of its parents.
* NullPointerException will be thrown if the given value is
* null.
*
- * @param key Key of the property to put into configuration.
- * @param value Value to put into configuration associated with the given key..
- * @return Object in this configuration that previously has been associated with the given key.
+ * @param key Key of the property to put into properties.
+ * @param value Value to put into properties associated with the given key..
+ * @return Object in this properties that previously has been associated with the given key.
*/
public final synchronized Object put(final String key, final Object value) {
if (value == null) { throw new NullPointerException(); }
@@ -322,18 +321,18 @@
}
/**
- * Remove any value previously associated with the given key from this configuration. The value
- * previously associated with the key int this configuration will be returned. If a mapping
- * for the key existed in the parent configuration only, the method returns null
+ * Remove any value previously associated with the given key from this properties. The value
+ * previously associated with the key in this properties will be returned. If a mapping
+ * for the key existed in the parent properties only, the method returns null
* and not the value of the parent. This allows to distingush if the mapping existed in this
- * configuration or one of its parents.
+ * properties or one of its parents.
* null as one of the parents may still contain a mapping for the key that
- * was hidden by the mapping in this configuration.
+ * was hidden by the mapping in this properties.
*
- * @param key Key of the property to remove from configuration.
- * @return Object in this configuration that previously has been associated with the given key.
+ * @param key Key of the property to remove from properties.
+ * @return Object in this properties that previously has been associated with the given key.
*/
public final synchronized Object remove(final String key) {
return _map.remove(key);
@@ -347,7 +346,7 @@
* If the key maps to any object value, it will be returned as is. If the property is not found,
* null will be returned.
*
- * @param key Key of the property to get from configuration.
+ * @param key Key of the property to get from properties.
* @return Object in this property map with the specified key value.
*/
protected synchronized Object get(final String key) {
@@ -366,7 +365,7 @@
* If the key maps to a boolean value, it will be returned as is. For string values that are
* equal, ignore case, to 'true' or 'false', the respective boolean value will be returned. If
* the property is not found, null will be returned. For all other types and
- * string values a ConfigurationException will be thrown. This behaviour is intended for those
+ * string values a PropertiesException will be thrown. This behaviour is intended for those
* usecases that need distinguish between values that are missconfigured or not specified at
* all.
*
@@ -390,8 +389,8 @@
}
Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value can not be converted to boolean: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
+ String msg = "Properties value can not be converted to boolean: {0}={1}";
+ throw new PropertiesException(MessageFormat.format(msg, args));
}
/**
@@ -432,7 +431,7 @@
* If the key maps to a integer value, it will be returned as is. For string values that can
* be interpreted as signed decimal integer, the respective integer value will be returned. If
* the property is not found, null will be returned. For all other types and
- * string values a ConfigurationException will be thrown. This behaviour is intended for those
+ * string values a PropertiesException will be thrown. This behaviour is intended for those
* usecases that need distinguish between values that are missconfigured or not specified at
* all.
*
@@ -451,14 +450,14 @@
return Integer.valueOf((String) objectValue);
} catch (NumberFormatException ex) {
Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value can not be converted to int: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
+ String msg = "Properties value can not be converted to int: {0}={1}";
+ throw new PropertiesException(MessageFormat.format(msg, args), ex);
}
}
Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value can not be converted to int: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
+ String msg = "Properties value can not be converted to int: {0}={1}";
+ throw new PropertiesException(MessageFormat.format(msg, args));
}
/**
@@ -497,7 +496,7 @@
* checked.
* null will be returned. For all other types a ConfigurationException will be
+ * null will be returned. For all other types a PropertiesException will be
* thrown.
*
* @param key Property key.
@@ -513,8 +512,8 @@
}
Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value is not a string: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
+ String msg = "Properties value is not a string: {0}={1}";
+ throw new PropertiesException(MessageFormat.format(msg, args));
}
/**
@@ -547,7 +546,7 @@
* If the key maps to a string array, it will be returned as is. A simple string will be
* converted into a string array by splitting it into substrings at every occurence of ','
* character. If the property is not found, null will be returned. For all other
- * types a ConfigurationException will be thrown.
+ * types a PropertiesException will be thrown.
*
* @param key Property key.
* @return String array in this property map with the specified key value.
@@ -564,8 +563,8 @@
}
Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value is not a String[]: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
+ String msg = "Properties value is not a String[]: {0}={1}";
+ throw new PropertiesException(MessageFormat.format(msg, args));
}
/**
@@ -576,7 +575,7 @@
* If the key maps to a class, it will be returned as is. A simple string will be interpreted
* as class name of which the class will be loaded with the given class loader. If the property
* is not found, null will be returned. For all other types and if loading of the
- * class fails a ConfigurationException will be thrown.
+ * class fails a PropertiesException will be thrown.
*
* @param key Property key.
* @param loader Class loader to load classes with.
@@ -595,14 +594,14 @@
return loader.loadClass(classname);
} catch (ClassNotFoundException ex) {
Object[] args = new Object[] {key, classname};
- String msg = "Could not find class of configuration value: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
+ String msg = "Could not find class of properties value: {0}={1}";
+ throw new PropertiesException(MessageFormat.format(msg, args), ex);
}
}
Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value is not a Class: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
+ String msg = "Properties value is not a Class: {0}={1}";
+ throw new PropertiesException(MessageFormat.format(msg, args));
}
/**
@@ -614,7 +613,7 @@
* splitted it into substrings at every occurence of ',' character. Each of these substrings
* will interpreted as class name of which the class will be loaded with the given class
* loader. If the property is not found, null will be returned. For all other
- * types and if loading of one of the classes fails a ConfigurationException will be thrown.
+ * types and if loading of one of the classes fails a PropertiesException will be thrown.
*
* @param key Property key.
* @param loader Class loader to load classes with.
@@ -635,16 +634,16 @@
classes[i] = loader.loadClass(classnames[i]);
} catch (ClassNotFoundException ex) {
Object[] args = new Object[] {key, new Integer(i), classnames[i]};
- String msg = "Could not find class of configuration value: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
+ String msg = "Could not find class of properties value: {0}[{1}]={2}";
+ throw new PropertiesException(MessageFormat.format(msg, args), ex);
}
}
return classes;
}
Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value is not a Class[]: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
+ String msg = "Properties value is not a Class[]: {0}={1}";
+ throw new PropertiesException(MessageFormat.format(msg, args));
}
/**
@@ -672,7 +671,7 @@
* will interpreted as class name of which the class will be loaded with the given class
* loader and instantiated using its default constructor. If the property is not found,
* null will be returned. For all other types and if loading or instantiation of
- * one of the classes fails a ConfigurationException will be thrown.
+ * one of the classes fails a PropertiesException will be thrown.
*
* @param key Property key.
* @param loader Class loader to load classes with.
@@ -698,31 +697,31 @@
} catch (ClassNotFoundException ex) {
Object[] args = new Object[] {key, new Integer(i), classname};
String msg = "Could not find configured class: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
+ throw new PropertiesException(MessageFormat.format(msg, args), ex);
} catch (IllegalAccessException ex) {
Object[] args = new Object[] {key, new Integer(i), classname};
String msg = "Could not instantiate configured class: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
+ throw new PropertiesException(MessageFormat.format(msg, args), ex);
} catch (InstantiationException ex) {
Object[] args = new Object[] {key, new Integer(i), classname};
String msg = "Could not instantiate configured class: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
+ throw new PropertiesException(MessageFormat.format(msg, args), ex);
} catch (ExceptionInInitializerError ex) {
Object[] args = new Object[] {key, new Integer(i), classname};
String msg = "Could not instantiate configured class: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
+ throw new PropertiesException(MessageFormat.format(msg, args), ex);
} catch (SecurityException ex) {
Object[] args = new Object[] {key, new Integer(i), classname};
String msg = "Could not instantiate configured class: {0}[{1}]={2}";
- throw new ConfigurationException(MessageFormat.format(msg, args), ex);
+ throw new PropertiesException(MessageFormat.format(msg, args), ex);
}
}
return objects.toArray();
}
Object[] args = new Object[] {key, objectValue};
- String msg = "Configuration value is not an Object[]: {0}={1}";
- throw new ConfigurationException(MessageFormat.format(msg, args));
+ String msg = "Properties value is not an Object[]: {0}={1}";
+ throw new PropertiesException(MessageFormat.format(msg, args));
}
}
Property changes on: core/src/main/java/org/castor/core/util/AbstractProperties.java
___________________________________________________________________
Added: svn:mergeinfo
Index: cpa/src/main/java/org/castor/cache/CacheFactoryRegistry.java
===================================================================
--- cpa/src/main/java/org/castor/cache/CacheFactoryRegistry.java (revision 8022)
+++ cpa/src/main/java/org/castor/cache/CacheFactoryRegistry.java (working copy)
@@ -22,8 +22,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
/**
* Registry for {@link CacheFactory} implementations obtained from the Castor
@@ -51,14 +51,14 @@
//--------------------------------------------------------------------------
/**
- * Construct an instance of CacheFactoryRegistry that uses given Configuration
+ * Construct an instance of CacheFactoryRegistry that uses given properties
* to get required configuration properties.
*
- * @param config The Configuration.
+ * @param properties The properties.
*/
- public CacheFactoryRegistry(final Configuration config) {
- Object[] objects = config.getObjectArray(
- CPAConfiguration.CACHE_FACTORIES, config.getApplicationClassLoader());
+ public CacheFactoryRegistry(final AbstractProperties properties) {
+ Object[] objects = properties.getObjectArray(
+ CPAProperties.CACHE_FACTORIES, properties.getApplicationClassLoader());
for (int i = 0; i < objects.length; i++) {
CacheFactory factory = (CacheFactory) objects[i];
_cacheFactories.put(factory.getCacheType(), factory);
Index: cpa/src/main/java/org/exolab/castor/jdo/engine/OQLQueryImpl.java
===================================================================
--- cpa/src/main/java/org/exolab/castor/jdo/engine/OQLQueryImpl.java (revision 8022)
+++ cpa/src/main/java/org/exolab/castor/jdo/engine/OQLQueryImpl.java (working copy)
@@ -49,9 +49,9 @@
import java.util.NoSuchElementException;
import java.util.Vector;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
import org.castor.core.util.Messages;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.cpa.CPAProperties;
import org.castor.cpa.persistence.convertor.TypeConvertorRegistry;
import org.castor.jdo.util.ClassLoadingUtils;
import org.castor.persist.TransactionContext;
@@ -130,8 +130,8 @@
private TypeConvertorRegistry getTypeConvertorRegistry() {
if (_typeConvertorRegistry == null) {
- Configuration config = CPAConfiguration.getInstance();
- _typeConvertorRegistry = new TypeConvertorRegistry(config);
+ AbstractProperties properties = CPAProperties.getInstance();
+ _typeConvertorRegistry = new TypeConvertorRegistry(properties);
}
return _typeConvertorRegistry;
}
Index: cpa/src/test/java/org/castor/jdo/engine/TestSQLTypes.java
===================================================================
--- cpa/src/test/java/org/castor/jdo/engine/TestSQLTypes.java (revision 8022)
+++ cpa/src/test/java/org/castor/jdo/engine/TestSQLTypes.java (working copy)
@@ -50,8 +50,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
import org.castor.cpa.persistence.convertor.TypeConvertorRegistry;
import org.exolab.castor.mapping.MappingException;
import org.exolab.castor.mapping.TypeConvertor;
@@ -70,8 +70,8 @@
super(arg0);
if (_registry == null) {
- Configuration config = CPAConfiguration.newInstance();
- _registry = new TypeConvertorRegistry(config);
+ AbstractProperties properties = CPAProperties.newInstance();
+ _registry = new TypeConvertorRegistry(properties);
}
}
Index: xml/src/main/java/org/castor/mapping/MappingUnmarshaller.java
===================================================================
--- xml/src/main/java/org/castor/mapping/MappingUnmarshaller.java (revision 8022)
+++ xml/src/main/java/org/castor/mapping/MappingUnmarshaller.java (working copy)
@@ -21,7 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.CoreConfiguration;
+import org.castor.core.CoreProperties;
import org.castor.core.util.Messages;
import org.castor.xml.InternalContext;
import org.castor.xml.AbstractInternalContext;
@@ -77,7 +77,7 @@
* Construct a new MappingUnmarshaller.
*/
public MappingUnmarshaller() {
- _registry = new MappingLoaderRegistry(new CoreConfiguration());
+ _registry = new MappingLoaderRegistry(new CoreProperties());
_idResolver = new MappingUnmarshallIDResolver();
AbstractInternalContext internalContext = new AbstractInternalContext() { };
internalContext.setClassLoader(getClass().getClassLoader());
Index: cpactf/src/test/java/org/castor/cpa/test/test1002/Test1002.java
===================================================================
--- cpactf/src/test/java/org/castor/cpa/test/test1002/Test1002.java (revision 8026)
+++ cpactf/src/test/java/org/castor/cpa/test/test1002/Test1002.java (working copy)
@@ -17,8 +17,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
import org.castor.cpa.test.framework.CPATestCase;
import org.castor.cpa.test.framework.xml.types.DatabaseEngineType;
import org.castor.jdo.conf.JdoConf;
@@ -47,17 +47,17 @@
protected void setUp() throws Exception {
super.setUp();
- Configuration cfg = getConfiguration();
- _memInitFlag = cfg.getObject(CPAConfiguration.INITIALIZE_AT_LOAD);
- cfg.put(CPAConfiguration.INITIALIZE_AT_LOAD, Boolean.toString(false));
+ AbstractProperties properties = getProperties();
+ _memInitFlag = properties.getObject(CPAProperties.INITIALIZE_AT_LOAD);
+ properties.put(CPAProperties.INITIALIZE_AT_LOAD, Boolean.toString(false));
}
protected void tearDown() throws Exception {
- Configuration cfg = getConfiguration();
+ AbstractProperties properties = getProperties();
if (_memInitFlag != null) {
- cfg.put(CPAConfiguration.INITIALIZE_AT_LOAD, _memInitFlag);
+ properties.put(CPAProperties.INITIALIZE_AT_LOAD, _memInitFlag);
} else {
- cfg.remove(CPAConfiguration.INITIALIZE_AT_LOAD);
+ properties.remove(CPAProperties.INITIALIZE_AT_LOAD);
}
super.tearDown();
Index: xml/src/main/java/org/exolab/castor/xml/validators/IntegerValidator.java
===================================================================
--- xml/src/main/java/org/exolab/castor/xml/validators/IntegerValidator.java (revision 8022)
+++ xml/src/main/java/org/exolab/castor/xml/validators/IntegerValidator.java (working copy)
@@ -44,7 +44,7 @@
*/
package org.exolab.castor.xml.validators;
-import org.castor.xml.XMLConfiguration;
+import org.castor.xml.XMLProperties;
import org.exolab.castor.xml.TypeValidator;
import org.exolab.castor.xml.ValidationContext;
import org.exolab.castor.xml.ValidationException;
@@ -414,7 +414,7 @@
value = ((Long) object).longValue();
} catch (Exception ex) {
String lenientProperty = context.getInternalContext()
- .getStringProperty(XMLConfiguration.LENIENT_INTEGER_VALIDATION);
+ .getStringProperty(XMLProperties.LENIENT_INTEGER_VALIDATION);
if (Boolean.valueOf(lenientProperty).booleanValue()) {
try {
value = ((Integer) object).longValue();
Index: cpa/src/main/java/org/exolab/castor/persist/PersistenceFactoryRegistry.java
===================================================================
--- cpa/src/main/java/org/exolab/castor/persist/PersistenceFactoryRegistry.java (revision 8022)
+++ cpa/src/main/java/org/exolab/castor/persist/PersistenceFactoryRegistry.java (working copy)
@@ -49,8 +49,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
import org.exolab.castor.persist.spi.PersistenceFactory;
/**
@@ -108,9 +108,9 @@
if (_factories == null) {
_factories = new Hashtable();
- Configuration config = CPAConfiguration.getInstance();
- Object[] objects = config.getObjectArray(
- CPAConfiguration.PERSISTENCE_FACTORIES, config.getApplicationClassLoader());
+ AbstractProperties properties = CPAProperties.getInstance();
+ Object[] objects = properties.getObjectArray(
+ CPAProperties.PERSISTENCE_FACTORIES, properties.getApplicationClassLoader());
for (int i = 0; i < objects.length; i++) {
PersistenceFactory factory = (PersistenceFactory) objects[i];
_factories.put(factory.getFactoryName(), factory);
Index: cpa/src/test/java/org/castor/transactionmanager/TestTransactionManagerRegistry.java
===================================================================
--- cpa/src/test/java/org/castor/transactionmanager/TestTransactionManagerRegistry.java (revision 8022)
+++ cpa/src/test/java/org/castor/transactionmanager/TestTransactionManagerRegistry.java (working copy)
@@ -23,8 +23,8 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
/**
* @author Ralf Joachim
@@ -51,17 +51,17 @@
if (DISABLE_LOGGING) { logger.setLevel(Level.FATAL); }
assertEquals("org.castor.transactionmanager.InitializeAtRegistration",
- CPAConfiguration.TRANSACTION_MANAGER_INIT);
+ CPAProperties.TRANSACTION_MANAGER_INIT);
- Configuration config = CPAConfiguration.getInstance();
- String memF = config.getString(CPAConfiguration.TRANSACTION_MANAGER_FACTORIES, null);
- String memI = config.getString(CPAConfiguration.TRANSACTION_MANAGER_INIT, null);
- config.put(CPAConfiguration.TRANSACTION_MANAGER_FACTORIES,
+ AbstractProperties properties = CPAProperties.getInstance();
+ String memF = properties.getString(CPAProperties.TRANSACTION_MANAGER_FACTORIES, null);
+ String memI = properties.getString(CPAProperties.TRANSACTION_MANAGER_INIT, null);
+ properties.put(CPAProperties.TRANSACTION_MANAGER_FACTORIES,
TransactionManagerFactoryDummy.class.getName());
- config.put(CPAConfiguration.TRANSACTION_MANAGER_INIT,
+ properties.put(CPAProperties.TRANSACTION_MANAGER_INIT,
Boolean.FALSE.toString());
- TransactionManagerRegistry tmr = new TransactionManagerRegistry(config);
+ TransactionManagerRegistry tmr = new TransactionManagerRegistry(properties);
String[] managers = tmr.getTransactionManagerNames();
assertEquals(0, managers.length);
@@ -134,8 +134,8 @@
managers = tmr.getTransactionManagerNames();
assertEquals(0, managers.length);
- config.put(CPAConfiguration.TRANSACTION_MANAGER_INIT, memI);
- config.put(CPAConfiguration.TRANSACTION_MANAGER_FACTORIES, memF);
+ properties.put(CPAProperties.TRANSACTION_MANAGER_INIT, memI);
+ properties.put(CPAProperties.TRANSACTION_MANAGER_FACTORIES, memF);
logger.setLevel(level);
}
Index: xml/src/test/java/org/castor/xml/XMLConfigurationTest.java
===================================================================
--- xml/src/test/java/org/castor/xml/XMLConfigurationTest.java (revision 8022)
+++ xml/src/test/java/org/castor/xml/XMLConfigurationTest.java (working copy)
@@ -1,104 +0,0 @@
-/*
- * Copyright 2007 Joachim Grueneis
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.castor.xml;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-/**
- * The XMLConfiguration test has one goal - check if the proper defaults
- * are in place.
- *
- * @author Joachim Grueneis, jgrueneis_at_gmail_dot_com
- * @version $Id$
- */
-public class XMLConfigurationTest extends TestCase {
- private static final Log LOG = LogFactory.getLog(XMLConfigurationTest.class);
-
- private Configuration _configuration;
-
- public XMLConfigurationTest(final String name) {
- super(name);
- }
-
- public void setUp() {
- _configuration = XMLConfiguration.newInstance();
- Assert.assertNotNull(
- "Configuration must exist after call to newInstance()", _configuration);
- Assert.assertNotNull(
- "Application class loader must not be null",
- _configuration.getApplicationClassLoader());
- Assert.assertNotNull(
- "Domain class loader must not be null",
- _configuration.getDomainClassLoader());
- }
-
- public void testNewInstanceClassLoaderClassLoader() {
- Configuration c = XMLConfiguration.newInstance(null, null);
- Assert.assertNotNull(
- "Configuration must exist after call to newInstance()", c);
-// Assert.assertNotNull(
-// "Application class loader must not be null",
-// c.getApplicationClassLoader());
-// Assert.assertNotNull(
-// "Domain class loader must not be null",
-// c.getDomainClassLoader());
- }
-
- public void testGetBooleanString() {
- Boolean notExistingProperty = _configuration.getBoolean("Something which doesn't exist");
- Assert.assertNull("A not existing property needs to return null", notExistingProperty);
- }
-
- public void testGetBooleanStringBoolean() {
- boolean notExistingPropertyWithDefault =
- _configuration.getBoolean("Something which doesn't exist", true);
- Assert.assertTrue(
- "A not existing property with default true",
- notExistingPropertyWithDefault);
- }
-
- /**
- * Tests wether the expected defaults are present or not.
- */
- public void testDefaults() {
- Boolean loadPackageMapping =
- _configuration.getBoolean(XMLConfiguration.LOAD_PACKAGE_MAPPING);
- Assert.assertEquals(
- "load package mapping is expected to be set to: true",
- Boolean.TRUE, loadPackageMapping);
-
- String serialzierFactory = _configuration.getString(XMLConfiguration.SERIALIZER_FACTORY);
- Assert.assertEquals(
- "check serializer factory default",
- "org.exolab.castor.xml.XercesJDK5XMLSerializerFactory",
- serialzierFactory);
-
- Boolean strictElements = _configuration.getBoolean(XMLConfiguration.STRICT_ELEMENTS);
- Assert.assertEquals("strict elements default", Boolean.FALSE, strictElements);
-
- Boolean marshallingValidation =
- _configuration.getBoolean(XMLConfiguration.MARSHALLING_VALIDATION);
- Assert.assertEquals("marshallingValidation", Boolean.TRUE, marshallingValidation);
-
- Boolean useIntrospection = _configuration.getBoolean(XMLConfiguration.USE_INTROSPECTION);
- Assert.assertEquals("useIntrospection", Boolean.TRUE, useIntrospection);
- }
-}
Index: schema/src/main/java/org/exolab/castor/xml/schema/SchemaContextImpl.java
===================================================================
--- schema/src/main/java/org/exolab/castor/xml/schema/SchemaContextImpl.java (revision 8022)
+++ schema/src/main/java/org/exolab/castor/xml/schema/SchemaContextImpl.java (working copy)
@@ -2,8 +2,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.castor.core.util.Configuration;
-import org.castor.xml.XMLConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.xml.XMLProperties;
import org.exolab.castor.xml.Serializer;
import org.exolab.castor.xml.util.XMLParserUtils;
import org.xml.sax.Parser;
@@ -25,16 +25,16 @@
private Resolver _schemaResolver;
/**
- * {@link Configuration} instance for retrieving property values related to XML parsers
+ * {@link AbstractProperties} instance for retrieving property values related to XML parsers
*/
- private Configuration _configuration;
+ private AbstractProperties _properties;
/**
* Creates an instance of {@link SchemaContextImpl}.
*/
public SchemaContextImpl() {
super();
- _configuration = XMLConfiguration.newInstance();
+ _properties = XMLProperties.newInstance();
}
/**
@@ -50,7 +50,7 @@
* @see org.castor.xml.InternalContext#getParser(java.lang.String)
*/
public Parser getParser(final String features) {
- return XMLParserUtils.getParser(_configuration, features);
+ return XMLParserUtils.getParser(_properties, features);
}
@@ -76,7 +76,7 @@
* @see org.castor.xml.InternalContext#getSerializer()
*/
public Serializer getSerializer() {
- return XMLParserUtils.getSerializer(_configuration);
+ return XMLParserUtils.getSerializer(_properties);
}
}
Index: xml/src/main/java/org/exolab/castor/xml/Unmarshaller.java
===================================================================
--- xml/src/main/java/org/exolab/castor/xml/Unmarshaller.java (revision 8022)
+++ xml/src/main/java/org/exolab/castor/xml/Unmarshaller.java (working copy)
@@ -58,7 +58,7 @@
import org.castor.xml.BackwardCompatibilityContext;
import org.castor.xml.InternalContext;
import org.castor.xml.UnmarshalListenerAdapter;
-import org.castor.xml.XMLConfiguration;
+import org.castor.xml.XMLProperties;
import org.exolab.castor.mapping.Mapping;
import org.exolab.castor.mapping.MappingException;
import org.exolab.castor.mapping.MappingLoader;
@@ -965,7 +965,7 @@
}
/**
- * Derive class-level properties from {@link XMLConfiguration} as defined
+ * Derive class-level properties from {@link XMLProperties} as defined
* {@link InternalContext}. This method will be called after a new {@link InternalContext}
* has been set.
* @link #setInternalContext(InternalContext)
@@ -976,7 +976,7 @@
//-- process namespace to package mappings
String mappings =
- _internalContext.getStringProperty(XMLConfiguration.NAMESPACE_PACKAGE_MAPPINGS);
+ _internalContext.getStringProperty(XMLProperties.NAMESPACE_PACKAGE_MAPPINGS);
if (mappings != null && mappings.length() > 0) {
StringTokenizer tokens = new StringTokenizer(mappings, ",");
while (tokens.hasMoreTokens()) {
Index: xml/src/main/java/org/exolab/castor/xml/UnmarshalHandler.java
===================================================================
--- xml/src/main/java/org/exolab/castor/xml/UnmarshalHandler.java (revision 8022)
+++ xml/src/main/java/org/exolab/castor/xml/UnmarshalHandler.java (working copy)
@@ -68,7 +68,7 @@
import org.castor.core.util.Base64Decoder;
import org.castor.core.util.HexDecoder;
import org.castor.xml.UnmarshalListenerAdapter;
-import org.castor.xml.XMLConfiguration;
+import org.castor.xml.XMLProperties;
import org.exolab.castor.mapping.ClassDescriptor;
import org.exolab.castor.mapping.ExtendedFieldHandler;
import org.exolab.castor.mapping.FieldHandler;
@@ -1983,7 +1983,7 @@
//-- which we have no mapping, increase the ignore depth counter and return
boolean lenientElementStrictnessForIntrospection =
getInternalContext()
- .getBooleanProperty(XMLConfiguration.LENIENT_INTROSPECTED_ELEMENT_STRICTNESS)
+ .getBooleanProperty(XMLProperties.LENIENT_INTROSPECTED_ELEMENT_STRICTNESS)
.booleanValue();
if (! _strictElements) {
++_ignoreElementDepth;
Index: xml/src/main/java/org/castor/xml/XMLConfiguration.java
===================================================================
--- xml/src/main/java/org/castor/xml/XMLConfiguration.java (revision 8022)
+++ xml/src/main/java/org/castor/xml/XMLConfiguration.java (working copy)
@@ -1,477 +0,0 @@
-/*
- * Copyright 2007 Ralf Joachim
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Id: Configuration.java 6907 2007-03-28 21:24:52Z rjoachim $
- */
-package org.castor.xml;
-
-import org.castor.core.CoreConfiguration;
-import org.castor.core.util.CastorConfiguration;
-import org.castor.core.util.Configuration;
-
-/**
- * Castor configuration of XML modul.
- *
- * @version $Id: Configuration.java,v 1.8 2006/03/08 17:25:52 jens Exp $
- * @author Ralf Joachim
- * @since 1.1.3
- */
-public final class XMLConfiguration extends Configuration {
- //--------------------------------------------------------------------------
-
- /** Path to Castor configuration of core modul. */
- private static final String FILEPATH = "/org/castor/xml/";
-
- /** Name of Castor configuration of core modul. */
- private static final String FILENAME = "castor.xml.properties";
-
- /** A static configuration instance to be used during migration to a none static one. */
- // TODO Remove property after support for static configuration has been terminated.
- private static Configuration _instance = null;
-
- //--------------------------------------------------------------------------
-
- /**
- * Factory method for a default XML configuration instance. Application and domain class
- * loaders will be initialized to the one used to load the Configuration class. The
- * configuration instance returned will be a CastorConfiguration with a XMLConfiguration and
- * a CoreConfiguration instance as parents. The CastorConfiguration holding user specific
- * properties is the only one that can be modified by put() and remove() methods.
- * XMLConfiguration and CoreConfiguration are responsible to deliver Castor's default values
- * if they have not been overwritten by the user.
- *
- * @return Configuration instance for Castor XML module.
- */
- public static Configuration newInstance() {
- Configuration core = new CoreConfiguration();
- Configuration xml = new XMLConfiguration(core);
- Configuration castor = new CastorConfiguration(xml);
- return castor;
- }
-
- /**
- * Factory method for a XML configuration instance that uses the specified class loaders. The
- * configuration instance returned will be a CastorConfiguration with a XMLConfiguration and
- * a CoreConfiguration instance as parents. The CastorConfiguration holding user specific
- * properties is the only one that can be modified by put() and remove() methods.
- * XMLConfiguration and CoreConfiguration are responsble to deliver Castor's default values
- * if they have not been overwritten by the user.
- *
- * @param app Classloader to be used for all classes of Castor and its required libraries.
- * @param domain Classloader to be used for all domain objects.
- * @return Configuration instance for Castor XML modul.
- */
- public static Configuration newInstance(final ClassLoader app, final ClassLoader domain) {
- Configuration core = new CoreConfiguration(app, domain);
- Configuration xml = new XMLConfiguration(core);
- Configuration castor = new CastorConfiguration(xml);
- return castor;
- }
-
- //--------------------------------------------------------------------------
-
- /**
- * Construct a configuration with given parent. Application and domain class loaders will be
- * initialized to the ones of the parent.
- * - * org.exolab.castor.xml.introspector.primitive.nodetype - *- */ - public static final String PRIMITIVE_NODE_TYPE - = "org.exolab.castor.xml.introspector.primitive.nodetype"; - - /** - * Property specifying the class name of the SAX 1 XML parser to - * use. - * - *
- * org.exolab.castor.parser - *- */ - public static final String PARSER = "org.exolab.castor.parser"; - - // TODO: expand comment to make things clearer; check against code - /** - * Property specifying whether to perform document validation - * by default. - * - * Possible values: - * - false (default) - * - true - * - *
- * org.exolab.castor.SAXParser.validation - *- */ - public static final String PARSER_VALIDATION = - "org.exolab.castor.parser.validation"; - - /** - * Property specifying whether to support XML namespaces by default. - * - * Possible values: - * - false (default) - * - true - * - *
- * org.exolab.castor.SAXParser.namespaces - *- */ - public static final String NAMESPACES = - "org.exolab.castor.parser.namespaces"; - - /** - * Property specifying XML namespace to Java package mappings. - * - *
- * org.exolab.castor.xml.nspackages - *- */ - public static final String NAMESPACE_PACKAGE_MAPPINGS = - "org.exolab.castor.xml.nspackages"; - - /** - * 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 {@link org.exolab.castor.xml.AbstractXMLNaming}. - * - * Possible values: - * - 'mixed' - * - 'lower' - * - A class name (which extends {@link org.exolab.castor.xml.AbstractXMLNaming}). - * - *
- * org.exolab.castor.xml.naming - *- * - */ - public static final String XML_NAMING = "org.exolab.castor.xml.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 {@link org.castor.xml.JavaNaming}. - * - * Possible values: - * - null - * - A class name (which extends {@link org.castor.xml.JavaNaming}). - * - *
- * org.castor.xml.java_naming - *- * - */ - public static final String JAVA_NAMING = "org.castor.xml.java.naming"; - - /** - * Property specifying whether to use validation in the Marshalling - * framework. - * - * - * Possible values: - * - false - * - true (default) - * - *
- * org.exolab.castor.marshalling.validation - *- */ - public static final String MARSHALLING_VALIDATION = - "org.exolab.castor.marshalling.validation"; - - /** - * Property specifying whether XML documents (as generated at marshalling) - * should use indentation or not. - * - * Possible values: - * - false (default) - * - true - * - *
- * org.exolab.castor.indent - *- */ - public static final String USE_INDENTATION = "org.exolab.castor.indent"; - - /** - * Property specifying additional features for the XML parser. - * This value contains a comma separated list of features that - * might or might not be supported by the specified SAX parser. - * - *
- * org.exolab.castor.sax.features - *- */ - public static final String PARSER_FEATURES = "org.exolab.castor.sax.features"; - - /** - * Property specifying features to be disbaled on the underlying SAX parser. - * This value contains a comma separated list of features to be disabled. - * - *
- * org.exolab.castor.sax.features-to-disable - *- */ - public static final String PARSER_FEATURES_DISABLED = - "org.exolab.castor.sax.features-to-disable"; - - /** - * Property specifying the regular expression validator - * to use. The specified class must implement - * {@link org.exolab.castor.xml.validators.RegExpValidator} - * - * Possible values: - * - A class name. - * - *
- * org.exolab.castor.regexp - *- */ - public static final String REG_EXP_CLASS_NAME = - "org.exolab.castor.regexp"; - - /** - * Property specifying whether to run in debug mode. - * - * Possible values: - * - false (default) - * - true - * - *
- * org.exolab.castor.debug - *- */ - public static final String DEBUG = "org.exolab.castor.debug"; - - /** - * Property specifying whether to apply strictness to elements when - * unmarshalling. Default is true which means that elements appearing in the - * XML document, which cannot be mapped to a class, cause a {@link SAXException} - * to be thrown. If set to false, these 'unknown' elements are ignored. - * - * Possible values: - * - false - * - true (default) - * - *
- * org.exolab.castor.strictelements - *- */ - public static final String STRICT_ELEMENTS = "org.exolab.castor.xml.strictelements"; - - /** - * Property specifying whether or not to save the "keys" of a {@link Hashtable} or - * {@link Map} during marshalling. By default this is true. - * - * Backwards compatibility switch (for 0.9.5.2 users and earlier) - * - * Possible values: - * - false - * - true (default) - * - *
- * org.exolab.castor.xml.saveMapKeys - *- * - * @since 0.9.5.3 - */ - public static final String SAVE_MAP_KEYS = "org.exolab.castor.xml.saveMapKeys"; - - /** - * Property specifying whether the ClassDescriptorResolver should (automatically) search - * for and consult with package mapping files (.castor.xml) to retrieve class - * descriptor information; on by default. - * - * Possible values: - * - false - * - true (default) - * - *
- * org.exolab.castor.xml.loadPackageMappings - *- * @since 1.0 - */ - public static final String LOAD_PACKAGE_MAPPING = "org.exolab.castor.xml.loadPackageMappings"; - - /** - * Property specifying what factory to use for dealing with XML serializers. - * - * Possible value: - * - A class name - * - *
- * org.exolab.castor.xml.serializer.factory - *- * @since 1.0 - */ - public static final String SERIALIZER_FACTORY = - "org.exolab.castor.xml.serializer.factory"; - - /** - * Property specifying whether sequence order validation should be lenient. - * - * Possible values - * - false (default) - * - true - * - *
- * org.exolab.castor.xml.lenient.sequence.order=false - *- * since 1.1 - */ - public static final String LENIENT_SEQUENCE_ORDER = - "org.exolab.castor.xml.lenient.sequence.order"; - - /** - * Property specifying whether id/href validation should be lenient; - * defaults to false. - * - * Possible values: - * - false (default) - * - true - * - *
- * org.exolab.castor.xml.lenient.id.validation=false - *- * since 1.1 - */ - public static final String LENIENT_ID_VALIDATION = - "org.exolab.castor.xml.lenient.id.validation"; - - /** - * 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 - *- * @since 1.1.3 - */ - public static final String PROXY_INTERFACES = - "org.exolab.castor.xml.proxyInterfaces"; - - - /** - * Property specifying whether element strictness for introspected classes/elements - * should be lenient (aka allowed); defaults to true. - * - * Possible values: - * - false - * - true (default) - * - *
- * org.exolab.castor.xml.lenient.introspected.element.strictness=true - *- * - * @since 1.1.3 - */ - public static final String LENIENT_INTROSPECTED_ELEMENT_STRICTNESS = - "org.exolab.castor.xml.lenient.introspected.element.strictness"; - - /** - * Property specifying which collections handlers should be used for - * Java 1.1 and Java 1.2 run-times. - * - *
- * org.exolab.castor.mapping.collections - *- */ - public static final String COLLECTION_HANDLERS_FOR_JAVA_11_OR_12 = - "org.exolab.castor.mapping.collections"; - - /** - * Property specifying if introspection should be used at class resolving. - * - *
- * org.castor.xml.class-resolver.use-introspection - *- */ - public static final String USE_INTROSPECTION - = "org.castor.xml.class-resolver.use-introspection"; - - /** - * The property name for enabling collection wrapping. - * The property controls whether or not collections - * (arrays, vectors, etc) should be wrapped in a container element. - * For example: - * - *
- * <foos> - * <foo>foo1</foo> - * <foo>foo2</foo> - * </foos> - * - * instead of the default: - * - * <foos>foo1<foos> - * <foos>foo2</foos> - * - *- * - * Use this property with a value of true or false in the - * castor.properties file - * - * org.exolab.castor.xml.introspector.wrapCollections=true - * -or- - * org.exolab.castor.xml.introspector.wrapCollections=false - * - * This property is false by default. - */ - public static final String WRAP_COLLECTIONS_PROPERTY = - "org.exolab.castor.xml.introspector.wrapCollections"; - - /** - * Property that allows to specify whether the validation for - * <xs:integer> should accept the old 'int/Integer' members as well; - * default to false. - * - * Possible values: - * - false (default) - * - true - * - *
- * org.exolab.castor.xml.lenient.integer.validation=false - *- */ - public static final String LENIENT_INTEGER_VALIDATION = - "org.exolab.castor.xml.lenient.integer.validation"; -} Index: cpa/src/main/java/org/castor/transactionmanager/TransactionManagerRegistry.java =================================================================== --- cpa/src/main/java/org/castor/transactionmanager/TransactionManagerRegistry.java (revision 8022) +++ cpa/src/main/java/org/castor/transactionmanager/TransactionManagerRegistry.java (working copy) @@ -23,8 +23,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.castor.core.util.Configuration; -import org.castor.cpa.CPAConfiguration; +import org.castor.core.util.AbstractProperties; +import org.castor.cpa.CPAProperties; /** * Registry for {@link TransactionManager} instances obtained by their name. @@ -126,13 +126,13 @@ * Construct an instance of TransactionManagerRegistry that uses given * LocalConfiguration to get required configuration properties. * - * @param config The LocalConfiguration. + * @param properties The properties. */ - public TransactionManagerRegistry(final Configuration config) { - _registry = new TransactionManagerFactoryRegistry(config); + public TransactionManagerRegistry(final AbstractProperties properties) { + _registry = new TransactionManagerFactoryRegistry(properties); - _initializationAtRegistration = config.getBoolean( - CPAConfiguration.TRANSACTION_MANAGER_INIT, false); + _initializationAtRegistration = properties.getBoolean( + CPAProperties.TRANSACTION_MANAGER_INIT, false); } //-------------------------------------------------------------------------- Index: cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToInteger.java =================================================================== --- cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToInteger.java (revision 8022) +++ cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToInteger.java (working copy) @@ -15,7 +15,7 @@ */ package org.castor.cpa.persistence.convertor; -import org.castor.core.util.Configuration; +import org.castor.core.util.AbstractProperties; /** * Convert
Boolean to Integer.
@@ -47,7 +47,7 @@
/**
* {@inheritDoc}
*/
- public void configure(final Configuration configuration) { }
+ public void configure(final AbstractProperties properties) { }
/**
* {@inheritDoc}
Index: cpa/src/main/java/org/exolab/castor/persist/LockEngine.java
===================================================================
--- cpa/src/main/java/org/exolab/castor/persist/LockEngine.java (revision 8022)
+++ cpa/src/main/java/org/exolab/castor/persist/LockEngine.java (working copy)
@@ -58,9 +58,9 @@
import org.castor.cache.CacheAcquireException;
import org.castor.cache.CacheFactory;
import org.castor.cache.CacheFactoryRegistry;
-import org.castor.core.util.Configuration;
+import org.castor.core.util.AbstractProperties;
import org.castor.core.util.Messages;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.cpa.CPAProperties;
import org.castor.jdo.engine.ConnectionFactory;
import org.castor.persist.ProposedEntity;
import org.castor.persist.TransactionContext;
@@ -163,8 +163,8 @@
final PersistenceFactory persistenceFactory)
throws MappingException {
if (_cacheFactoryRegistry == null) {
- Configuration config = CPAConfiguration.getInstance();
- _cacheFactoryRegistry = new CacheFactoryRegistry(config);
+ AbstractProperties properties = CPAProperties.getInstance();
+ _cacheFactoryRegistry = new CacheFactoryRegistry(properties);
}
_connectionFactory = connectionFactory;
Index: cpa/src/main/java/org/castor/cpa/persistence/sql/driver/SQLServerFactory.java
===================================================================
--- cpa/src/main/java/org/castor/cpa/persistence/sql/driver/SQLServerFactory.java (revision 8022)
+++ cpa/src/main/java/org/castor/cpa/persistence/sql/driver/SQLServerFactory.java (working copy)
@@ -44,8 +44,8 @@
*/
package org.castor.cpa.persistence.sql.driver;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
import org.exolab.castor.persist.spi.QueryExpression;
/**
@@ -64,9 +64,9 @@
}
public QueryExpression getQueryExpression() {
- Configuration config = CPAConfiguration.getInstance();
- boolean useNewSyntaxForSQLServer = config.getBoolean(
- CPAConfiguration.MSSQL_ANSI_COMPLIANT, false);
+ AbstractProperties properties = CPAProperties.getInstance();
+ boolean useNewSyntaxForSQLServer = properties.getBoolean(
+ CPAProperties.MSSQL_ANSI_COMPLIANT, false);
if (useNewSyntaxForSQLServer) {
return new JDBCQueryExpression(this);
Index: xml/src/main/java/org/castor/xml/XMLProperties.java
===================================================================
--- xml/src/main/java/org/castor/xml/XMLProperties.java (revision 8022)
+++ xml/src/main/java/org/castor/xml/XMLProperties.java (working copy)
@@ -17,81 +17,77 @@
*/
package org.castor.xml;
-import org.castor.core.CoreConfiguration;
-import org.castor.core.util.CastorConfiguration;
-import org.castor.core.util.Configuration;
+import org.castor.core.CoreProperties;
+import org.castor.core.util.CastorProperties;
+import org.castor.core.util.AbstractProperties;
/**
- * Castor configuration of XML modul.
+ * Properties of XML modul.
*
* @version $Id: Configuration.java,v 1.8 2006/03/08 17:25:52 jens Exp $
* @author Ralf Joachim
* @since 1.1.3
*/
-public final class XMLConfiguration extends Configuration {
+public final class XMLProperties extends AbstractProperties {
//--------------------------------------------------------------------------
- /** Path to Castor configuration of core modul. */
+ /** Path to Castor properties of core modul. */
private static final String FILEPATH = "/org/castor/xml/";
- /** Name of Castor configuration of core modul. */
+ /** Name of Castor properties of core modul. */
private static final String FILENAME = "castor.xml.properties";
- /** A static configuration instance to be used during migration to a none static one. */
- // TODO Remove property after support for static configuration has been terminated.
- private static Configuration _instance = null;
-
//--------------------------------------------------------------------------
/**
- * Factory method for a default XML configuration instance. Application and domain class
- * loaders will be initialized to the one used to load the Configuration class. The
- * configuration instance returned will be a CastorConfiguration with a XMLConfiguration and
- * a CoreConfiguration instance as parents. The CastorConfiguration holding user specific
- * properties is the only one that can be modified by put() and remove() methods.
- * XMLConfiguration and CoreConfiguration are responsible to deliver Castor's default values
- * if they have not been overwritten by the user.
+ * Factory method for a default XML properties instance. Application and domain class
+ * loaders will be initialized to the one used to load this class. The properties instance
+ * returned will be a CastorProperties with a XMLProperties and a CoreProperties instance
+ * as parents. The CastorProperties holding user specific properties is the only one that
+ * can be modified by put() and remove() methods. XMLProperties and CoreProperties are
+ * responsible to deliver Castor's default values if they have not been overwritten by the
+ * user.
*
- * @return Configuration instance for Castor XML module.
+ * @return Properties instance for Castor XML module.
*/
- public static Configuration newInstance() {
- Configuration core = new CoreConfiguration();
- Configuration xml = new XMLConfiguration(core);
- Configuration castor = new CastorConfiguration(xml);
+ public static AbstractProperties newInstance() {
+ AbstractProperties core = new CoreProperties();
+ AbstractProperties xml = new XMLProperties(core);
+ AbstractProperties castor = new CastorProperties(xml);
return castor;
}
/**
- * Factory method for a XML configuration instance that uses the specified class loaders. The
- * configuration instance returned will be a CastorConfiguration with a XMLConfiguration and
- * a CoreConfiguration instance as parents. The CastorConfiguration holding user specific
+ * Factory method for a XML properties instance that uses the specified class loaders. The
+ * properties instance returned will be a CastorProperties with a XMLProperties and
+ * a CoreProperties instance as parents. The CastorProperties holding user specific
* properties is the only one that can be modified by put() and remove() methods.
- * XMLConfiguration and CoreConfiguration are responsble to deliver Castor's default values
+ * XMLProperties and CoreProperties are responsble to deliver Castor's default values
* if they have not been overwritten by the user.
*
* @param app Classloader to be used for all classes of Castor and its required libraries.
* @param domain Classloader to be used for all domain objects.
- * @return Configuration instance for Castor XML modul.
+ * @return Properties instance for Castor XML modul.
*/
- public static Configuration newInstance(final ClassLoader app, final ClassLoader domain) {
- Configuration core = new CoreConfiguration(app, domain);
- Configuration xml = new XMLConfiguration(core);
- Configuration castor = new CastorConfiguration(xml);
+ public static AbstractProperties newInstance(final ClassLoader app, final ClassLoader domain) {
+ AbstractProperties core = new CoreProperties(app, domain);
+ AbstractProperties xml = new XMLProperties(core);
+ AbstractProperties castor = new CastorProperties(xml);
return castor;
}
//--------------------------------------------------------------------------
/**
- * Construct a configuration with given parent. Application and domain class loaders will be
+ * Construct properties with given parent. Application and domain class loaders will be
* initialized to the ones of the parent.
* org.castor.jdo.use.jdbc30. */ - public static final String USE_JDBC30 = - "org.castor.jdo.use.jdbc30"; - - /** Property specifying whether JDBC proxy classes should be used - *
org.exolab.castor.persist.useProxies. */ - public static final String USE_JDBC_PROXIES = - "org.exolab.castor.persist.useProxies"; - - /** Property specifying whether to use ANSI-compliant SQL for MS SQL Server. - *
org.exolab.castor.jdo.sqlserver.ansi-compliant*/ - public static final String MSSQL_ANSI_COMPLIANT = - "org.exolab.castor.jdo.sqlserver.ansi-compliant"; - - //-------------------------------------------------------------------------- -} Index: cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToBigDecimal.java =================================================================== --- cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToBigDecimal.java (revision 8022) +++ cpa/src/main/java/org/castor/cpa/persistence/convertor/BooleanToBigDecimal.java (working copy) @@ -17,7 +17,7 @@ import java.math.BigDecimal; -import org.castor.core.util.Configuration; +import org.castor.core.util.AbstractProperties; /** * Convert
Boolean to BigDecimal.
@@ -49,7 +49,7 @@
/**
* {@inheritDoc}
*/
- public void configure(final Configuration configuration) { }
+ public void configure(final AbstractProperties properties) { }
/**
* {@inheritDoc}
Index: cpa/src/test/java/org/castor/cache/TestCacheFactoryRegistry.java
===================================================================
--- cpa/src/test/java/org/castor/cache/TestCacheFactoryRegistry.java (revision 8022)
+++ cpa/src/test/java/org/castor/cache/TestCacheFactoryRegistry.java (working copy)
@@ -51,9 +51,9 @@
import org.castor.cache.simple.TimeLimitedFactory;
import org.castor.cache.simple.Unlimited;
import org.castor.cache.simple.UnlimitedFactory;
-import org.castor.core.util.Configuration;
-import org.castor.core.util.ConfigurationException;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.core.util.PropertiesException;
+import org.castor.cpa.CPAProperties;
/**
* @author Werner Guttmann
@@ -83,38 +83,38 @@
Logger logger = Logger.getLogger(CacheFactoryRegistry.class);
Level level = logger.getLevel();
- assertEquals("org.castor.cache.Factories", CPAConfiguration.CACHE_FACTORIES);
+ assertEquals("org.castor.cache.Factories", CPAProperties.CACHE_FACTORIES);
- Configuration config = CPAConfiguration.newInstance();
- String memF = config.getString(CPAConfiguration.CACHE_FACTORIES);
+ AbstractProperties properties = CPAProperties.newInstance();
+ String memF = properties.getString(CPAProperties.CACHE_FACTORIES);
- config.remove(CPAConfiguration.CACHE_FACTORIES);
- new CacheFactoryRegistry(config);
+ properties.remove(CPAProperties.CACHE_FACTORIES);
+ new CacheFactoryRegistry(properties);
- config.put(CPAConfiguration.CACHE_FACTORIES, "");
- new CacheFactoryRegistry(config);
+ properties.put(CPAProperties.CACHE_FACTORIES, "");
+ new CacheFactoryRegistry(properties);
- config.put(CPAConfiguration.CACHE_FACTORIES, UnlimitedFactory.class.getName());
- new CacheFactoryRegistry(config);
+ properties.put(CPAProperties.CACHE_FACTORIES, UnlimitedFactory.class.getName());
+ new CacheFactoryRegistry(properties);
if (DISABLE_LOGGING) { logger.setLevel(Level.FATAL); }
- config.put(CPAConfiguration.CACHE_FACTORIES, "org.castor.cache.simple.UnknownFactory");
+ properties.put(CPAProperties.CACHE_FACTORIES, "org.castor.cache.simple.UnknownFactory");
try {
- new CacheFactoryRegistry(config);
+ new CacheFactoryRegistry(properties);
fail("Should have failed to create unknown class.");
- } catch (ConfigurationException ex) {
+ } catch (PropertiesException ex) {
assertTrue(true);
}
logger.setLevel(level);
- config.put(CPAConfiguration.CACHE_FACTORIES, memF);
+ properties.put(CPAProperties.CACHE_FACTORIES, memF);
}
public void testGetCacheNames() {
- Configuration config = CPAConfiguration.newInstance();
- Collection col = new CacheFactoryRegistry(config).getCacheNames();
+ AbstractProperties properties = CPAProperties.newInstance();
+ Collection col = new CacheFactoryRegistry(properties).getCacheNames();
assertEquals(13, col.size());
assertTrue(col.contains(CountLimited.TYPE));
assertTrue(col.contains(NoCache.TYPE));
@@ -132,8 +132,8 @@
}
public void testGetCacheFactories() {
- Configuration config = CPAConfiguration.newInstance();
- Collection col = new CacheFactoryRegistry(config).getCacheFactories();
+ AbstractProperties properties = CPAProperties.newInstance();
+ Collection col = new CacheFactoryRegistry(properties).getCacheFactories();
assertEquals(13, col.size());
assertTrue(containsInstanceOf(col, CountLimitedFactory.class));
assertTrue(containsInstanceOf(col, NoCacheFactory.class));
@@ -163,8 +163,8 @@
Logger logger = Logger.getLogger(CacheFactoryRegistry.class);
Level level = logger.getLevel();
- Configuration config = CPAConfiguration.newInstance();
- _registry = new CacheFactoryRegistry(config);
+ AbstractProperties properties = CPAProperties.newInstance();
+ _registry = new CacheFactoryRegistry(properties);
Cache cache = null;
Index: xml/src/main/java/org/exolab/castor/xml/AbstractXMLNaming.java
===================================================================
--- xml/src/main/java/org/exolab/castor/xml/AbstractXMLNaming.java (revision 8022)
+++ xml/src/main/java/org/exolab/castor/xml/AbstractXMLNaming.java (working copy)
@@ -73,7 +73,7 @@
/**
* Returns the default instance of XMLNaming.
- * @see org.exolab.castor.util.Configuration
+ * @see org.exolab.castor.util.AbstractProperties
**/
public static final XMLNaming getInstance() {
return new BackwardCompatibilityContext().getXMLNaming();
Index: cpa/src/main/java/org/castor/cpa/persistence/convertor/TypeConvertorRegistry.java
===================================================================
--- cpa/src/main/java/org/castor/cpa/persistence/convertor/TypeConvertorRegistry.java (revision 8022)
+++ cpa/src/main/java/org/castor/cpa/persistence/convertor/TypeConvertorRegistry.java (working copy)
@@ -19,8 +19,8 @@
import java.util.Iterator;
import java.util.Map;
-import org.castor.core.util.Configuration;
-import org.castor.cpa.CPAConfiguration;
+import org.castor.core.util.AbstractProperties;
+import org.castor.cpa.CPAProperties;
import org.exolab.castor.mapping.MappingException;
/**
@@ -43,17 +43,17 @@
/**
* Create a new registry instance of type convertors. The registry will be initialized
* with all type convertors specified through TYPE_CONVERTORS property of given
- * configuration. The configuration get also passed to the type converters for them to
+ * properties. The properties get also passed to the type converters for them to
* get any required property.
*
- * @param config The configuration to use.
+ * @param properties The properties to use.
*/
- public TypeConvertorRegistry(final Configuration config) {
- Object[] objects = config.getObjectArray(
- CPAConfiguration.TYPE_CONVERTORS, config.getApplicationClassLoader());
+ public TypeConvertorRegistry(final AbstractProperties properties) {
+ Object[] objects = properties.getObjectArray(
+ CPAProperties.TYPE_CONVERTORS, properties.getApplicationClassLoader());
for (int i = 0; i < objects.length; i++) {
TypeConvertor convertor = (TypeConvertor) objects[i];
- convertor.configure(config);
+ convertor.configure(properties);
putConvertor(convertor.fromType(), convertor.toType(), convertor);
}
Index: core/src/main/java/org/castor/core/util/CastorProperties.java
===================================================================
--- core/src/main/java/org/castor/core/util/CastorProperties.java (revision 8022)
+++ core/src/main/java/org/castor/core/util/CastorProperties.java (working copy)
@@ -17,32 +17,31 @@
*/
package org.castor.core.util;
-
/**
- * Castor configuration holding user properties.
+ * Properties class holding user properties.
*
* @version $Id: Configuration.java,v 1.8 2006/03/08 17:25:52 jens Exp $
* @author Ralf Joachim
* @since 1.1.3
*/
-public final class CastorConfiguration extends Configuration {
+public final class CastorProperties extends AbstractProperties {
//--------------------------------------------------------------------------
- /** Name of common Castor configuration file. */
+ /** Name of common Castor properties file. */
private static final String FILENAME = "castor.properties";
//--------------------------------------------------------------------------
/**
- * Construct a configuration with given parent. Application and domain class loaders will be
+ * Construct properties with given parent. Application and domain class loaders will be
* initialized to the ones of the parent.
*