openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r422003 - in /incubator/openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/event/ openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ openjpa-lib/src/main/java/org/apache/openjpa/lib/log/ openjpa-lib/src/main/java/org/apache/...
Date Fri, 14 Jul 2006 19:48:07 GMT
Author: pcl
Date: Fri Jul 14 12:48:07 2006
New Revision: 422003

URL: http://svn.apache.org/viewvc?rev=422003&view=rev
Log:
updates to configuration. Committed on behalf of Abe

Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.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/GenericConfigurable.java
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryImpl.java
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java?rev=422003&r1=422002&r2=422003&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java
Fri Jul 14 12:48:07 2006
@@ -15,7 +15,6 @@
  */
 package org.apache.openjpa.event;
 
-import java.util.Map;
 import java.util.Properties;
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
@@ -36,6 +35,7 @@
 import org.apache.openjpa.lib.conf.Configurable;
 import org.apache.openjpa.lib.conf.GenericConfigurable;
 import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.util.OpenJPAException;
 import org.apache.openjpa.util.UserException;
 
@@ -92,11 +92,11 @@
      * constructor for JNDI lookups. Implementation of
      * {@link GenericConfigurable}.
      */
-    public void setInto(Map m) {
-        if (m != null && !m.isEmpty()) {
+    public void setInto(Options opts) {
+        if (opts != null && !opts.isEmpty()) {
             _ctxProps = new Properties();
-            _ctxProps.putAll(m);
-            m.clear();
+            _ctxProps.putAll(opts);
+            opts.clear();
         } else
             _ctxProps = null;
     }

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=422003&r1=422002&r2=422003&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
Fri Jul 14 12:48:07 2006
@@ -274,7 +274,7 @@
             configurable.startConfiguration();
         }
         if (opts != null) {
-            Map invalidEntries = opts.setInto(obj);
+            Options invalidEntries = opts.setInto(obj);
             if (obj instanceof GenericConfigurable)
                 ((GenericConfigurable) obj).setInto(invalidEntries);
 
@@ -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/GenericConfigurable.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/GenericConfigurable.java?rev=422003&r1=422002&r2=422003&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/GenericConfigurable.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/GenericConfigurable.java
Fri Jul 14 12:48:07 2006
@@ -15,13 +15,13 @@
  */
 package org.apache.openjpa.lib.conf;
 
-import java.util.Map;
+import org.apache.openjpa.lib.util.Options;
 
 /**
  * Implementations of this interface may perform additional
  * generic configuration with any key-value pairs that cannot be set
- * into the object via the normal {@link org.apache.openjpa.lib.util.Options#setInto}
- * means.
+ * into the object via the normal 
+ * {@link org.apache.openjpa.lib.util.Options#setInto} means.
  *
  * @author Patrick Linskey
  */
@@ -29,10 +29,10 @@
 
     /**
      * Perform any generic configuration based on the data in
-     * <code>m</code>. This method should remove any values in
-     * <code>m</code> that have been successfully processed; if any
-     * values remain in <code>m</code> after this method is executed,
+     * <code>opts</code>. This method should remove any values in
+     * <code>opts</code> that have been successfully processed; if any
+     * values remain in <code>opts</code> after this method is executed,
      * an exception will be thrown identifying those key-value pairs as invalid.
      */
-    public void setInto(Map m);
+    public void setInto(Options opts);
 }

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryImpl.java?rev=422003&r1=422002&r2=422003&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryImpl.java
Fri Jul 14 12:48:07 2006
@@ -28,6 +28,7 @@
 import org.apache.openjpa.lib.conf.GenericConfigurable;
 import org.apache.openjpa.lib.util.Files;
 import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.lib.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -222,15 +223,15 @@
 
     // ---------- GenericConfigurable implementation ----------
 
-    public void setInto(Map m) {
-        if (!m.isEmpty()) {
+    public void setInto(Options opts) {
+        if (!opts.isEmpty()) {
             Map.Entry e;
-            for (Iterator iter = m.entrySet().iterator(); iter.hasNext();) {
+            for (Iterator iter = opts.entrySet().iterator(); iter.hasNext();) {
                 e = (Map.Entry) iter.next();
                 _configuredLevels.put(shorten((String) e.getKey()),
                     new Short(getLevel((String) e.getValue())));
             }
-            m.clear();
+            opts.clear();
         }
     }
 

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java?rev=422003&r1=422002&r2=422003&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java
Fri Jul 14 12:48:07 2006
@@ -49,6 +49,11 @@
  */
 public class Options extends TypedProperties {
 
+    /**
+     * Immutable empty instance.
+     */
+    public static Options EMPTY = new EmptyOptions();
+
     // maps primitive types to the appropriate wrapper class and default value
     private static Object[][] _primWrappers = new Object[][]{
         { boolean.class, Boolean.class, Boolean.FALSE },
@@ -152,15 +157,16 @@
      * <li>Map Entry: <code>"brother.name"-&gt;"Bob"</code><br />
      * Resultant method call: <code>obj.getBrother().setName("Bob")
      * <code></li>
-     * </ul> Any keys present in the map for which there is no
+     * </ul> 
+     * Any keys present in the map for which there is no
      * corresponding property in the given object will be ignored,
      * and will be returned in the {@link Map} returned by this method.
      *
-     * @return a {@link Map} of key-value pairs in this object
+     * @return an {@link Options} of key-value pairs in this object
      * for which no setters could be found.
      * @throws RuntimeException on parse error
      */
-    public Map setInto(Object obj) {
+    public Options setInto(Object obj) {
         // set all defaults that have no explicit value
         Map.Entry entry = null;
         if (defaults != null) {
@@ -173,19 +179,17 @@
         }
 
         // set from main map
-        Map invalidEntries = null;
+        Options invalidEntries = null;
         Map.Entry e;
         for (Iterator itr = entrySet().iterator(); itr.hasNext();) {
             e = (Map.Entry) itr.next();
             if (!setInto(obj, e)) {
                 if (invalidEntries == null)
-                    invalidEntries = new HashMap();
+                    invalidEntries = new Options();
                 invalidEntries.put(e.getKey(), e.getValue());
             }
         }
-
-        return (invalidEntries == null) ? Collections.EMPTY_MAP :
-            invalidEntries;
+        return (invalidEntries == null) ? EMPTY : invalidEntries;
     }
 
     /**
@@ -605,5 +609,19 @@
     public String removeProperty(String key, String key2, String def) {
         String val = removeProperty(key);
         return (val == null) ? removeProperty(key2, def) : val;
+    }
+
+    /**
+     * Immutable empty options.
+     */
+    private static class EmptyOptions extends Options {
+
+        public Object setProperty(String key, String value) {
+            throw new UnsupportedOperationException();
+        }
+
+        public Object put(Object key, Object value) {
+            throw new UnsupportedOperationException();
+        }
     }
 }



Mime
View raw message