openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r422262 - in /incubator/openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/conf/ openjpa-kernel/src/main/java/org/apache/openjpa/event/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-lib/src/main/java/org/apache...
Date Sat, 15 Jul 2006 16:40:01 GMT
Author: pcl
Date: Sat Jul 15 09:40:00 2006
New Revision: 422262

URL: http://svn.apache.org/viewvc?rev=422262&view=rev
Log:
moved to raw 'openjpa.*' property prefix instead of 'org.apache.openjpa.*'; implemented system
to allow multiple property prefixes for configurations without relaxing any of the current
validations

Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/AutoDetachValue.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/BrokerFactoryValue.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/RemoteCommitProviderValue.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/RemoteCommitProvider.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/MapConfigurationProvider.java
    incubator/openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConfigurationProviderImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/AutoDetachValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/AutoDetachValue.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/AutoDetachValue.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/AutoDetachValue.java
Sat Jul 15 09:40:00 2006
@@ -44,8 +44,8 @@
 
     private int _flags;
 
-    public AutoDetachValue(String prop) {
-        super(prop);
+    public AutoDetachValue() {
+        super("AutoDetach");
         setAliases(ALIASES);
     }
 

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/BrokerFactoryValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/BrokerFactoryValue.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/BrokerFactoryValue.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/BrokerFactoryValue.java
Sat Jul 15 09:40:00 2006
@@ -15,7 +15,13 @@
  */
 package org.apache.openjpa.conf;
 
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+
 import org.apache.openjpa.kernel.BrokerFactory;
+import org.apache.openjpa.lib.conf.ConfigurationProvider;
 import org.apache.openjpa.lib.conf.PluginValue;
 
 /**
@@ -30,12 +36,18 @@
 public class BrokerFactoryValue
     extends PluginValue {
 
-    public static final String KEY = "org.apache.openjpa.BrokerFactory";
+    private static final String KEY = "BrokerFactory";
 
     private static final String[] ALIASES = new String[]{
         "abstractstore",
         "org.apache.openjpa.abstractstore.AbstractStoreBrokerFactory",
     };
+    
+    private static final Collection _prefixes = new HashSet();
+    
+    static {
+        _prefixes.add("openjpa");
+    }
 
     public BrokerFactoryValue() {
         this(KEY);
@@ -44,5 +56,36 @@
     public BrokerFactoryValue(String prop) {
         super(prop, false);
         setAliases(ALIASES);
+    }
+
+    /**
+     * Extract the concrete {@link BrokerFactory} class name that the specified
+     * configuration will use.
+     */
+    public static Object getBrokerFactoryClassName(ConfigurationProvider cp) {
+        Map props = cp.getProperties();
+        for (Iterator iter = _prefixes.iterator(); iter.hasNext(); ) {
+            Object bf = props.get(iter.next() + "." + KEY);
+            if (bf != null)
+                return  bf;
+        }
+        return null;
+    }
+
+    /**
+     * Return the property to use for setting the broker factory for 
+     * <code>cp</code>.
+     */
+    public static String getBrokerFactoryProperty(ConfigurationProvider cp) {
+        return _prefixes.iterator().next() + "." 
+            + BrokerFactoryValue.KEY; 
+    }
+    
+    /**
+     * Add <code>prefix</code> to the list of prefixes under which configuration
+     * properties may be scoped.
+     */
+    public static void addPropertyPrefix(String prefix) {
+        _prefixes.add(prefix);
     }
 }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
