You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2006/07/19 23:35:07 UTC

svn commit: r423615 [2/44] - in /incubator/openjpa/trunk: ./ openjpa-jdbc-5/ openjpa-jdbc-5/src/ openjpa-jdbc-5/src/main/ openjpa-jdbc-5/src/main/java/ openjpa-jdbc-5/src/main/java/org/ openjpa-jdbc-5/src/main/java/org/apache/ openjpa-jdbc-5/src/main/j...

Added: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ReverseMappingToolTask.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ReverseMappingToolTask.java?rev=423615&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ReverseMappingToolTask.java (added)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ReverseMappingToolTask.java Wed Jul 19 14:34:44 2006
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.apache.openjpa.jdbc.ant;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Properties;
+
+import org.apache.tools.ant.types.EnumeratedAttribute;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
+import org.apache.openjpa.jdbc.meta.PropertiesReverseCustomizer;
+import org.apache.openjpa.jdbc.meta.ReverseCustomizer;
+import org.apache.openjpa.jdbc.meta.ReverseMappingTool;
+import org.apache.openjpa.lib.ant.AbstractTask;
+import org.apache.openjpa.lib.conf.Configuration;
+import org.apache.openjpa.lib.conf.Configurations;
+import org.apache.openjpa.lib.util.CodeFormat;
+import org.apache.openjpa.lib.util.Files;
+
+/**
+ * Executes the {@link ReverseMappingTool} on the specified XML files.
+ * This task can take the following arguments:
+ * <ul>
+ * <li><code>package</code></li>
+ * <li><code>directory</code></li>
+ * <li><code>useSchemaName</code></li>
+ * <li><code>useForeignKeyName</code></li>
+ * <li><code>nullableAsObject</code></li>
+ * <li><code>blobAsObject</code></li>
+ * <li><code>typeMap</code></li>
+ * <li><code>primaryKeyOnJoin</code></li>
+ * <li><code>useDatastoreIdentity</code></li>
+ * <li><code>useBuiltinIdentityClass</code></li>
+ * <li><code>detachable</code></li>
+ * <li><code>inverseRelations</code></li>
+ * <li><code>discriminatorStrategy</code></li>
+ * <li><code>versionStrategy</code></li>
+ * <li><code>innerIdentityClasses</code></li>
+ * <li><code>identityClassSuffix</code></li>
+ * <li><code>metadata</code></li>
+ * <li><code>customizerClass</code></li>
+ * <li><code>customizerProperties</code></li>
+ * </ul> The task also accepts an embedded <code>codeFormat</code> element with
+ * attributes for the bean properties of the {@link CodeFormat}.
+ */
+public class ReverseMappingToolTask
+    extends AbstractTask {
+
+    protected ReverseMappingTool.Flags flags = new ReverseMappingTool.Flags();
+    protected String dirName = null;
+    protected String typeMap = null;
+    protected String customizerProperties = null;
+    protected String customizerClass =
+        PropertiesReverseCustomizer.class.getName();
+
+    /**
+     * Default constructor.
+     */
+    public ReverseMappingToolTask() {
+        flags.metaDataLevel = "package";
+        flags.format = new CodeFormat();
+    }
+
+    /**
+     * Set the package name for the generated classes.
+     */
+    public void setPackage(String pkg) {
+        flags.packageName = pkg;
+    }
+
+    /**
+     * Set the output directory for the generated classes.
+     */
+    public void setDirectory(String dirName) {
+        this.dirName = dirName;
+    }
+
+    /**
+     * Set whether to use the schema name when naming the classes.
+     */
+    public void setUseSchemaName(boolean useSchemaName) {
+        flags.useSchemaName = useSchemaName;
+    }
+
+    /**
+     * Set whether to use foreign key names to name relations.
+     */
+    public void setUseForeignKeyName(boolean useForeignKeyName) {
+        flags.useForeignKeyName = useForeignKeyName;
+    }
+
+    /**
+     * Set whether to represent nullable columns as primitive wrappers.
+     */
+    public void setNullableAsObject(boolean nullableAsObject) {
+        flags.nullableAsObject = nullableAsObject;
+    }
+
+    /**
+     * Set whether to represent blob columns as Java objects rather than
+     * byte[] fields.
+     */
+    public void setBlobAsObject(boolean blobAsObject) {
+        flags.blobAsObject = blobAsObject;
+    }
+
+    /**
+     * Set the SQL type map overrides.
+     */
+    public void setTypeMap(String typeMap) {
+        this.typeMap = typeMap;
+    }
+
+    /**
+     * Set whether to allow primary keys on join tables.
+     */
+    public void setPrimaryKeyOnJoin(boolean primaryKeyOnJoin) {
+        flags.primaryKeyOnJoin = primaryKeyOnJoin;
+    }
+
+    /**
+     * Set whether to use datastore identity by default.
+     */
+    public void setUseDataStoreIdentity(boolean useDataStoreIdentity) {
+        flags.useDataStoreIdentity = useDataStoreIdentity;
+    }
+
+    /**
+     * Set whether to use single field identity where possible.
+     */
+    public void setUseBuiltinIdentityClass(boolean useBuiltinIdentityClass) {
+        flags.useBuiltinIdentityClass = useBuiltinIdentityClass;
+    }
+
+    /**
+     * Set whether to generate inverse 1-many/1-1 relations for all many-1/1-1
+     * relations.
+     */
+    public void setInverseRelations(boolean inverseRelations) {
+        flags.inverseRelations = inverseRelations;
+    }
+
+    /**
+     * Set whether to make generated classes detachable.
+     */
+    public void setDetachable(boolean detachable) {
+        flags.detachable = detachable;
+    }
+
+    /**
+     * Default discriminator strategy for base class mappings.
+     */
+    public void setDiscriminatorStrategy(String discStrat) {
+        flags.discriminatorStrategy = discStrat;
+    }
+
+    /**
+     * Default version strategy for base class mappings.
+     */
+    public void setVersionStrategy(String versionStrat) {
+        flags.versionStrategy = versionStrat;
+    }
+
+    /**
+     * Whether or not to generate application identity classes as inner classes.
+     */
+    public void setInnerIdentityClasses(boolean innerAppId) {
+        flags.innerIdentityClasses = innerAppId;
+    }
+
+    /**
+     * The suffix to use to create the identity class name for a class, or
+     * for inner classes, the name of the inner class.
+     */
+    public void setIdentityClassSuffix(String suffix) {
+        flags.identityClassSuffix = suffix;
+    }
+
+    /**
+     * Set the level of the generated metadata.
+     */
+    public void setMetadata(Level level) {
+        flags.metaDataLevel = level.getValue();
+    }
+
+    /**
+     * Set a customizer class to use.
+     */
+    public void setCustomizerClass(String customizerClass) {
+        this.customizerClass = customizerClass;
+    }
+
+    /**
+     * Set a properties file to pass to the customizer class.
+     */
+    public void setCustomizerProperties(String customizerProperties) {
+        this.customizerProperties = customizerProperties;
+    }
+
+    public Object createCodeFormat() {
+        return flags.format;
+    }
+
+    protected Configuration newConfiguration() {
+        return new JDBCConfigurationImpl();
+    }
+
+    protected void executeOn(String[] files)
+        throws Exception {
+        ClassLoader loader = getClassLoader();
+        if (dirName != null && dirName.length() > 0)
+            flags.directory = Files.getFile(dirName, loader);
+        if (typeMap != null && typeMap.length() > 0)
+            flags.typeMap = Configurations.parseProperties(typeMap);
+
+        // load customizer properties
+        Properties customProps = new Properties();
+        File propsFile = Files.getFile(customizerProperties, loader);
+        if (propsFile != null && propsFile.exists())
+            customProps.load(new FileInputStream(propsFile));
+
+        // create and configure customizer
+        JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
+        flags.customizer = (ReverseCustomizer) Configurations.
+            newInstance(customizerClass, conf, null,
+                ReverseCustomizer.class.getClassLoader());
+        if (flags.customizer != null)
+            flags.customizer.setConfiguration(customProps);
+
+        ReverseMappingTool.run(conf, files, flags, loader);
+    }
+
+    public static class Level
+        extends EnumeratedAttribute {
+
+        public String[] getValues() {
+            return new String[]{
+                "package",
+                "class",
+            };
+        }
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ReverseMappingToolTask.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/SchemaToolTask.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/SchemaToolTask.java?rev=423615&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/SchemaToolTask.java (added)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/SchemaToolTask.java Wed Jul 19 14:34:44 2006
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.apache.openjpa.jdbc.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.EnumeratedAttribute;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
+import org.apache.openjpa.jdbc.schema.SchemaTool;
+import org.apache.openjpa.lib.ant.AbstractTask;
+import org.apache.openjpa.lib.conf.Configuration;
+import org.apache.openjpa.lib.util.Files;
+import org.apache.openjpa.lib.util.Localizer;
+
+/**
+ * Executes the {@link SchemaTool} on the specified XML schema definition
+ * files. This task can take the following arguments:
+ * <ul>
+ * <li><code>action</code></li>
+ * <li><code>ignoreErrors</code></li>
+ * <li><code>dropTables</code></li>
+ * <li><code>dropSequences</code></li>
+ * <li><code>openjpaTables</code></li>
+ * <li><code>primaryKeys</code></li>
+ * <li><code>foreignKeys</code></li>
+ * <li><code>indexes</code></li>
+ * <li><code>sequences</code></li>
+ * <li><code>record</code></li>
+ * <li><code>file</code></li>
+ * </ul> Of these arguments, only <code>action</code> is required.
+ */
+public class SchemaToolTask
+    extends AbstractTask {
+
+    private static final Localizer _loc = Localizer.forPackage
+        (SchemaToolTask.class);
+
+    protected SchemaTool.Flags flags = new SchemaTool.Flags();
+    protected String file = null;
+
+    /**
+     * Set the enumerated SchemaTool action type.
+     */
+    public void setAction(Action act) {
+        flags.action = act.getValue();
+    }
+
+    /**
+     * Set whether we want the SchemaTool to ignore SQL errors.
+     */
+    public void setIgnoreErrors(boolean ignoreErrors) {
+        flags.ignoreErrors = ignoreErrors;
+    }
+
+    /**
+     * Set whether to drop or reflect on OpenJPA tables.
+     */
+    public void setOpenJPATables(boolean openjpaTables) {
+        flags.openjpaTables = openjpaTables;
+    }
+
+    /**
+     * Set whether the SchemaTool should drop sequences.
+     */
+    public void setDropSequences(boolean dropSequences) {
+        flags.dropSequences = dropSequences;
+    }
+
+    /**
+     * Set whether the SchemaTool should manipulate sequences.
+     */
+    public void setSequences(boolean sequences) {
+        flags.sequences = sequences;
+    }
+
+    /**
+     * Set whether to generate primary key information.
+     */
+    public void setPrimaryKeys(boolean pks) {
+        flags.primaryKeys = pks;
+    }
+
+    /**
+     * Set whether to generate foreign key information.
+     */
+    public void setForeignKeys(boolean fks) {
+        flags.foreignKeys = fks;
+    }
+
+    /**
+     * Set whether to generate index information.
+     */
+    public void setIndexes(boolean idxs) {
+        flags.indexes = idxs;
+    }
+
+    /**
+     * Set whether the SchemaTool should record to the schema factory.
+     */
+    public void setRecord(boolean record) {
+        flags.record = record;
+    }
+
+    /**
+     * Set the output file we want the SchemaTool to write to.
+     */
+    public void setFile(String file) {
+        this.file = file;
+    }
+
+    protected Configuration newConfiguration() {
+        return new JDBCConfigurationImpl();
+    }
+
+    protected void executeOn(String[] files)
+        throws Exception {
+        assertFiles(files);
+
+        ClassLoader loader = getClassLoader();
+        flags.writer = Files.getWriter(file, loader);
+        if (!SchemaTool.run((JDBCConfiguration) getConfiguration(), files,
+            flags, loader))
+            throw new BuildException(_loc.get("bad-conf", "SchemaToolTask"));
+    }
+
+    public static class Action
+        extends EnumeratedAttribute {
+
+        public String[] getValues() {
+            return SchemaTool.ACTIONS;
+        }
+    }
+}
+

Propchange: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/SchemaToolTask.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/package.html
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/package.html?rev=423615&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/package.html (added)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/package.html Wed Jul 19 14:34:44 2006
@@ -0,0 +1,9 @@
+<html>
+<body>
+<p><strong>OpenJPA-JDBC Ant Tasks</strong></p>
+
+<p>
+    Ant tasks for JDBC OpenJPA tools.
+</p>
+</body>
+</html>

Propchange: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/package.html
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/FetchModeValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/FetchModeValue.java?rev=423615&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/FetchModeValue.java (added)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/FetchModeValue.java Wed Jul 19 14:34:44 2006
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.apache.openjpa.jdbc.conf;
+
+import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
+import org.apache.openjpa.lib.conf.IntValue;
+
+/**
+ * Value type used to represent fetch modes. This type is
+ * defined separately so that it can be used both in the global configuration
+ * and in class metadata with the same encapsulated configuration.
+ *
+ * @author Abe White
+ * @nojavadoc
+ */
+public class FetchModeValue
+    extends IntValue {
+
+    public static final String EAGER_NONE = "none";
+    public static final String EAGER_JOIN = "join";
+    public static final String EAGER_PARALLEL = "parallel";
+
+    private static String[] ALIASES = new String[]{
+        EAGER_PARALLEL, String.valueOf(EagerFetchModes.EAGER_PARALLEL),
+        EAGER_JOIN, String.valueOf(EagerFetchModes.EAGER_JOIN),
+        EAGER_NONE, String.valueOf(EagerFetchModes.EAGER_NONE),
+        // deprecated
+        "multiple", String.valueOf(EagerFetchModes.EAGER_PARALLEL),
+        "single", String.valueOf(EagerFetchModes.EAGER_JOIN),
+    };
+
+    public FetchModeValue(String prop) {
+        super(prop);
+        setAliases(ALIASES);
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/FetchModeValue.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java?rev=423615&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java (added)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java Wed Jul 19 14:34:44 2006
@@ -0,0 +1,609 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.apache.openjpa.jdbc.conf;
+
+import javax.sql.DataSource;
+
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
+import org.apache.openjpa.jdbc.kernel.LRSSizes;
+import org.apache.openjpa.jdbc.kernel.UpdateManager;
+import org.apache.openjpa.jdbc.meta.MappingDefaults;
+import org.apache.openjpa.jdbc.meta.MappingRepository;
+import org.apache.openjpa.jdbc.schema.DriverDataSource;
+import org.apache.openjpa.jdbc.schema.SchemaFactory;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.jdbc.sql.SQLFactory;
+import org.apache.openjpa.kernel.StoreContext;
+import org.apache.openjpa.lib.jdbc.ConnectionDecorator;
+import org.apache.openjpa.lib.jdbc.JDBCEvent;
+import org.apache.openjpa.lib.jdbc.JDBCListener;
+import org.apache.openjpa.meta.MetaDataFactory;
+
+/**
+ * Configuration that defines the properties necessary to configure
+ * runtime and connect to a JDBC DataSource.
+ *
+ * @author Marc Prud'hommeaux
+ */
+public interface JDBCConfiguration
+    extends OpenJPAConfiguration {
+
+    /**
+     * Name of the logger for SQL execution messages:
+     * <code>org.apache.openjpa.jdbc.SQL</code>.
+     */
+    public static final String LOG_SQL = "org.apache.openjpa.jdbc.SQL";
+
+    /**
+     * Name of the logger for JDBC-related messages:
+     * <code>org.apache.openjpa.jdbc.JDBC</code>.
+     */
+    public static final String LOG_JDBC = "org.apache.openjpa.jdbc.JDBC";
+
+    /**
+     * Name of the logger for schema-related messages:
+     * <code>org.apache.openjpa.jdbc.Schema</code>.
+     */
+    public static final String LOG_SCHEMA = "org.apache.openjpa.jdbc.Schema";
+
+    /**
+     * Default schema for unqualified tables.
+     */
+    public String getSchema();
+
+    /**
+     * Default schema for unqualified tables.
+     */
+    public void setSchema(String schema);
+
+    /**
+     * Comma-separated list of modifiable schemas for persistent instances.
+     */
+    public String getSchemas();
+
+    /**
+     * Comma-separated list of modifiable schemas for persistent instances.
+     */
+    public void setSchemas(String schemas);
+
+    /**
+     * Modificable schema components.
+     */
+    public String[] getSchemasList();
+
+    /**
+     * Modifiable schema components.
+     */
+    public void setSchemas(String[] schemas);
+
+    /**
+     * The transaction isolation level to use at the database level.
+     * Possible values are:
+     * <ul>
+     * <li><code>default</code>: The JDBC driver's default isolation level.</li>
+     * <li><code>none</code>: The standard JDBC
+     * {@link java.sql.Connection#TRANSACTION_NONE} level.</li>
+     * <li><code>read-committed</code>: The standard JDBC
+     * {@link java.sql.Connection#TRANSACTION_READ_COMMITTED} level.</li>
+     * <li><code>read-uncommitted</code>: The standard JDBC
+     * {@link java.sql.Connection#TRANSACTION_READ_UNCOMMITTED} level.</li>
+     * <li><code>repeatable-read</code>: The standard JDBC
+     * {@link java.sql.Connection#TRANSACTION_REPEATABLE_READ} level.</li>
+     * <li><code>serializable</code>: The standard JDBC
+     * {@link java.sql.Connection#TRANSACTION_SERIALIZABLE} level.</li>
+     * </ul>
+     */
+    public String getTransactionIsolation();
+
+    /**
+     * The transaction isolation level to use at the database level.
+     * Possible values are:
+     * <ul>
+     * <li><code>default</code>: The JDBC driver's default isolation level.</li>
+     * <li><code>none</code>: The standard JDBC
+     * {@link java.sql.Connection#TRANSACTION_NONE} level.</li>
+     * <li><code>read-committed</code>: The standard JDBC
+     * {@link java.sql.Connection#TRANSACTION_READ_COMMITTED} level.</li>
+     * <li><code>read-uncommitted</code>: The standard JDBC
+     * {@link java.sql.Connection#TRANSACTION_READ_UNCOMMITTED} level.</li>
+     * <li><code>repeatable-read</code>: The standard JDBC
+     * {@link java.sql.Connection#TRANSACTION_REPEATABLE_READ} level.</li>
+     * <li><code>serializable</code>: The standard JDBC
+     * {@link java.sql.Connection#TRANSACTION_SERIALIZABLE} level.</li>
+     * </ul>
+     */
+    public void setTransactionIsolation(String level);
+
+    /**
+     * Return the proper transaction isolation level constant from
+     * {@link java.sql.Connection}, or -1 for the default level.
+     */
+    public int getTransactionIsolationConstant();
+
+    /**
+     * Set the proper transaction isolation level constant from
+     * {@link java.sql.Connection}, or -1 for the default level.
+     */
+    public void setTransactionIsolation(int level);
+
+    /**
+     * The JDBC result set type. Defaults to <code>forward-only</code>.
+     * <ul>
+     * <li><code>forward-only</code>: The standard JDBC
+     * {@link java.sql.ResultSet#TYPE_FORWARD_ONLY} type.</li>
+     * <li><code>scroll-sensitive</code>: The standard JDBC
+     * {@link java.sql.ResultSet#TYPE_SCROLL_SENSITIVE} type.</li>
+     * <li><code>scroll-insensitive</code>: The standard JDBC
+     * {@link java.sql.ResultSet#TYPE_SCROLL_INSENSITIVE} type.</li>
+     * </ul>
+     */
+    public String getResultSetType();
+
+    /**
+     * Return the result set constant for the result set type.
+     */
+    public int getResultSetTypeConstant();
+
+    /**
+     * The JDBC result set type. Defaults to <code>forward-only</code>.
+     * <ul>
+     * <li><code>forward-only</code>: The standard JDBC
+     * {@link java.sql.ResultSet#TYPE_FORWARD_ONLY} type.</li>
+     * <li><code>scroll-sensitive</code>: The standard JDBC
+     * {@link java.sql.ResultSet#TYPE_SCROLL_SENSITIVE} type.</li>
+     * <li><code>scroll-insensitive</code>: The standard JDBC
+     * {@link java.sql.ResultSet#TYPE_SCROLL_INSENSITIVE} type.</li>
+     * </ul>
+     */
+    public void setResultSetType(String type);
+
+    /**
+     * Set the result set constant type.
+     */
+    public void setResultSetType(int type);
+
+    /**
+     * The JDBC fetch direction. Defaults to <code>forward</code>.
+     * <ul>
+     * <li><code>forward</code>: The standard JDBC
+     * {@link java.sql.ResultSet#FETCH_FORWARD} direction.</li>
+     * <li><code>reverse</code>: The standard JDBC
+     * {@link java.sql.ResultSet#FETCH_REVERSE} direction.</li>
+     * <li><code>unknown</code>: The standard JDBC
+     * {@link java.sql.ResultSet#FETCH_UNKNOWN} direction.</li>
+     * </ul>
+     */
+    public String getFetchDirection();
+
+    /**
+     * Return the result set constant for the fetch direction.
+     */
+    public int getFetchDirectionConstant();
+
+    /**
+     * The JDBC fetch direction. Defaults to <code>forward</code>.
+     * <ul>
+     * <li><code>forward</code>: The standard JDBC
+     * {@link java.sql.ResultSet#FETCH_FORWARD} direction.</li>
+     * <li><code>reverse</code>: The standard JDBC
+     * {@link java.sql.ResultSet#FETCH_REVERSE} direction.</li>
+     * <li><code>unknown</code>: The standard JDBC
+     * {@link java.sql.ResultSet#FETCH_UNKNOWN} direction.</li>
+     * </ul>
+     */
+    public void setFetchDirection(String direction);
+
+    /**
+     * Set the result set fetch direction constant.
+     */
+    public void setFetchDirection(int direction);
+
+    /**
+     * Specifies the default eager fetch mode to use. Defaults to
+     * <code>parallel</code> unless the query is by-oid. Possible values are:
+     * <ul>
+     * <li><code>none</code>: When querying for an object, do not try to
+     * select for related objects at the same time.</li>
+     * <li><code>join</code>: When querying for objects, also select for
+     * 1-1 relations in the configured fetch groups using joins.</li>
+     * <li><code>parallel</code>: When querying for objects, also select for
+     * both 1-1 relations using joins and to-many relations using batched
+     * selects.</li>
+     * </li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public String getEagerFetchMode();
+
+    /**
+     * Specifies the default eager fetch mode to use. Defaults to
+     * <code>parallel</code> unless the query is by-oid. Possible values are:
+     * <ul>
+     * <li><code>none</code>: When querying for an object, do not try to
+     * select for related objects at the same time.</li>
+     * <li><code>join</code>: When querying for objects, also select for
+     * 1-1 relations in the configured fetch groups using joins.</li>
+     * <li><code>parallel</code>: When querying for objects, also select for
+     * both 1-1 relations using joins and to-many relations using batched
+     * selects.</li>
+     * </li>
+     * </ul>
+     */
+    public void setEagerFetchMode(String mode);
+
+    /**
+     * Return the eager fetch mode as one of the following symbolic constants:
+     * <ul>
+     * <li>{@link EagerFetchModes#EAGER_NONE}</li>
+     * <li>{@link EagerFetchModes#EAGER_JOIN}</li>
+     * <li>{@link EagerFetchModes#EAGER_PARALLEL}</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public int getEagerFetchModeConstant();
+
+    /**
+     * Set the eager fetch mode as one of the following symbolic constants:
+     * <ul>
+     * <li>{@link EagerFetchModes#EAGER_NONE}</li>
+     * <li>{@link EagerFetchModes#EAGER_JOIN}</li>
+     * <li>{@link EagerFetchModes#EAGER_PARALLEL}</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void setEagerFetchMode(int eagerFetchMode);
+
+    /**
+     * Specifies the default subclass fetch mode to use. Defaults to
+     * <code>join</code> unless the query is by-oid. Possible values are:
+     * <ul>
+     * <li><code>none</code>: Only select base class data.</li>
+     * <li><code>join</code>: Select both base class and all possible subclass
+     * data using joins.</li>
+     * <li><code>parallel</code>: Select for each possible subclass
+     * separately.</li>
+     * </ul>
+     *
+     * @since 3.2
+     */
+    public String getSubclassFetchMode();
+
+    /**
+     * Specifies the default subclass fetch mode to use. Defaults to
+     * <code>join</code> unless the query is by-oid. Possible values are:
+     * <ul>
+     * <li><code>none</code>: Only select base class data.</li>
+     * <li><code>join</code>: Select both base class and all possible subclass
+     * data using joins.</li>
+     * <li><code>parallel</code>: Select for each possible subclass
+     * separately.</li>
+     * </ul>
+     *
+     * @since 3.2
+     */
+    public void setSubclassFetchMode(String mode);
+
+    /**
+     * Return the subclass fetch mode as one of the following symbolic
+     * constants:
+     * <ul>
+     * <li>{@link EagerFetchModes#EAGER_NONE}</li>
+     * <li>{@link EagerFetchModes#EAGER_JOIN}</li>
+     * <li>{@link EagerFetchModes#EAGER_PARALLEL}</li>
+     * </ul>
+     *
+     * @since 3.2
+     */
+    public int getSubclassFetchModeConstant();
+
+    /**
+     * Set the subclass fetch mode as one of the following symbolic constants:
+     * <ul>
+     * <li>{@link EagerFetchModes#EAGER_NONE}</li>
+     * <li>{@link EagerFetchModes#EAGER_JOIN}</li>
+     * <li>{@link EagerFetchModes#EAGER_PARALLEL}</li>
+     * </ul>
+     *
+     * @since 3.2
+     */
+    public void setSubclassFetchMode(int subclassFetchMode);
+
+    /**
+     * How to obtain the size of large result sets. Defaults to
+     * <code>unknown</code>.
+     * <ul>
+     * <li><code>unknown</code>: Do not attempt to calculate the size of
+     * large result sets; return {@link Integer#MAX_VALUE}.</li>
+     * <li><code>last</code>: For result sets that support random access,
+     * calculate the size using {@link java.sql.ResultSet#last}.</li>
+     * <li><code>query</code>: Use a separate COUNT query to calculate the
+     * size of the results.</li>
+     * </ul>
+     */
+    public String getLRSSize();
+
+    /**
+     * Return the {@link LRSSizes} constant for the large result set size
+     * setting.
+     */
+    public int getLRSSizeConstant();
+
+    /**
+     * How to obtain the size of large result sets. Defaults to
+     * <code>unknown</code>.
+     * <ul>
+     * <li><code>unknown</code>: Do not attempt to calculate the size of
+     * large result sets; return {@link Integer#MAX_VALUE}.</li>
+     * <li><code>last</code>: For result sets that support random access,
+     * calculate the size using {@link java.sql.ResultSet#last}.</li>
+     * <li><code>query</code>: Use a separate COUNT query to calculate the
+     * size of the results.</li>
+     * </ul>
+     */
+    public void setLRSSize(String lrsSize);
+
+    /**
+     * Set the fetch configuration large result set size constant.
+     */
+    public void setLRSSize(int size);
+
+    /**
+     * Whether OpenJPA should try to automatically refresh O/R mapping
+     * information and the database schema.
+     */
+    public String getSynchronizeMappings();
+
+    /**
+     * Whether OpenJPA should try to automatically refresh O/R mapping
+     * information and the database schema.
+     */
+    public void setSynchronizeMappings(String synchronizeMappings);
+
+    /**
+     * A comma-separated list of the {@link JDBCListener} plugins for
+     * listening to {@link JDBCEvent}s.
+     */
+    public String getJDBCListeners();
+
+    /**
+     * A comma-separated list of the {@link JDBCListener} plugins for
+     * listening to {@link JDBCEvent}s.
+     */
+    public void setJDBCListeners(String jdbcListeners);
+
+    /**
+     * The {@link JDBCListener}s to use.
+     */
+    public JDBCListener[] getJDBCListenerInstances();
+
+    /**
+     * The {@link JDBCListener}s to use.
+     */
+    public void setJDBCListeners(JDBCListener[] jdbcListeners);
+
+    /**
+     * A comma-separated list of the {@link ConnectionDecorator} for adding
+     * functionality to JDBC connections.
+     */
+    public String getConnectionDecorators();
+
+    /**
+     * A comma-separated list of the {@link ConnectionDecorator} for
+     * adding functionality to JDBC connections.
+     */
+    public void setConnectionDecorators(String decorators);
+
+    /**
+     * The {@link ConnectionDecorator}s to use.
+     */
+    public ConnectionDecorator[] getConnectionDecoratorInstances();
+
+    /**
+     * The {@link ConnectionDecorator}s to use.
+     */
+    public void setConnectionDecorators(ConnectionDecorator[] decorators);
+
+    /**
+     * The {@link DBDictionary} to use to define the RDBMS SQL information.
+     */
+    public String getDBDictionary();
+
+    /**
+     * The {@link DBDictionary} to use to define the RDBMS SQL information.
+     */
+    public void setDBDictionary(String dbdictionary);
+
+    /**
+     * The {@link DBDictionary} to use.
+     */
+    public DBDictionary getDBDictionaryInstance();
+
+    /**
+     * The {@link DBDictionary} to use.
+     */
+    public void setDBDictionary(DBDictionary dbdictionary);
+
+    /**
+     * The {@link UpdateManager} to use for managing SQL updates.
+     */
+    public String getUpdateManager();
+
+    /**
+     * The {@link UpdateManager} to use for managing SQL updates.
+     */
+    public void setUpdateManager(String updateManager);
+
+    /**
+     * The {@link UpdateManager} for runtime data store interaction.
+     */
+    public UpdateManager getUpdateManagerInstance();
+
+    /**
+     * The {@link UpdateManager} for runtime data store interaction.
+     */
+    public void setUpdateManager(UpdateManager updateManager);
+
+    /**
+     * The {@link DriverDataSource} to use for creating a {@link DataSource}
+     * from a JDBC {@link Driver}.
+     */
+    public String getDriverDataSource();
+
+    /**
+     * The {@link DriverDataSource} to use for creating a {@link DataSource}
+     * from a JDBC {@link Driver}.
+     */
+    public void setDriverDataSource(String driverDataSource);
+
+    /**
+     * Create an instance of the {@link DriverDataSource} to use
+     * for creating a {@link DataSource} from a JDBC {@link Driver}.
+     */
+    public DriverDataSource newDriverDataSourceInstance();
+
+    /**
+     * The plugin string for the {@link SchemaFactory} to use to provide
+     * schema information during system initialization.
+     */
+    public String getSchemaFactory();
+
+    /**
+     * The plugin string for the {@link SchemaFactory} to use to provide
+     * schema information during system initialization.
+     */
+    public void setSchemaFactory(String schemaFactory);
+
+    /**
+     * The {@link SchemaFactory} to use for schema information.
+     */
+    public SchemaFactory getSchemaFactoryInstance();
+
+    /**
+     * The {@link SchemaFactory} to use for schema information.
+     */
+    public void setSchemaFactory(SchemaFactory schemaFactory);
+
+    /**
+     * The SQL factory to use for SQL constructs.
+     */
+    public String getSQLFactory();
+
+    /**
+     * The SQL factory to use for SQL constructs.
+     */
+    public SQLFactory getSQLFactoryInstance();
+
+    /**
+     * The SQL factory to use for SQL constructs.
+     */
+    public void setSQLFactory(String sqlFactory);
+
+    /**
+     * The SQL factory to use for SQL constructs.
+     */
+    public void setSQLFactory(SQLFactory sqlFactory);
+
+    /**
+     * A plugin string describing the {@link MetaDataFactory} to use for
+     * loading and storing object-relational mapping data.
+     */
+    public String getMappingFactory();
+
+    /**
+     * A plugin string describing the {@link MetaDataFactory} to use for
+     * loading and storing object-relational mapping data.
+     */
+    public void setMappingFactory(String mappingFactory);
+
+    /**
+     * A plugin string describing the {@link MappingDefaults} to use.
+     *
+     * @since 4.0
+     */
+    public String getMappingDefaults();
+
+    /**
+     * A plugin string describing the {@link MappingDefaults} to use.
+     *
+     * @since 4.0
+     */
+    public void setMappingDefaults(String map);
+
+    /**
+     * The {@link MappingDefaults} to use with a repository.
+     *
+     * @since 4.0
+     */
+    public MappingDefaults getMappingDefaultsInstance();
+
+    /**
+     * The {@link MappingDefaults} to use with a repository.
+     *
+     * @since 4.0
+     */
+    public void setMappingDefaults(MappingDefaults map);
+
+    /**
+     * Return the mapping repository. Convenience method to cast from
+     * the internal metadata repository.
+     */
+    public MappingRepository getMappingRepository();
+
+    /**
+     * Return a new mapping repository instance for this configuration.
+     */
+    public MappingRepository newMappingRepositoryInstance();
+
+    /**
+     * Return a new mapping repository instance for this configuration with
+     * the specified {@link MetaDataFactory} and {@link MappingDefaults}.
+     */
+    public MappingRepository newMappingRepositoryInstance(MetaDataFactory mdf,
+        MappingDefaults mapDefaults);
+
+    /**
+     * Return the primary data source to use. The data source will
+     * automatically use the given context's user name and password on calls
+     * to {@link DataSource#getConnection}. If the given context is null, the
+     * data source will use the configuration's default connection user name
+     * and password. If those too are null and the first context has been
+     * obtained already, then the user name and password for that context
+     * will be used, as we know they represent a valid combination. This
+     * method avoids casting the result of
+     * {@link OpenJPAConfiguration#getConnectionFactory}, and avoids having to
+     * pass in the user name and password to obtain connections.
+     */
+    public DataSource getDataSource(StoreContext ctx);
+
+    /**
+     * Return the non-enlisted data source to use. If there is a valid
+     * non-xa connection factory configured, then it will be returned. Its
+     * default user name and password on calls to
+     * {@link DataSource#getConnection} will be the specificed connection 2
+     * user name and password. If those are null and the given context is
+     * non-null, its user name password will be used instead. If the context
+     * is null too, then the user name and password used to retrieve the first
+     * context will be used. If there is no second connection factory the
+     * primary connection factory is used.
+     *
+     * @see #getDataSource
+     */
+    public DataSource getDataSource2(StoreContext ctx);
+}

Propchange: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java?rev=423615&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java (added)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java Wed Jul 19 14:34:44 2006
@@ -0,0 +1,900 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.apache.openjpa.jdbc.conf;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import javax.sql.DataSource;
+
+import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
+import org.apache.openjpa.conf.ProductDerivations;
+import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
+import org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory;
+import org.apache.openjpa.jdbc.kernel.LRSSizes;
+import org.apache.openjpa.jdbc.kernel.PessimisticLockManager;
+import org.apache.openjpa.jdbc.kernel.UpdateManager;
+import org.apache.openjpa.jdbc.meta.MappingDefaults;
+import org.apache.openjpa.jdbc.meta.MappingRepository;
+import org.apache.openjpa.jdbc.schema.DataSourceFactory;
+import org.apache.openjpa.jdbc.schema.DriverDataSource;
+import org.apache.openjpa.jdbc.schema.SchemaFactory;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.jdbc.sql.DBDictionaryFactory;
+import org.apache.openjpa.jdbc.sql.SQLFactory;
+import org.apache.openjpa.kernel.BrokerImpl;
+import org.apache.openjpa.kernel.StoreContext;
+import org.apache.openjpa.lib.conf.IntValue;
+import org.apache.openjpa.lib.conf.ObjectValue;
+import org.apache.openjpa.lib.conf.PluginValue;
+import org.apache.openjpa.lib.conf.StringListValue;
+import org.apache.openjpa.lib.conf.StringValue;
+import org.apache.openjpa.lib.jdbc.ConnectionDecorator;
+import org.apache.openjpa.lib.jdbc.DecoratingDataSource;
+import org.apache.openjpa.lib.jdbc.JDBCListener;
+import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.meta.MetaDataFactory;
+import org.apache.openjpa.meta.MetaDataRepository;
+
+/**
+ * Default implementation of the {@link JDBCConfiguration} interface.
+ *
+ * @author Marc Prud'hommeaux
+ * @author Abe White
+ */
+public class JDBCConfigurationImpl
+    extends OpenJPAConfigurationImpl
+    implements JDBCConfiguration {
+
+    public StringValue schema;
+    public StringListValue schemas;
+    public IntValue transactionIsolation;
+    public IntValue resultSetType;
+    public IntValue fetchDirection;
+    public FetchModeValue eagerFetchMode;
+    public FetchModeValue subclassFetchMode;
+    public IntValue lrsSize;
+    public StringValue synchronizeMappings;
+    public ObjectValue jdbcListenerPlugins;
+    public ObjectValue connectionDecoratorPlugins;
+    public PluginValue dbdictionaryPlugin;
+    public ObjectValue updateManagerPlugin;
+    public ObjectValue schemaFactoryPlugin;
+    public ObjectValue sqlFactoryPlugin;
+    public ObjectValue mappingDefaultsPlugin;
+    public PluginValue driverDataSourcePlugin;
+    public MappingFactoryValue mappingFactoryPlugin;
+    public MappingRepositoryValue mappingRepositoryPlugin;
+
+    // used internally
+    private String firstUser = null;
+    private String firstPass = null;
+    private DecoratingDataSource dataSource = null;
+    private DecoratingDataSource dataSource2 = null;
+
+    /**
+     * Default constructor. Attempts to load default properties.
+     */
+    public JDBCConfigurationImpl() {
+        this(true);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param loadDefaults whether to attempt to load the default
+     * <code>org.apache.openjpa.properties</code> resource
+     */
+    public JDBCConfigurationImpl(boolean loadDefaults) {
+        this(true, loadDefaults);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param derivations whether to apply product derivations
+     * @param loadDefaults whether to attempt to load the default properties
+     */
+    public JDBCConfigurationImpl(boolean derivations, boolean loadDefaults) {
+        super(false, false);
+        String[] aliases;
+
+        schema = addString("jdbc.Schema");
+        schemas = addStringList("jdbc.Schemas");
+
+        transactionIsolation = addInt("jdbc.TransactionIsolation");
+        aliases = new String[]{
+            "default", String.valueOf(-1),
+            "none", String.valueOf(Connection.TRANSACTION_NONE),
+            "read-committed", String.valueOf
+            (Connection.TRANSACTION_READ_COMMITTED),
+            "read-uncommitted", String.valueOf
+            (Connection.TRANSACTION_READ_UNCOMMITTED),
+            "repeatable-read", String.valueOf
+            (Connection.TRANSACTION_REPEATABLE_READ),
+            "serializable", String.valueOf(Connection.TRANSACTION_SERIALIZABLE)
+        };
+        transactionIsolation.setAliases(aliases);
+        transactionIsolation.setDefault(aliases[0]);
+        transactionIsolation.set(-1);
+
+        resultSetType = addInt("jdbc.ResultSetType");
+        aliases = new String[]{
+            "forward-only", String.valueOf(ResultSet.TYPE_FORWARD_ONLY),
+            "scroll-sensitive", String.valueOf
+            (ResultSet.TYPE_SCROLL_SENSITIVE),
+            "scroll-insensitive", String.valueOf
+            (ResultSet.TYPE_SCROLL_INSENSITIVE),
+        };
+        resultSetType.setAliases(aliases);
+        resultSetType.setDefault(aliases[0]);
+        resultSetType.set(ResultSet.TYPE_FORWARD_ONLY);
+
+        fetchDirection = addInt("jdbc.FetchDirection");
+        aliases = new String[]{
+            "forward", String.valueOf(ResultSet.FETCH_FORWARD),
+            "reverse", String.valueOf(ResultSet.FETCH_REVERSE),
+            "unknown", String.valueOf(ResultSet.FETCH_UNKNOWN),
+        };
+        fetchDirection.setAliases(aliases);
+        fetchDirection.setDefault(aliases[0]);
+        fetchDirection.set(ResultSet.FETCH_FORWARD);
+
+        eagerFetchMode = new FetchModeValue("jdbc.EagerFetchMode");
+        eagerFetchMode.setDefault(FetchModeValue.EAGER_PARALLEL);
+        eagerFetchMode.set(EagerFetchModes.EAGER_PARALLEL);
+        addValue(eagerFetchMode);
+
+        subclassFetchMode = new FetchModeValue("jdbc.SubclassFetchMode");
+        subclassFetchMode.setDefault(FetchModeValue.EAGER_JOIN);
+        subclassFetchMode.set(EagerFetchModes.EAGER_JOIN);
+        addValue(subclassFetchMode);
+
+        lrsSize = addInt("jdbc.LRSSize");
+        aliases = new String[]{
+            "query", String.valueOf(LRSSizes.SIZE_QUERY),
+            "unknown", String.valueOf(LRSSizes.SIZE_UNKNOWN),
+            "last", String.valueOf(LRSSizes.SIZE_LAST),
+        };
+        lrsSize.setAliases(aliases);
+        lrsSize.setDefault(aliases[0]);
+        lrsSize.set(LRSSizes.SIZE_QUERY);
+
+        synchronizeMappings = addString("jdbc.SynchronizeMappings");
+        aliases = new String[]{ "false", null };
+        synchronizeMappings.setAliases(aliases);
+        synchronizeMappings.setDefault(aliases[0]);
+
+        jdbcListenerPlugins = addPluginList("jdbc.JDBCListeners");
+        jdbcListenerPlugins.setInstantiatingGetter("getJDBCListenerInstances");
+
+        connectionDecoratorPlugins = addPluginList
+            ("jdbc.ConnectionDecorators");
+        connectionDecoratorPlugins.setInstantiatingGetter
+            ("getConnectionDecoratorInstances");
+
+        dbdictionaryPlugin = addPlugin("jdbc.DBDictionary", true);
+        aliases = new String[]{
+            "access", "org.apache.openjpa.jdbc.sql.AccessDictionary",
+            "db2", "org.apache.openjpa.jdbc.sql.DB2Dictionary",
+            "derby", "org.apache.openjpa.jdbc.sql.DerbyDictionary",
+            "empress", "org.apache.openjpa.jdbc.sql.EmpressDictionary",
+            "foxpro", "org.apache.openjpa.jdbc.sql.FoxProDictionary",
+            "hsql", "org.apache.openjpa.jdbc.sql.HSQLDictionary",
+            "informix", "org.apache.openjpa.jdbc.sql.InformixDictionary",
+            "jdatastore", "org.apache.openjpa.jdbc.sql.JDataStoreDictionary",
+            "mysql", "org.apache.openjpa.jdbc.sql.MySQLDictionary",
+            "oracle", "org.apache.openjpa.jdbc.sql.OracleDictionary",
+            "pointbase", "org.apache.openjpa.jdbc.sql.PointbaseDictionary",
+            "postgres", "org.apache.openjpa.jdbc.sql.PostgresDictionary",
+            "sqlserver", "org.apache.openjpa.jdbc.sql.SQLServerDictionary",
+            "sybase", "org.apache.openjpa.jdbc.sql.SybaseDictionary",
+        };
+        dbdictionaryPlugin.setAliases(aliases);
+        dbdictionaryPlugin.setInstantiatingGetter("getDBDictionaryInstance");
+
+        updateManagerPlugin = addPlugin("jdbc.UpdateManager", true);
+        aliases = new String[]{
+            "default",
+            "org.apache.openjpa.jdbc.kernel.OperationOrderUpdateManager",
+            "operation-order",
+            "org.apache.openjpa.jdbc.kernel.OperationOrderUpdateManager",
+        };
+        updateManagerPlugin.setAliases(aliases);
+        updateManagerPlugin.setDefault(aliases[0]);
+        updateManagerPlugin.setString(aliases[0]);
+        updateManagerPlugin.setInstantiatingGetter("getUpdateManagerInstance");
+
+        driverDataSourcePlugin = addPlugin("jdbc.DriverDataSource",
+            false);
+        aliases = new String[]{
+            "simple", "org.apache.openjpa.jdbc.schema.SimpleDriverDataSource",
+        };
+        driverDataSourcePlugin.setAliases(aliases);
+        driverDataSourcePlugin.setDefault(aliases[0]);
+        driverDataSourcePlugin.setString(aliases[0]);
+
+        schemaFactoryPlugin = addPlugin("jdbc.SchemaFactory", true);
+        aliases = new String[]{
+            "dynamic", "org.apache.openjpa.jdbc.schema.DynamicSchemaFactory",
+            "native", "org.apache.openjpa.jdbc.schema.LazySchemaFactory",
+            "file", "org.apache.openjpa.jdbc.schema.FileSchemaFactory",
+            "table", "org.apache.openjpa.jdbc.schema.TableSchemaFactory",
+            // deprecated alias
+            "db", "org.apache.openjpa.jdbc.schema.TableSchemaFactory",
+        };
+        schemaFactoryPlugin.setAliases(aliases);
+        schemaFactoryPlugin.setDefault(aliases[0]);
+        schemaFactoryPlugin.setString(aliases[0]);
+        schemaFactoryPlugin.setInstantiatingGetter("getSchemaFactoryInstance");
+
+        sqlFactoryPlugin = addPlugin("jdbc.SQLFactory", true);
+        aliases = new String[]{
+            "default", "org.apache.openjpa.jdbc.sql.SQLFactoryImpl",
+        };
+        sqlFactoryPlugin.setAliases(aliases);
+        sqlFactoryPlugin.setDefault(aliases[0]);
+        sqlFactoryPlugin.setString(aliases[0]);
+        sqlFactoryPlugin.setInstantiatingGetter("getSQLFactoryInstance");
+
+        mappingFactoryPlugin = new MappingFactoryValue("jdbc.MappingFactory");
+        addValue(mappingFactoryPlugin);
+
+        mappingRepositoryPlugin = new MappingRepositoryValue
+            ("jdbc.MappingRepository");
+        addValue(mappingRepositoryPlugin);
+        aliases = new String[]{
+            "default", "org.apache.openjpa.jdbc.meta.MappingRepository",
+        };
+        mappingRepositoryPlugin.setAliases(aliases);
+        mappingRepositoryPlugin.setDefault(aliases[0]);
+        mappingRepositoryPlugin.setString(aliases[0]);
+        mappingRepositoryPlugin.setInstantiatingGetter
+            ("getMappingRepository");
+
+        mappingDefaultsPlugin = addPlugin("jdbc.MappingDefaults", true);
+        aliases = new String[]{
+            "default", "org.apache.openjpa.jdbc.meta.MappingDefaultsImpl",
+        };
+        mappingDefaultsPlugin.setAliases(aliases);
+        mappingDefaultsPlugin.setDefault(aliases[0]);
+        mappingDefaultsPlugin.setString(aliases[0]);
+        mappingDefaultsPlugin.setInstantiatingGetter
+            ("getMappingDefaultsInstance");
+
+        // set up broker factory defaults
+        brokerFactoryPlugin.setAlias("jdbc",
+            JDBCBrokerFactory.class.getName());
+        brokerFactoryPlugin.setDefault("jdbc");
+        brokerFactoryPlugin.setString("jdbc");
+
+        // set new default for lock manager
+        lockManagerPlugin.setAlias("pessimistic",
+            PessimisticLockManager.class.getName());
+        lockManagerPlugin.setDefault("pessimistic");
+        lockManagerPlugin.setString("pessimistic");
+
+        // native savepoint manager options
+        savepointManagerPlugin.setAlias("jdbc",
+            "org.apache.openjpa.jdbc.kernel.JDBC3SavepointManager");
+        savepointManagerPlugin.setAlias("oracle",
+            "org.apache.openjpa.jdbc.sql.OracleSavepointManager");
+
+        // set new aliases and defaults for sequence
+        seqPlugin.setAliases(JDBCSeqValue.ALIASES);
+        seqPlugin.setDefault(JDBCSeqValue.ALIASES[0]);
+        seqPlugin.setString(JDBCSeqValue.ALIASES[0]);
+
+        // this static initializer is to get past a weird
+        // ClassCircularityError that happens only under IBM's
+        // JDK 1.3.1 on Linux from within the JRun ClassLoader;
+        // while exact causes are unknown, it is almost certainly
+        // a bug in JRun, and we can get around it by forcing
+        // Instruction.class to be loaded and initialized
+        // before TypedInstruction.class
+        try {
+            serp.bytecode.lowlevel.Entry.class.getName();
+        } catch (Throwable t) {
+        }
+        try {
+            serp.bytecode.Instruction.class.getName();
+        } catch (Throwable t) {
+        }
+
+        supportedOptions().add(OPTION_QUERY_SQL);
+        supportedOptions().add(OPTION_JDBC_CONNECTION);
+        supportedOptions().remove(OPTION_VALUE_INCREMENT);
+        supportedOptions().remove(OPTION_NULL_CONTAINER);
+
+        if (derivations)
+            ProductDerivations.beforeConfigurationLoad(this);
+        if (loadDefaults)
+            loadDefaults();
+    }
+
+    /**
+     * Copy constructor
+     */
+    public JDBCConfigurationImpl(JDBCConfiguration conf) {
+        this(true, false);
+        if (conf != null)
+            fromProperties(conf.toProperties(false));
+    }
+
+    public void setSchema(String schema) {
+        assertNotReadOnly();
+        this.schema.setString(schema);
+    }
+
+    public String getSchema() {
+        return schema.getString();
+    }
+
+    public void setSchemas(String schemas) {
+        assertNotReadOnly();
+        this.schemas.setString(schemas);
+    }
+
+    public String getSchemas() {
+        return schemas.getString();
+    }
+
+    public void setSchemas(String[] schemas) {
+        assertNotReadOnly();
+        this.schemas.set(schemas);
+    }
+
+    public String[] getSchemasList() {
+        return schemas.get();
+    }
+
+    public void setTransactionIsolation(String transactionIsolation) {
+        assertNotReadOnly();
+        this.transactionIsolation.setString(transactionIsolation);
+    }
+
+    public String getTransactionIsolation() {
+        return transactionIsolation.getString();
+    }
+
+    public void setTransactionIsolation(int transactionIsolation) {
+        assertNotReadOnly();
+        this.transactionIsolation.set(transactionIsolation);
+    }
+
+    public int getTransactionIsolationConstant() {
+        return transactionIsolation.get();
+    }
+
+    public void setResultSetType(String resultSetType) {
+        assertNotReadOnly();
+        this.resultSetType.setString(resultSetType);
+    }
+
+    public String getResultSetType() {
+        return resultSetType.getString();
+    }
+
+    public void setResultSetType(int resultSetType) {
+        assertNotReadOnly();
+        this.resultSetType.set(resultSetType);
+    }
+
+    public int getResultSetTypeConstant() {
+        return resultSetType.get();
+    }
+
+    public void setFetchDirection(String fetchDirection) {
+        assertNotReadOnly();
+        this.fetchDirection.setString(fetchDirection);
+    }
+
+    public String getFetchDirection() {
+        return fetchDirection.getString();
+    }
+
+    public void setFetchDirection(int fetchDirection) {
+        assertNotReadOnly();
+        this.fetchDirection.set(fetchDirection);
+    }
+
+    public int getFetchDirectionConstant() {
+        return fetchDirection.get();
+    }
+
+    public void setEagerFetchMode(String eagerFetchMode) {
+        assertNotReadOnly();
+        this.eagerFetchMode.setString(eagerFetchMode);
+    }
+
+    public String getEagerFetchMode() {
+        return eagerFetchMode.getString();
+    }
+
+    public void setEagerFetchMode(int eagerFetchMode) {
+        assertNotReadOnly();
+        this.eagerFetchMode.set(eagerFetchMode);
+    }
+
+    public int getEagerFetchModeConstant() {
+        return eagerFetchMode.get();
+    }
+
+    public void setSubclassFetchMode(String subclassFetchMode) {
+        assertNotReadOnly();
+        this.subclassFetchMode.setString(subclassFetchMode);
+    }
+
+    public String getSubclassFetchMode() {
+        return subclassFetchMode.getString();
+    }
+
+    public void setSubclassFetchMode(int subclassFetchMode) {
+        assertNotReadOnly();
+        this.subclassFetchMode.set(subclassFetchMode);
+    }
+
+    public int getSubclassFetchModeConstant() {
+        return subclassFetchMode.get();
+    }
+
+    public void setLRSSize(String lrsSize) {
+        assertNotReadOnly();
+        this.lrsSize.setString(lrsSize);
+    }
+
+    public String getLRSSize() {
+        return lrsSize.getString();
+    }
+
+    public void setLRSSize(int lrsSize) {
+        assertNotReadOnly();
+        this.lrsSize.set(lrsSize);
+    }
+
+    public int getLRSSizeConstant() {
+        return lrsSize.get();
+    }
+
+    public void setSynchronizeMappings(String synchronizeMappings) {
+        assertNotReadOnly();
+        this.synchronizeMappings.set(synchronizeMappings);
+    }
+
+    public String getSynchronizeMappings() {
+        return synchronizeMappings.get();
+    }
+
+    public void setJDBCListeners(String jdbcListeners) {
+        assertNotReadOnly();
+        jdbcListenerPlugins.setString(jdbcListeners);
+    }
+
+    public String getJDBCListeners() {
+        return jdbcListenerPlugins.getString();
+    }
+
+    public void setJDBCListeners(JDBCListener[] listeners) {
+        assertNotReadOnly();
+        jdbcListenerPlugins.set(listeners);
+    }
+
+    public JDBCListener[] getJDBCListenerInstances() {
+        if (jdbcListenerPlugins.get() == null)
+            jdbcListenerPlugins.instantiate(JDBCListener.class, this);
+        return (JDBCListener[]) jdbcListenerPlugins.get();
+    }
+
+    public void setConnectionDecorators(String connectionDecorators) {
+        assertNotReadOnly();
+        connectionDecoratorPlugins.setString(connectionDecorators);
+    }
+
+    public String getConnectionDecorators() {
+        return connectionDecoratorPlugins.getString();
+    }
+
+    public void setConnectionDecorators(ConnectionDecorator[] decorators) {
+        assertNotReadOnly();
+        connectionDecoratorPlugins.set(decorators);
+    }
+
+    public ConnectionDecorator[] getConnectionDecoratorInstances() {
+        if (connectionDecoratorPlugins.get() == null) {
+            connectionDecoratorPlugins.instantiate
+                (ConnectionDecorator.class, this);
+        }
+        return (ConnectionDecorator[]) connectionDecoratorPlugins.get();
+    }
+
+    public void setDBDictionary(String dbdictionary) {
+        assertNotReadOnly();
+        dbdictionaryPlugin.setString(dbdictionary);
+    }
+
+    public String getDBDictionary() {
+        return dbdictionaryPlugin.getString();
+    }
+
+    public void setDBDictionary(DBDictionary dbdictionary) {
+        // we can't allow the dictionary to be set after the connection
+        // factory, due to initialization issues
+        if (connectionFactory.get() != null
+            || connectionFactory2.get() != null)
+            throw new IllegalStateException();
+
+        assertNotReadOnly();
+        dbdictionaryPlugin.set(dbdictionary);
+    }
+
+    public DBDictionary getDBDictionaryInstance() {
+        // lock on connection factory name, since getting the connection
+        // factory and getting the dictionary have to use the same locks to
+        // prevent deadlock since they call each other
+        DBDictionary dbdictionary = (DBDictionary) dbdictionaryPlugin.get();
+        if (dbdictionary == null) {
+            String clsName = dbdictionaryPlugin.getClassName();
+            String props = dbdictionaryPlugin.getProperties();
+            if (clsName != null && clsName.length() > 0) {
+                dbdictionary = DBDictionaryFactory.newDBDictionary
+                    (this, clsName, props);
+            } else {
+                // if the dictionary class isn't set, try to guess from
+                // connection URL and driver name
+                dbdictionary = DBDictionaryFactory.calculateDBDictionary
+                    (this, getConnectionURL(), getConnectionDriverName(),
+                        props);
+
+                // if the url and driver name aren't enough, connect to
+                // the DB and use the connection metadata
+                if (dbdictionary == null) {
+                    Log log = getLog(LOG_JDBC);
+                    if (log.isInfoEnabled()) {
+                        Localizer loc = Localizer.forPackage
+                            (JDBCConfigurationImpl.class);
+                        log.info(loc.get("connecting-for-dictionary"));
+                    }
+
+                    // use the base connection factory rather than the
+                    // configured data source b/c the data source relies
+                    // on passing the connection through the dictionary,
+                    // resulting in infinite loops
+                    DataSource ds = createConnectionFactory();
+                    dbdictionary = DBDictionaryFactory.newDBDictionary
+                        (this, getDataSource(null, ds), props);
+                }
+            }
+            dbdictionaryPlugin.set(dbdictionary, true);
+        }
+        return dbdictionary;
+    }
+
+    public void setUpdateManager(String updateManager) {
+        assertNotReadOnly();
+        updateManagerPlugin.setString(updateManager);
+    }
+
+    public String getUpdateManager() {
+        return updateManagerPlugin.getString();
+    }
+
+    public void setUpdateManager(UpdateManager updateManager) {
+        assertNotReadOnly();
+        updateManagerPlugin.set(updateManager);
+    }
+
+    public UpdateManager getUpdateManagerInstance() {
+        if (updateManagerPlugin.get() == null)
+            updateManagerPlugin.instantiate(UpdateManager.class, this);
+        return (UpdateManager) updateManagerPlugin.get();
+    }
+
+    public void setDriverDataSource(String driverDataSource) {
+        assertNotReadOnly();
+        driverDataSourcePlugin.setString(driverDataSource);
+    }
+
+    public String getDriverDataSource() {
+        return driverDataSourcePlugin.getString();
+    }
+
+    public DriverDataSource newDriverDataSourceInstance() {
+        return (DriverDataSource) driverDataSourcePlugin.
+            instantiate(DriverDataSource.class, this);
+    }
+
+    public void setSchemaFactory(String schemaFactory) {
+        assertNotReadOnly();
+        schemaFactoryPlugin.setString(schemaFactory);
+    }
+
+    public String getSchemaFactory() {
+        return schemaFactoryPlugin.getString();
+    }
+
+    public void setSchemaFactory(SchemaFactory schemaFactory) {
+        assertNotReadOnly();
+        schemaFactoryPlugin.set(schemaFactory);
+    }
+
+    public SchemaFactory getSchemaFactoryInstance() {
+        if (schemaFactoryPlugin.get() == null)
+            schemaFactoryPlugin.instantiate(SchemaFactory.class, this);
+        return (SchemaFactory) schemaFactoryPlugin.get();
+    }
+
+    public void setSQLFactory(String sqlFactory) {
+        assertNotReadOnly();
+        sqlFactoryPlugin.setString(sqlFactory);
+    }
+
+    public String getSQLFactory() {
+        return sqlFactoryPlugin.getString();
+    }
+
+    public void setSQLFactory(SQLFactory sqlFactory) {
+        assertNotReadOnly();
+        sqlFactoryPlugin.set(sqlFactory);
+    }
+
+    public SQLFactory getSQLFactoryInstance() {
+        if (sqlFactoryPlugin.get() == null)
+            sqlFactoryPlugin.instantiate(SQLFactory.class, this);
+        return (SQLFactory) sqlFactoryPlugin.get();
+    }
+
+    public String getMappingFactory() {
+        return mappingFactoryPlugin.getString();
+    }
+
+    public void setMappingFactory(String mapping) {
+        assertNotReadOnly();
+        mappingFactoryPlugin.setString(mapping);
+    }
+
+    public MetaDataFactory newMetaDataFactoryInstance() {
+        return mappingFactoryPlugin.instantiateMetaDataFactory(this,
+            metaFactoryPlugin, getMapping());
+    }
+
+    public void setMappingDefaults(String mapping) {
+        assertNotReadOnly();
+        this.mappingDefaultsPlugin.setString(mapping);
+    }
+
+    public String getMappingDefaults() {
+        return mappingDefaultsPlugin.getString();
+    }
+
+    public void setMappingDefaults(MappingDefaults mapping) {
+        assertNotReadOnly();
+        mappingDefaultsPlugin.set(mapping);
+    }
+
+    public MappingDefaults getMappingDefaultsInstance() {
+        if (mappingDefaultsPlugin.get() == null)
+            mappingDefaultsPlugin.instantiate(MappingDefaults.class, this);
+        return (MappingDefaults) mappingDefaultsPlugin.get();
+    }
+
+    public MappingRepository getMappingRepository() {
+        return (MappingRepository) getMetaDataRepository();
+    }
+
+    public MappingRepository newMappingRepositoryInstance() {
+        return (MappingRepository) getMappingRepository().newInstance();
+    }
+
+    public MappingRepository newMappingRepositoryInstance(MetaDataFactory mdf,
+        MappingDefaults mapDefaults) {
+        return (MappingRepository) getMappingRepository().
+            newInstance(mdf, mapDefaults);
+    }
+
+    public MetaDataRepository getMetaDataRepository() {
+        if (metaRepos == null) {
+            mappingRepositoryPlugin.instantiate(MappingRepository.class, this);
+            metaRepos = (MetaDataRepository) mappingRepositoryPlugin.get();
+        }
+        return metaRepos;
+    }
+
+    public BrokerImpl newBrokerInstance(String user, String pass) {
+        BrokerImpl broker = super.newBrokerInstance(user, pass);
+
+        // record first non-null broker user and pass in case no global settings
+        if (broker != null && user != null && firstUser == null) {
+            firstUser = user;
+            firstPass = pass;
+        }
+        return broker;
+    }
+
+    public Object getConnectionFactory() {
+        // override to configure data source
+        if (dataSource == null) {
+            DecoratingDataSource ds = createConnectionFactory();
+            dataSource = DataSourceFactory.installDBDictionary
+                (getDBDictionaryInstance(), ds, this, false);
+        }
+        return dataSource;
+    }
+
+    public void setConnectionFactory(Object factory) {
+        // there's a lot of one-time initialization involved for
+        // connection factories, so ignore resets
+        if (factory == connectionFactory.get())
+            return;
+
+        // override to configure data source
+        assertNotReadOnly();
+        if (factory != null) {
+            // need to ensure it is decorated before we set the dict
+            DecoratingDataSource ds =
+                setupConnectionFactory((DataSource) factory, false);
+            dataSource = DataSourceFactory.installDBDictionary
+                (getDBDictionaryInstance(), ds, this, false);
+        } else
+            connectionFactory.set(null);
+    }
+
+    /**
+     * Ensure that the specified DataSource is decorated and set in the cache.
+     */
+    private DecoratingDataSource setupConnectionFactory(DataSource ds,
+        boolean factory2) {
+        if (ds == null)
+            return null;
+
+        DecoratingDataSource dds;
+        if (ds instanceof DecoratingDataSource)
+            dds = (DecoratingDataSource) ds;
+        else
+            dds = DataSourceFactory.decorateDataSource(ds, this, factory2);
+
+        if (!factory2 && connectionFactory.get() != ds)
+            connectionFactory.set(dds, true);
+        else if (factory2 && connectionFactory2.get() != ds)
+            connectionFactory2.set(dds, true);
+
+        return dds;
+    }
+
+    public Object getConnectionFactory2() {
+        // override to configure data source
+        if (dataSource2 == null) {
+            DataSource ds = (DataSource) connectionFactory2.get();
+            if (ds == null) {
+                // the driver name is always required, so if not specified,
+                // then no connection factory 2
+                String driver = getConnection2DriverName();
+                if (driver != null && driver.length() > 0)
+                    ds = DataSourceFactory.newDataSource(this, true);
+            }
+            if (ds != null) {
+                DecoratingDataSource dds =
+                    setupConnectionFactory(ds, true); // before dict
+                dataSource2 = DataSourceFactory.installDBDictionary
+                    (getDBDictionaryInstance(), dds, this, true);
+            }
+        }
+        return dataSource2;
+    }
+
+    public void setConnectionFactory2(Object factory) {
+        if (factory == connectionFactory2.get())
+            return;
+
+        // override to configure data source
+        assertNotReadOnly();
+        if (factory != null) {
+            // need to ensure it is decorated before we set the dict
+            DecoratingDataSource ds = setupConnectionFactory((DataSource)
+                factory, true);
+            dataSource2 = DataSourceFactory.installDBDictionary
+                (getDBDictionaryInstance(), ds, this, true);
+        } else
+            connectionFactory2.set(null);
+    }
+
+    /**
+     * Create the connection factory if necessary.
+     */
+    private DecoratingDataSource createConnectionFactory() {
+        DataSource ds = (DataSource) connectionFactory.get();
+        if (ds != null)
+            return setupConnectionFactory(ds, false);
+
+        ds = (DataSource) super.getConnectionFactory(); // JNDI lookup
+        if (ds == null)
+            ds = DataSourceFactory.newDataSource(this, false);
+
+        return setupConnectionFactory(ds, false);
+    }
+
+    public DataSource getDataSource(StoreContext ctx) {
+        return getDataSource(ctx, (DataSource) getConnectionFactory());
+    }
+
+    public DataSource getDataSource2(StoreContext ctx) {
+        // if there is no connection factory 2, use the primary factory
+        DataSource ds = (DataSource) getConnectionFactory2();
+        if (ds == null)
+            return getDataSource(ctx);
+
+        // prefer the global connection 2 auth info if given
+        String user = getConnection2UserName();
+        String pass = getConnection2Password();
+        if (user == null && pass == null) {
+            // no global auth info; use the context if given, or the first
+            // context if not
+            if (ctx == null) {
+                user = firstUser;
+                pass = firstPass;
+            } else {
+                user = ctx.getConnectionUserName();
+                pass = ctx.getConnectionPassword();
+            }
+        }
+        return DataSourceFactory.defaultsDataSource(ds, user, pass);
+    }
+
+    /**
+     * This version allows us to pass in which data source to wrap internally;
+     * useful during initialization before the connection factory is
+     * completely configured.
+     */
+    private DataSource getDataSource(StoreContext ctx, DataSource ds) {
+        String user, pass;
+        if (ctx == null) {
+            // if no context, default to the global auth info, or the auth info
+            // of the first context if none
+            user = getConnectionUserName();
+            if (user == null)
+                user = firstUser;
+            pass = getConnectionPassword();
+            if (pass == null)
+                pass = firstPass;
+        } else {
+            // use the context's auth info
+            user = ctx.getConnectionUserName();
+            pass = ctx.getConnectionPassword();
+        }
+        return DataSourceFactory.defaultsDataSource(ds, user, pass);
+    }
+
+    /**
+     * Free the data sources.
+     */
+    public void close() {
+        if (dataSource != null) {
+            getDBDictionaryInstance().closeDataSource(dataSource);
+            connectionFactory.set(null, true); // so super doesn't close it
+        }
+        if (dataSource2 != null) {
+            getDBDictionaryInstance().closeDataSource(dataSource);
+            connectionFactory2.set(null, true); // so super doesn't close it
+        }
+        super.close();
+    }
+
+    protected boolean isInvalidProperty(String propName) {
+        // handle openjpa.jdbc.SomeMisspelledProperty, but not
+        // openjpa.someotherimplementation.SomeProperty
+        return super.isInvalidProperty(propName)
+            || propName.toLowerCase().startsWith("openjpa.jdbc");
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCProductDerivation.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCProductDerivation.java?rev=423615&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCProductDerivation.java (added)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCProductDerivation.java Wed Jul 19 14:34:44 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.apache.openjpa.jdbc.conf;
+
+import org.apache.openjpa.conf.BrokerFactoryValue;
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.conf.ProductDerivation;
+import org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory;
+import org.apache.openjpa.lib.conf.ConfigurationProvider;
+
+/**
+ * Sets JDBC as default store.
+ */
+public class JDBCProductDerivation
+    implements ProductDerivation {
+
+    public int getType() {
+        return TYPE_STORE;
+    }
+
+    public void beforeConfigurationConstruct(ConfigurationProvider cp) {
+        // default to JDBC when no broker factory set
+        if (BrokerFactoryValue.getBrokerFactoryClassName(cp) == null) {
+            cp.addProperty(BrokerFactoryValue.getBrokerFactoryProperty(cp),
+                JDBCBrokerFactory.class.getName());
+        }
+    }
+
+    public void beforeConfigurationLoad(OpenJPAConfiguration c) {
+    }
+
+    public void afterSpecificationSet(OpenJPAConfiguration c) {
+    }
+
+    public void afterClose(OpenJPAConfiguration c) {
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCProductDerivation.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCSeqValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCSeqValue.java?rev=423615&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCSeqValue.java (added)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCSeqValue.java Wed Jul 19 14:34:44 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.apache.openjpa.jdbc.conf;
+
+import org.apache.openjpa.conf.SeqValue;
+import org.apache.openjpa.jdbc.kernel.ClassTableJDBCSeq;
+import org.apache.openjpa.jdbc.kernel.NativeJDBCSeq;
+import org.apache.openjpa.jdbc.kernel.TableJDBCSeq;
+import org.apache.openjpa.jdbc.kernel.ValueTableJDBCSeq;
+import org.apache.openjpa.jdbc.meta.SequenceMapping;
+import org.apache.openjpa.kernel.TimeSeededSeq;
+
+/**
+ * Adds additional aliases to base {@link SeqValue}. This subclass is
+ * not added to the configuration object because it is not visible to it.
+ * Therefore, this class should not attempt to alter sequence instantiation
+ * behavior. The aliases defined by this subclass are added to the
+ * configuration, however, and this subclass may also be instantiated by
+ * other components for creation of sequences without manual alias setting.
+ *
+ * @author Abe White
+ * @nojavadoc
+ */
+public class JDBCSeqValue
+    extends SeqValue {
+
+    static final String[] ALIASES = new String[]{
+        SequenceMapping.IMPL_TABLE, TableJDBCSeq.class.getName(),
+        SequenceMapping.IMPL_VALUE_TABLE, ValueTableJDBCSeq.class.getName(),
+        SequenceMapping.IMPL_CLASS_TABLE, ClassTableJDBCSeq.class.getName(),
+        SequenceMapping.IMPL_NATIVE, NativeJDBCSeq.class.getName(),
+        SequenceMapping.IMPL_TIME, TimeSeededSeq.class.getName(),
+        // deprecated aliases
+        "db", TableJDBCSeq.class.getName(),
+        "db-class", ClassTableJDBCSeq.class.getName(),
+        "sjvm", TimeSeededSeq.class.getName(),
+    };
+
+    public JDBCSeqValue(String prop) {
+        super(prop);
+        setAliases(ALIASES);
+        setDefault(ALIASES[0]);
+        setClassName(ALIASES[1]);
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCSeqValue.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingFactoryValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingFactoryValue.java?rev=423615&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingFactoryValue.java (added)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingFactoryValue.java Wed Jul 19 14:34:44 2006
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.apache.openjpa.jdbc.conf;
+
+import org.apache.openjpa.jdbc.meta.MetaDataPlusMappingFactory;
+import org.apache.openjpa.lib.conf.Configuration;
+import org.apache.openjpa.lib.conf.Configurations;
+import org.apache.openjpa.lib.conf.PluginValue;
+import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.meta.MetaDataFactory;
+
+/**
+ * Handles the complex logic of creating a {@link MetaDataFactory} for
+ * combined metadata and mapping.
+ *
+ * @author Abe White
+ * @nojavadoc
+ */
+public class MappingFactoryValue
+    extends PluginValue {
+
+    private static final Localizer _loc = Localizer.forPackage
+        (MappingFactoryValue.class);
+
+    private String[] _metaFactoryDefaults = null;
+    private String[] _mappedMetaFactoryDefaults = null;
+
+    public MappingFactoryValue(String prop) {
+        super(prop, false);
+    }
+
+    /**
+     * Default setting for a given <code>MetaDataFactory</code> alias setting.
+     * If a <code>MappingFactory</code> value is not supplied, we check these
+     * defaults against the <code>MetaDataFactory</code> setting. If the
+     * <code>MetaDataFactory</code> does not have a default, we assume it
+     * handles both metadata and mapping factory.
+     */
+    public void setMetaDataFactoryDefault(String metaAlias,
+        String mappingAlias) {
+        _metaFactoryDefaults = setAlias(metaAlias, mappingAlias,
+            _metaFactoryDefaults);
+    }
+
+    /**
+     * If the <code>Mapping</code> property is set, we check these defaults
+     * before checking metadata factory defaults.
+     */
+    public void setMappedMetaDataFactoryDefault(String metaAlias,
+        String mappingAlias) {
+        _mappedMetaFactoryDefaults = setAlias(metaAlias, mappingAlias,
+            _mappedMetaFactoryDefaults);
+    }
+
+    /**
+     * Intantiate a {@link MetaDataFactory} responsible for both metadata and
+     * mapping.
+     */
+    public MetaDataFactory instantiateMetaDataFactory(Configuration conf,
+        PluginValue metaPlugin, String mapping) {
+        return instantiateMetaDataFactory(conf, metaPlugin, mapping, true);
+    }
+
+    /**
+     * Intantiate a {@link MetaDataFactory} responsible for both metadata and
+     * mapping.
+     */
+    public MetaDataFactory instantiateMetaDataFactory(Configuration conf,
+        PluginValue metaPlugin, String mapping, boolean fatal) {
+        String clsName = getClassName();
+        String props = getProperties();
+        String metaClsName = metaPlugin.getClassName();
+        String metaProps = metaPlugin.getProperties();
+
+        // if no mapping factory set, check for default for this factory
+        if (clsName == null || clsName.length() == 0) {
+            String def;
+            if (mapping != null) {
+                def = unalias(metaPlugin.alias(metaClsName),
+                    _mappedMetaFactoryDefaults, true);
+                if (def != null)
+                    clsName = unalias(def);
+            }
+            if (clsName == null) {
+                def = unalias(metaPlugin.alias(metaClsName),
+                    _metaFactoryDefaults, true);
+                if (def != null)
+                    clsName = unalias(def);
+            }
+        }
+
+        // if mapping factory and metadata factory the same, combine
+        // into metadata factory
+        if (clsName != null && clsName.equals(metaClsName)) {
+            if (props != null && metaProps == null)
+                metaProps = props;
+            else if (props != null)
+                metaProps += "," + props;
+            clsName = null;
+            props = null;
+        }
+
+        // instantiate factories
+        MetaDataFactory map = (MetaDataFactory) newInstance(clsName,
+            MetaDataFactory.class, conf, fatal);
+        MetaDataFactory meta;
+        if (map != null
+            && map.getClass().getName().indexOf("Deprecated") != -1) {
+            // deprecated mapping factories take over metadata too, so we have
+            // to special-case them to treat them like metadata factory only
+            meta = map;
+            map = null;
+        } else {
+            meta = (MetaDataFactory) metaPlugin.newInstance
+                (metaClsName, MetaDataFactory.class, conf, fatal);
+        }
+
+        // configure factories.  if only meta factory, allow user to specify
+        // its mapping properties in the mapping factory setting
+        if (map == null && props != null) {
+            if (metaProps == null)
+                metaProps = props;
+            else
+                metaProps += ", " + props;
+        }
+        Configurations.configureInstance(map, conf, props,
+            (fatal) ? getProperty() : null);
+        Configurations.configureInstance(meta, conf, metaProps,
+            (fatal) ? metaPlugin.getProperty() : null);
+
+        Log log = conf.getLog(JDBCConfiguration.LOG_METADATA);
+        if (log.isTraceEnabled()) {
+            log.trace(_loc.get("meta-factory", meta));
+            if (map != null)
+                log.trace(_loc.get("map-factory", map));
+        }
+
+        // if no mapping setting, return meta factory alone, assuming it handles
+        // both metadata and mapping
+        MetaDataFactory ret = (map == null) ? meta
+            : new MetaDataPlusMappingFactory(meta, map);
+        return ret;
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingFactoryValue.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingRepositoryValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingRepositoryValue.java?rev=423615&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingRepositoryValue.java (added)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingRepositoryValue.java Wed Jul 19 14:34:44 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.apache.openjpa.jdbc.conf;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.openjpa.jdbc.meta.MappingRepository;
+import org.apache.openjpa.lib.conf.Configuration;
+import org.apache.openjpa.lib.conf.PluginValue;
+import org.apache.openjpa.lib.util.Localizer;
+import serp.util.Strings;
+
+/**
+ * Handles the complex logic of creating a {@link MappingRepository} for
+ * a given configuration.
+ *
+ * @author Marc Prud'hommeaux
+ * @nojavadoc
+ */
+public class MappingRepositoryValue
+    extends PluginValue {
+
+    private static final Localizer _loc = Localizer.forPackage
+        (MappingRepositoryValue.class);
+
+    public MappingRepositoryValue(String prop) {
+        super(prop, true);
+    }
+
+    public Object newInstance(String clsName, Class type,
+        Configuration conf, boolean fatal) {
+        // since the MappingRepository takes a JDBConfiguration constructor,
+        // we need to manually perform the instantiation
+        try {
+            Class cls = Strings.toClass(clsName, type.getClassLoader());
+
+            return cls.getConstructor(new Class[]{ JDBCConfiguration.class }).
+                newInstance(new Object[]{ conf });
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (InvocationTargetException e) {
+            if (e.getTargetException()instanceof RuntimeException)
+                throw(RuntimeException) e.getTargetException();
+
+            // fall back to default behavior for better error reporting
+            return super.newInstance(clsName, type, conf, fatal);
+        } catch (Exception e) {
+            // fall back to default behavior for better error reporting
+            return super.newInstance(clsName, type, conf, fatal);
+        }
+    }
+}