Sat Jul 15 09:40:00 2006
@@ -58,7 +58,7 @@
 /**
  * Implementation of the {@link OpenJPAConfiguration} interface.
  *  On construction, the class will attempt to locate a default properties
- * file called <code>org.apache.openjpa.properties</code> located at any top
level token
+ * file called <code>openjpa.properties</code> located at any top level token
  * of the CLASSPATH. See the {@link ConfigurationImpl} class description
  * for details.
  *
@@ -153,7 +153,7 @@
      * Constructor.
      *
      * @param loadDefaults whether to attempt to load the default
-     * <code>org.apache.openjpa.properties</code> resource
+     * <code>openjpa.properties</code> resource
      */
     public OpenJPAConfigurationImpl(boolean loadDefaults) {
         this(true, loadDefaults);
@@ -164,14 +164,14 @@
      *
      * @param derivations whether to apply product derivations
      * @param loadDefaults whether to attempt to load the default
-     * <code>org.apache.openjpa.properties</code> resource
+     * <code>openjpa.properties</code> resource
      */
     public OpenJPAConfigurationImpl(boolean derivations, boolean loadDefaults) {
         super(false);
         String[] aliases;
 
         // setup super's log factory plugin
-        logFactoryPlugin.setProperty("org.apache.openjpa.Log");
+        logFactoryPlugin.setProperty("Log");
         logFactoryPlugin
             .setAlias("openjpa", "org.apache.openjpa.lib.log.LogFactoryImpl");
         aliases = logFactoryPlugin.getAliases();
@@ -179,7 +179,7 @@
         logFactoryPlugin.setString(aliases[0]);
 
         classResolverPlugin =
-            addPlugin("org.apache.openjpa.ClassResolver", true);
+            addPlugin("ClassResolver", true);
         aliases = new String[]{
             "default", "org.apache.openjpa.util.ClassResolverImpl",
             // deprecated alias
@@ -193,14 +193,14 @@
         brokerFactoryPlugin = new BrokerFactoryValue();
         addValue(brokerFactoryPlugin);
 
-        brokerPlugin = addPlugin("org.apache.openjpa.BrokerImpl", false);
+        brokerPlugin = addPlugin("BrokerImpl", false);
         aliases = new String[]{ "default", BrokerImpl.class.getName() };
         brokerPlugin.setAliases(aliases);
         brokerPlugin.setDefault(aliases[0]);
         brokerPlugin.setString(aliases[0]);
 
         dataCacheManagerPlugin =
-            addPlugin("org.apache.openjpa.DataCacheManager", true);
+            addPlugin("DataCacheManager", true);
         aliases = new String[]{
             "default", DataCacheManagerImpl.class.getName(),
         };
@@ -209,7 +209,7 @@
         dataCacheManagerPlugin.setString(aliases[0]);
         dataCacheManagerPlugin.setInstantiatingGetter("getDataCacheManager");
 
-        dataCachePlugin = addPlugin("org.apache.openjpa.DataCache", false);
+        dataCachePlugin = addPlugin("DataCache", false);
         aliases = new String[]{
             "false", null,
             "true", ConcurrentDataCache.class.getName(),
@@ -219,11 +219,11 @@
         dataCachePlugin.setDefault(aliases[0]);
         dataCachePlugin.setString(aliases[0]);
 
-        dataCacheTimeout = addInt("org.apache.openjpa.DataCacheTimeout");
+        dataCacheTimeout = addInt("DataCacheTimeout");
         dataCacheTimeout.setDefault("-1");
         dataCacheTimeout.set(-1);
 
-        queryCachePlugin = addPlugin("org.apache.openjpa.QueryCache", true);
+        queryCachePlugin = addPlugin("QueryCache", true);
         aliases = new String[]{
             "true", ConcurrentQueryCache.class.getName(),
             "concurrent", ConcurrentQueryCache.class.getName(),
@@ -234,11 +234,11 @@
         queryCachePlugin.setString(aliases[0]);
 
         dynamicDataStructs =
-            addBoolean("org.apache.openjpa.DynamicDataStructs");
+            addBoolean("DynamicDataStructs");
         dynamicDataStructs.setDefault("false");
         dynamicDataStructs.set(false);
 
-        lockManagerPlugin = addPlugin("org.apache.openjpa.LockManager", false);
+        lockManagerPlugin = addPlugin("LockManager", false);
         aliases = new String[]{
             "none", "org.apache.openjpa.kernel.NoneLockManager",
             "version", "org.apache.openjpa.kernel.VersionLockManager",
@@ -248,7 +248,7 @@
         lockManagerPlugin.setString(aliases[0]);
 
         inverseManagerPlugin =
-            addPlugin("org.apache.openjpa.InverseManager", false);
+            addPlugin("InverseManager", false);
         aliases = new String[]{
             "false", null,
             "true", "org.apache.openjpa.kernel.InverseManager",
@@ -258,7 +258,7 @@
         inverseManagerPlugin.setString(aliases[0]);
 
         savepointManagerPlugin =
-            addPlugin("org.apache.openjpa.SavepointManager", true);
+            addPlugin("SavepointManager", true);
         aliases = new String[]{
             "in-mem", "org.apache.openjpa.kernel.InMemorySavepointManager",
         };
@@ -269,7 +269,7 @@
             ("getSavepointManagerInstance");
 
         orphanedKeyPlugin =
-            addPlugin("org.apache.openjpa.OrphanedKeyAction", true);
+            addPlugin("OrphanedKeyAction", true);
         aliases = new String[]{
             "log", "org.apache.openjpa.event.LogOrphanedKeyAction",
             "exception", "org.apache.openjpa.event.ExceptionOrphanedKeyAction",
@@ -281,11 +281,10 @@
         orphanedKeyPlugin.setInstantiatingGetter
             ("getOrphanedKeyActionInstance");
 
-        remoteProviderPlugin = new RemoteCommitProviderValue
-            ("org.apache.openjpa.RemoteCommitProvider");
+        remoteProviderPlugin = new RemoteCommitProviderValue();
         addValue(remoteProviderPlugin);
 
-        transactionMode = addBoolean("org.apache.openjpa.TransactionMode");
+        transactionMode = addBoolean("TransactionMode");
         aliases = new String[]{
             "local", "false",
             "managed", "true",
@@ -294,7 +293,7 @@
         transactionMode.setDefault(aliases[0]);
 
         managedRuntimePlugin =
-            addPlugin("org.apache.openjpa.ManagedRuntime", true);
+            addPlugin("ManagedRuntime", true);
         aliases = new String[]{
             "auto", "org.apache.openjpa.ee.AutomaticManagedRuntime",
             "jndi", "org.apache.openjpa.ee.JNDIManagedRuntime",
@@ -306,7 +305,7 @@
         managedRuntimePlugin.setInstantiatingGetter
             ("getManagedRuntimeInstance");
 
-        proxyManagerPlugin = addPlugin("org.apache.openjpa.ProxyManager", true);
+        proxyManagerPlugin = addPlugin("ProxyManager", true);
         aliases = new String[]{ "default",
             "org.apache.openjpa.util.ProxyManagerImpl" };
         proxyManagerPlugin.setAliases(aliases);
@@ -314,43 +313,42 @@
         proxyManagerPlugin.setString(aliases[0]);
         proxyManagerPlugin.setInstantiatingGetter("getProxyManagerInstance");
 
-        mapping = addString("org.apache.openjpa.Mapping");
+        mapping = addString("Mapping");
         metaFactoryPlugin =
-            addPlugin("org.apache.openjpa.MetaDataFactory", false);
+            addPlugin("MetaDataFactory", false);
 
-        connectionFactory = addObject("org.apache.openjpa.ConnectionFactory");
+        connectionFactory = addObject("ConnectionFactory");
         connectionFactory.setInstantiatingGetter("getConnectionFactory");
 
-        connectionFactory2 = addObject("org.apache.openjpa.ConnectionFactory2");
+        connectionFactory2 = addObject("ConnectionFactory2");
         connectionFactory2.setInstantiatingGetter("getConnectionFactory2");
 
-        connectionUserName = addString("org.apache.openjpa.ConnectionUserName");
-        connectionPassword = addString("org.apache.openjpa.ConnectionPassword");
-        connectionURL = addString("org.apache.openjpa.ConnectionURL");
+        connectionUserName = addString("ConnectionUserName");
+        connectionPassword = addString("ConnectionPassword");
+        connectionURL = addString("ConnectionURL");
         connectionDriverName =
-            addString("org.apache.openjpa.ConnectionDriverName");
+            addString("ConnectionDriverName");
         connectionFactoryName =
-            addString("org.apache.openjpa.ConnectionFactoryName");
+            addString("ConnectionFactoryName");
         connectionProperties =
-            addString("org.apache.openjpa.ConnectionProperties");
-        connectionFactoryProperties = addString
-            ("org.apache.openjpa.ConnectionFactoryProperties");
+            addString("ConnectionProperties");
+        connectionFactoryProperties = addString("ConnectionFactoryProperties");
         connection2UserName =
-            addString("org.apache.openjpa.Connection2UserName");
+            addString("Connection2UserName");
         connection2Password =
-            addString("org.apache.openjpa.Connection2Password");
-        connection2URL = addString("org.apache.openjpa.Connection2URL");
+            addString("Connection2Password");
+        connection2URL = addString("Connection2URL");
         connection2DriverName =
-            addString("org.apache.openjpa.Connection2DriverName");
+            addString("Connection2DriverName");
         connection2Properties =
-            addString("org.apache.openjpa.Connection2Properties");
-        connectionFactory2Properties = addString
-            ("org.apache.openjpa.ConnectionFactory2Properties");
+            addString("Connection2Properties");
+        connectionFactory2Properties = addString(
+            "ConnectionFactory2Properties");
         connectionFactory2Name =
-            addString("org.apache.openjpa.ConnectionFactory2Name");
+            addString("ConnectionFactory2Name");
 
         connectionFactoryMode =
-            addBoolean("org.apache.openjpa.ConnectionFactoryMode");
+            addBoolean("ConnectionFactoryMode");
         aliases = new String[]{
             "local", "false",
             "managed", "true",
@@ -358,11 +356,11 @@
         connectionFactoryMode.setAliases(aliases);
         connectionFactoryMode.setDefault(aliases[0]);
 
-        optimistic = addBoolean("org.apache.openjpa.Optimistic");
+        optimistic = addBoolean("Optimistic");
         optimistic.setDefault("true");
         optimistic.set(true);
 
-        autoClear = addInt("org.apache.openjpa.AutoClear");
+        autoClear = addInt("AutoClear");
         aliases = new String[]{
             "datastore", String.valueOf(AutoClear.CLEAR_DATASTORE),
             "all", String.valueOf(AutoClear.CLEAR_ALL),
@@ -371,11 +369,11 @@
         autoClear.setDefault(aliases[0]);
         autoClear.set(AutoClear.CLEAR_DATASTORE);
 
-        retainState = addBoolean("org.apache.openjpa.RetainState");
+        retainState = addBoolean("RetainState");
         retainState.setDefault("true");
         retainState.set(true);
 
-        restoreState = addInt("org.apache.openjpa.RestoreState");
+        restoreState = addInt("RestoreState");
         aliases = new String[]{
             "none", String.valueOf(RestoreState.RESTORE_NONE),
             "false", String.valueOf(RestoreState.RESTORE_NONE),
@@ -388,10 +386,10 @@
         restoreState.setDefault(aliases[0]);
         restoreState.set(RestoreState.RESTORE_IMMUTABLE);
 
-        autoDetach = new AutoDetachValue("org.apache.openjpa.AutoDetach");
+        autoDetach = new AutoDetachValue();
         addValue(autoDetach);
 
-        detachStatePlugin = addPlugin("org.apache.openjpa.DetachState", true);
+        detachStatePlugin = addPlugin("DetachState", true);
         aliases = new String[]{
             "loaded", DetachOptions.Loaded.class.getName(),
             "fgs", DetachOptions.FetchGroups.class.getName(),
@@ -402,26 +400,26 @@
         detachStatePlugin.setString(aliases[0]);
         detachStatePlugin.setInstantiatingGetter("getDetachStateInstance");
 
-        ignoreChanges = addBoolean("org.apache.openjpa.IgnoreChanges");
+        ignoreChanges = addBoolean("IgnoreChanges");
 
         nontransactionalRead =
-            addBoolean("org.apache.openjpa.NontransactionalRead");
+            addBoolean("NontransactionalRead");
         nontransactionalRead.setDefault("true");
         nontransactionalRead.set(true);
 
         nontransactionalWrite =
-            addBoolean("org.apache.openjpa.NontransactionalWrite");
-        multithreaded = addBoolean("org.apache.openjpa.Multithreaded");
+            addBoolean("NontransactionalWrite");
+        multithreaded = addBoolean("Multithreaded");
 
-        fetchBatchSize = addInt("org.apache.openjpa.FetchBatchSize");
+        fetchBatchSize = addInt("FetchBatchSize");
         fetchBatchSize.setDefault("-1");
         fetchBatchSize.set(-1);
 
-        fetchGroups = addStringList("org.apache.openjpa.FetchGroups");
+        fetchGroups = addStringList("FetchGroups");
         fetchGroups.setDefault("default");
         fetchGroups.set(new String[]{ "default" });
 
-        flushBeforeQueries = addInt("org.apache.openjpa.FlushBeforeQueries");
+        flushBeforeQueries = addInt("FlushBeforeQueries");
         aliases = new String[]{
             "true", String.valueOf(QueryFlushModes.FLUSH_TRUE),
             "false", String.valueOf(QueryFlushModes.FLUSH_FALSE),
@@ -432,11 +430,11 @@
         flushBeforeQueries.setDefault(aliases[0]);
         flushBeforeQueries.set(QueryFlushModes.FLUSH_TRUE);
 
-        lockTimeout = addInt("org.apache.openjpa.LockTimeout");
+        lockTimeout = addInt("LockTimeout");
         lockTimeout.setDefault("-1");
         lockTimeout.set(-1);
 
-        readLockLevel = addInt("org.apache.openjpa.ReadLockLevel");
+        readLockLevel = addInt("ReadLockLevel");
         aliases = new String[]{
             "read", String.valueOf(LockLevels.LOCK_READ),
             "write", String.valueOf(LockLevels.LOCK_WRITE),
@@ -446,7 +444,7 @@
         readLockLevel.setDefault(aliases[0]);
         readLockLevel.set(LockLevels.LOCK_READ);
 
-        writeLockLevel = addInt("org.apache.openjpa.WriteLockLevel");
+        writeLockLevel = addInt("WriteLockLevel");
         aliases = new String[]{
             "read", String.valueOf(LockLevels.LOCK_READ),
             "write", String.valueOf(LockLevels.LOCK_WRITE),
@@ -456,12 +454,12 @@
         writeLockLevel.setDefault(aliases[1]);
         writeLockLevel.set(LockLevels.LOCK_WRITE);
 
-        seqPlugin = new SeqValue("org.apache.openjpa.Sequence");
+        seqPlugin = new SeqValue("Sequence");
         seqPlugin.setInstantiatingGetter("getSequenceInstance");
         addValue(seqPlugin);
 
         connectionRetainMode =
-            addInt("org.apache.openjpa.ConnectionRetainMode");
+            addInt("ConnectionRetainMode");
         aliases = new String[]{
             "on-demand",
             String.valueOf(ConnectionRetainModes.CONN_RETAIN_DEMAND),
@@ -479,20 +477,20 @@
         connectionRetainMode.set(ConnectionRetainModes.CONN_RETAIN_DEMAND);
 
         filterListenerPlugins =
-            addPluginList("org.apache.openjpa.FilterListeners");
+            addPluginList("FilterListeners");
         filterListenerPlugins.setInstantiatingGetter
             ("getFilterListenerInstances");
 
         aggregateListenerPlugins =
-            addPluginList("org.apache.openjpa.AggregateListeners");
+            addPluginList("AggregateListeners");
         aggregateListenerPlugins.setInstantiatingGetter
             ("getAggregateListenerInstances");
 
         retryClassRegistration =
-            addBoolean("org.apache.openjpa.RetryClassRegistration");
+            addBoolean("RetryClassRegistration");
 
         compatibilityPlugin =
-            addPlugin("org.apache.openjpa.Compatibility", true);
+            addPlugin("Compatibility", true);
         aliases = new String[]{ "default", Compatibility.class.getName() };
         compatibilityPlugin.setAliases(aliases);
         compatibilityPlugin.setDefault(aliases[0]);
@@ -1409,15 +1407,6 @@
         ImplHelper.close(metaRepos);
         super.close();
         ProductDerivations.afterClose(this);
-    }
-
-    protected boolean isInvalidProperty(String propName) {
-        // handle warnings for org.apache.openjpa.SomeString, but not for
-        // org.apache.openjpa.some.subpackage.SomeString, since it might be valid for some
-        // specific implementation of OpenJPA
-        return propName.toLowerCase().startsWith("org.apache.openjpa.")
-            && propName.length() > 5
-            && propName.indexOf('.', 5) == -1;
     }
 
     public Log getConfigurationLog() {

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/RemoteCommitProviderValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/RemoteCommitProviderValue.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/RemoteCommitProviderValue.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/RemoteCommitProviderValue.java
Sat Jul 15 09:40:00 2006
@@ -42,8 +42,8 @@
     private Options _opts = null;
     private Boolean _transmitPersIds = null;
 
-    public RemoteCommitProviderValue(String prop) {
-        super(prop, true);
+    public RemoteCommitProviderValue() {
+        super("RemoteCommitProvider", true);
         setAliases(ALIASES);
     }
 

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/RemoteCommitProvider.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/RemoteCommitProvider.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/RemoteCommitProvider.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/RemoteCommitProvider.java
Sat Jul 15 09:40:00 2006
@@ -21,7 +21,7 @@
  * An entity that is responsible for communicating commit
  * notification to other {@link RemoteCommitEventManager}s. Each
  * event manager creates a remote commit provider, based on
- * the values of the <code>org.apache.openjpa.RemoteCommitProvider</code>
+ * the values of the <code>openjpa.RemoteCommitProvider</code>
  * configuration property.
  *  An adapter that implements {@link TransactionListener} is
  * registered with each {@link org.apache.openjpa.kernel.Broker}. This adapter

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java
Sat Jul 15 09:40:00 2006
@@ -120,8 +120,7 @@
         if (loader == null)
             loader = Thread.currentThread().getContextClassLoader();
 
-        Map props = conf.getProperties();
-        Object cls = props.get(BrokerFactoryValue.KEY);
+        Object cls = BrokerFactoryValue.getBrokerFactoryClassName(conf);
         if (cls instanceof Class)
             return (Class) cls;
 
@@ -129,8 +128,8 @@
         value.setString((String) cls);
         String clsName = value.getClassName();
         if (clsName == null)
-            throw new UserException(s_loc.get("no-brokerfactory", props)).
-                setFatal(true);
+            throw new UserException(s_loc.get("no-brokerfactory", 
+                conf.getProperties())).setFatal(true);
 
         try {
             return Class.forName(clsName, true, loader);

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java
Sat Jul 15 09:40:00 2006
@@ -200,4 +200,10 @@
      * Return a copy of this configuration.
      */
     public Object clone();
+
+    /**
+     * Add <code>prefix</code> to the list of prefixes to use
+     * to identify valid configuration properties.
+     */
+    public void addPropertyPrefix(String prefix);
 }

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
Sat Jul 15 09:40:00 2006
@@ -15,7 +15,7 @@
  */
 package org.apache.openjpa.lib.conf;
 
-import java.awt.*;
+import java.awt.Image;
 import java.beans.BeanDescriptor;
 import java.beans.BeanInfo;
 import java.beans.EventSetDescriptor;
@@ -36,17 +36,18 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.AbstractList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.Properties;
+import java.util.Set;
 import java.util.TreeSet;
 
 import org.apache.commons.lang.StringUtils;
@@ -112,6 +113,8 @@
     // cache descriptors
     private PropertyDescriptor[] _pds = null;
     private MethodDescriptor[] _mds = null;
+    
+    private Set _prefixes = new HashSet();
 
     /**
      * Default constructor. Attempts to load default properties through
@@ -127,7 +130,9 @@
      * @param loadDefaults whether to attempt to load the default properties
      */
     public ConfigurationImpl(boolean loadDefaults) {
-        logFactoryPlugin = addPlugin("org.apache.openjpa.lib.Log", true);
+        _prefixes.add("openjpa");
+        
+        logFactoryPlugin = addPlugin("Log", true);
         String[] aliases = new String[]{
             "true", "org.apache.openjpa.lib.log.LogFactoryImpl",
             "commons", "org.apache.openjpa.lib.log.CommonsLogFactory",
@@ -171,7 +176,7 @@
     }
 
     public String getProductName() {
-        return "solarmetric";
+        return "openjpa";
     }
 
     public LogFactory getLogFactory() {
@@ -579,7 +584,8 @@
         Object set;
         for (int i = 0; i < _vals.size(); i++) {
             val = (Value) _vals.get(i);
-            set = map.get(val.getProperty());
+            Object[] propertyInfo = lookUpProperty(val.getProperty(), map);
+            set = propertyInfo[1];
             if (set == null)
                 continue;
 
@@ -591,13 +597,14 @@
                 val.setObject(set);
             }
 
-            remaining.remove(val.getProperty());
+            removeFoundProperty(val, remaining);
         }
-
+        
         // convention is to point product at a resource with the
-        // <product>.properties System property; remove that property so we
+        // <prefix>.properties System property; remove that property so we
         // we don't warn about it
-        remaining.remove(getProductName() + ".properties");
+        for (Iterator iter = _prefixes.iterator(); iter.hasNext(); )
+            remaining.remove((String) iter.next() + ".properties");
 
         // now warn if there are any remaining properties that there
         // is an unhandled prop
@@ -615,6 +622,35 @@
     }
 
     /**
+     * Removes <code>val</code> from <code>remaining</code>. Use
this method
+     * instead of attempting to remove the value directly because this will
+     * account for any duplicate-but-same-valued keys in the map.
+     */
+    private void removeFoundProperty(Value val, Map remaining) {
+        for (Iterator iter = _prefixes.iterator(); iter.hasNext(); )
+            remaining.remove((String) iter.next() + "." + val.getProperty());
+    }
+
+    private Object[] lookUpProperty(String property, Map map) {
+        String firstKey = null;
+        Object o = null;
+        for (Iterator iter = _prefixes.iterator(); iter.hasNext(); ) {
+            String key = (String) iter.next() + "." + property;
+            if (firstKey == null) {
+                o = map.get(key);
+                if (o != null)
+                    firstKey = key;
+            } else if (map.containsKey(key)) {
+                // if we've already found a property with a previous prefix,
+                // then this is a collision.
+                throw new IllegalStateException(
+                    _loc.get("dup-with-different-prefixes", firstKey, key));
+            }
+        }
+        return new Object[] { firstKey, o };
+    }
+
+    /**
      * Issue a warning that the specified property is not valid.
      */
     private void warnInvalidProperty(String propName) {
@@ -627,7 +663,7 @@
         // try to find the closest string to the invalid property
         // so that we can provide a hint in case of a misspelling
         String closest = StringDistance.getClosestLevenshteinDistance
-            (propName, new PropertyList(), 15);
+            (propName, newPropertyList(), 15);
 
         if (closest == null)
             log.warn(_loc.get("invalid-property", propName));
@@ -635,14 +671,33 @@
             log.warn(_loc.get("invalid-property-hint", propName, closest));
     }
 
+    private Collection newPropertyList() {
+        Set s = new HashSet();
+        for (Iterator iter = _vals.iterator(); iter.hasNext(); ) {
+            Value val = (Value) iter.next();
+            for (Iterator iter2 = _prefixes.iterator(); iter2.hasNext(); )
+                s.add(((String) iter2.next()) + "." + val.getProperty());  
+        }
+        return s;
+    }
+
     /**
      * Returns true if the specified property name should raise a warning
      * if it is not found in the list of known properties.
      */
     protected boolean isInvalidProperty(String propName) {
-        // by default, we don't warn on any properties, since we don't
-        // know what property pattern will be used for the base config
-        return false;
+        // handle warnings for openjpa.SomeString, but not for
+        // openjpa.some.subpackage.SomeString, since it might be valid for some
+        // specific implementation of OpenJPA
+        boolean invalid = false;
+        for (Iterator iter = _prefixes.iterator(); iter.hasNext(); ) {
+            String prefix = (String) iter.next();
+            if (propName.toLowerCase().startsWith(prefix)
+                && propName.indexOf('.', prefix.length()) != -1)
+                invalid = true;
+        }
+
+        return invalid;
     }
 
     /**
@@ -661,7 +716,7 @@
      * <code>propertiesFile</code> value with the name of a file.
      */
     public void setPropertiesFile(File file) throws IOException {
-        Configurations.load(file, getClass().getClassLoader()). setInto(this);
+        Configurations.load(file, getClass().getClassLoader()).setInto(this);
     }
 
     /////////////
@@ -714,6 +769,8 @@
     public void readExternal(ObjectInput in)
         throws IOException, ClassNotFoundException {
         fromProperties((Map) in.readObject());
+        _prefixes = (Set) in.readObject();
+        _defaults = in.readBoolean();
     }
 
     /**
@@ -725,6 +782,9 @@
             out.writeObject(_props);
         else
             out.writeObject(toProperties(false));
+        
+        out.writeObject(_prefixes);
+        out.writeBoolean(_defaults);
     }
 
     /**
@@ -735,8 +795,11 @@
         try {
             Constructor cons = getClass().getConstructor
                 (new Class[]{ boolean.class });
-            Configuration clone = (Configuration) cons.newInstance
+            ConfigurationImpl clone = (ConfigurationImpl) cons.newInstance
                 (new Object[]{ Boolean.FALSE });
+            clone._prefixes.clear();
+            clone._prefixes.addAll(_prefixes);
+            clone._defaults = _defaults;
             clone.fromProperties(toProperties(true));
             return clone;
         } catch (RuntimeException re) {
@@ -759,6 +822,10 @@
         return val;
     }
 
+    public void addPropertyPrefix(String prefix) {
+        _prefixes.add(prefix);
+    }
+
     /**
      * Add the given value to the set of configuration properties.
      */
@@ -838,19 +905,5 @@
         PluginListValue val = new PluginListValue(property);
         addValue(val);
         return val;
-    }
-
-    /**
-     * Exposes our values list as a list of property names.
-     */
-    private class PropertyList extends AbstractList {
-
-        public Object get(int i) {
-            return ((Value) _vals.get(i)).getProperty();
-        }
-
-        public int size() {
-            return _vals.size();
-        }
     }
 }

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
Sat Jul 15 09:40:00 2006
@@ -282,8 +282,8 @@
                 String msg = null;
                 String first = (String) invalidEntries.keySet().iterator()
                     .next();
-                if (invalidEntries.keySet().size() == 1 
-                    && first.indexOf('.') == -1) {
+                if (invalidEntries.keySet().size() == 1 &&
+                    first.indexOf('.') == -1) {
                     // if there's just one misspelling and this is not a
                     // path traversal, check for near misses.
                     Collection options = Options.findOptionsFor(obj.getClass());

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/MapConfigurationProvider.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/MapConfigurationProvider.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/MapConfigurationProvider.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/MapConfigurationProvider.java
Sat Jul 15 09:40:00 2006
@@ -36,7 +36,7 @@
         (MapConfigurationProvider.class);
 
     private Map _props = null;
-
+    
     /**
      * Construct with null properties.
      */
@@ -47,6 +47,7 @@
      * Constructor; supply properties map.
      */
     public MapConfigurationProvider(Map props) {
+        this();
         addProperties(props);
     }
 
@@ -91,6 +92,7 @@
     protected void setInto(Configuration conf, Log log) {
         if (log != null && log.isTraceEnabled())
             log.trace(_loc.get("conf-load", getProperties()));
+        
         if (_props != null)
             conf.fromProperties(_props);
     }

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties
Sat Jul 15 09:40:00 2006
@@ -51,6 +51,8 @@
 	on "{0}". This exception will be consumed.
 closeable-ex: An exception occurred while invoking close() on "{0}". This \
 	exception will be consumed.
+dup-with-different-prefixes: Found multiple properties with different valid \
+	prefixes. Properties: {0}, {1}.
 
 Log-name: Log factory
 Log-desc: LogFactory and configuration

Modified: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java
Sat Jul 15 09:40:00 2006
@@ -43,19 +43,21 @@
     }
 
     public void setUp() {
-        //### any way to avoid hard coding this?
-        _def = System.getProperty("org.apache.openjpa.properties");
-        System.setProperty("org.apache.openjpa.properties", "test.properties");
+        _def = System.getProperty("openjpa.properties");
+        System.setProperty("openjpa.properties", "test.properties");
     }
 
     public void tearDown() throws Exception {
-        System.setProperty("org.apache.openjpa.properties", _def);
+    	if (_def != null)
+    		System.setProperty("openjpa.properties", _def);
 
-        super.tearDown();
+    	super.tearDown();
     }
 
     /**
      * Test that default properties are found and loaded.
+     * ### This test method requires some sort of ConfigurationProvider
+     * ### to be available in the openjpa-lib module, which is not the case.
      */
     public void testDefaults() {
         System.setProperty("sysKey", "sysvalue");
@@ -72,8 +74,7 @@
         // override the properties location to a non-existant value
         _conf.setTestKey(null);
         _conf.setSysKey(null);
-        //###
-        System.setProperty("org.apache.openjpa.properties", "foo.properties");
+        System.setProperty("openjpa.properties", "foo.properties");
         try {
             assertTrue(!_conf.loadDefaults());
             fail("Should have thrown exception for missing resource.");
@@ -81,8 +82,7 @@
         }
 
         // set back for remainder of tests
-        //###
-        System.setProperty("org.apache.openjpa.properties", "test.properties");
+        System.setProperty("openjpa.properties", "test.properties");
         System.setProperty("pluginKey", "java.lang.Object");
         assertTrue(_conf.loadDefaults());
         assertEquals("testvalue", _conf.getTestKey());

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConfigurationProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConfigurationProviderImpl.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConfigurationProviderImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConfigurationProviderImpl.java
Sat Jul 15 09:40:00 2006
@@ -40,9 +40,9 @@
  * Configuration provider capable of loading a {@link Configuration} from
  * the current environment's JPA-style XML configuration data.
  * 
- * For defaults, looks in <code>org.apache.openjpa.properties</code> system property
for
+ * For defaults, looks in <code>openjpa.properties</code> system property for
  * the location of a file to parse. If no system property is defined, the
- * default resource location of <code>org.apache.openjpa.xml</code> is used.
+ * default resource location of <code>openjpa.xml</code> is used.
  * If it exists, the resource is parsed as an XML file.
  *
  * @nojavadoc
@@ -51,7 +51,7 @@
 public class ConfigurationProviderImpl
     extends MapConfigurationProvider {
 
-    private static final String RSRC_DEFAULT = "org.apache.openjpa.xml";
+    private static final String RSRC_DEFAULT = "openjpa.xml";
     private static final String RSRC_SPEC = "META-INF/persistence.xml";
 
     private static final Localizer _loc = Localizer.forPackage
@@ -129,7 +129,7 @@
     @Override
     public boolean loadDefaults(ClassLoader loader)
         throws IOException {
-        String rsrc = System.getProperty("org.apache.openjpa.properties");
+        String rsrc = System.getProperty("openjpa.properties");
         String name = null;
         boolean explicit = false;
         if (rsrc == null)

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java?rev=422262&r1=422261&r2=422262&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
Sat Jul 15 09:40:00 2006
@@ -134,37 +134,37 @@
 
         OpenJPAConfiguration conf = getConfiguration();
         String user =
-            (String) props.remove("org.apache.openjpa.ConnectionUserName");
+            (String) props.remove("openjpa.ConnectionUserName");
         if (user == null)
             user = conf.getConnectionUserName();
         String pass =
-            (String) props.remove("org.apache.openjpa.ConnectionPassword");
+            (String) props.remove("openjpa.ConnectionPassword");
         if (pass == null)
             pass = conf.getConnectionPassword();
 
         String str =
-            (String) props.remove("org.apache.openjpa.TransactionMode");
+            (String) props.remove("openjpa.TransactionMode");
         boolean managed;
         if (str == null)
             managed = conf.isTransactionModeManaged();
         else {
-            Value val = conf.getValue("org.apache.openjpa.TransactionMode");
+            Value val = conf.getValue("openjpa.TransactionMode");
             managed = Boolean.parseBoolean(val.unalias(str));
         }
 
-        Object obj = props.remove("org.apache.openjpa.ConnectionRetainMode");
+        Object obj = props.remove("openjpa.ConnectionRetainMode");
         int retainMode;
         if (obj instanceof Number)
             retainMode = ((Number) obj).intValue();
         else if (obj != null) {
             Value val =
-                conf.getValue("org.apache.openjpa.ConnectionRetainMode");
+                conf.getValue("openjpa.ConnectionRetainMode");
             try {
                 retainMode = Integer.parseInt(val.unalias((String) obj));
             }
             catch (Exception e) {
                 throw new ArgumentException(_loc.get("bad-em-prop",
-                    "org.apache.openjpa.ConnectionRetainMode", obj),
+                    "openjpa.ConnectionRetainMode", obj),
                     new Throwable[]{ e },
                     obj, true);
             }
@@ -186,7 +186,7 @@
         Object val;
         for (Map.Entry entry : (Set<Map.Entry>) props.entrySet()) {
             prop = (String) entry.getKey();
-            if (!prop.startsWith("org.apache.openjpa."))
+            if (!prop.startsWith("openjpa."))
                 continue;
             prop = prop.substring(5);
             try {



Mime
View raw message