Author: dblevins
Date: Tue Aug 21 00:01:15 2012
New Revision: 1375337

URL: http://svn.apache.org/viewvc?rev=1375337&view=rev
Log:
Move the "openejb.foo trumps foo" code to a more generally applicable place
TOMEE-387

Added:
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/SystemPropertiesOverride.java
Modified:
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ApplicationProperties.java
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java

Modified: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ApplicationProperties.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ApplicationProperties.java?rev=1375337&r1=1375336&r2=1375337&view=diff
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ApplicationProperties.java
 (original)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ApplicationProperties.java
 Tue Aug 21 00:01:15 2012
@@ -76,32 +76,10 @@ public class ApplicationProperties imple
     }
 
     private void applyOverrides(AppModule appModule) {
-
-        final SuperProperties properties = new 
SuperProperties().caseInsensitive(false);
-        properties.putAll(SystemInstance.get().getProperties());
-
-        // Anything starting with "openejb" or "tomee" trumps other properties
-        // so "openejb.foo" always beats "foo"
-        for (Map.Entry<Object, Object> entry : 
SystemInstance.get().getProperties().entrySet()) {
-            final String key = entry.getKey().toString();
-
-            for (String prefix : Arrays.asList("openejb.", "tomee.")) {
-                if (key.startsWith(prefix)) {
-                    final String property = key.substring(prefix.length());
-
-                    if (appModule.getProperties().containsKey(property)) {
-                        log.debug("Overriding system property " + property + 
"=" + entry.getValue());
-                    } else {
-                        log.debug("Adding system property " + property + "=" + 
entry.getValue());
-                    }
-
-                    properties.put(property, entry.getValue());
-                }
-            }
-        }
-
         final String id = appModule.getModuleId() + ".";
 
+        final Properties properties = SystemInstance.get().getProperties();
+
         for (Map.Entry<Object, Object> entry : properties.entrySet()) {
             final String key = entry.getKey().toString();
 

Modified: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=1375337&r1=1375336&r2=1375337&view=diff
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
 (original)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
 Tue Aug 21 00:01:15 2012
@@ -162,6 +162,8 @@ public class ConfigurationFactory implem
 
         final Chain chain = new Chain();
 
+        chain.add(new SystemPropertiesOverride());
+
         chain.add(new GeneratedClientModules.Add());
 
         chain.add(new ReadDescriptors());

Added: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/SystemPropertiesOverride.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/SystemPropertiesOverride.java?rev=1375337&view=auto
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/SystemPropertiesOverride.java
 (added)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/SystemPropertiesOverride.java
 Tue Aug 21 00:01:15 2012
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.openejb.config;
+
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.loader.SystemInstance;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Anything starting with "openejb" or "tomee" trumps other properties
+ * so "openejb.foo" always beats "foo"
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemPropertiesOverride implements DynamicDeployer {
+
+    @Override
+    public AppModule deploy(AppModule appModule) throws OpenEJBException {
+
+        final Properties properties = new Properties();
+
+        for (Map.Entry<Object, Object> entry : 
SystemInstance.get().getProperties().entrySet()) {
+            final String key = entry.getKey().toString();
+
+            for (String prefix : Arrays.asList("openejb.", "tomee.")) {
+                if (key.startsWith(prefix)) {
+                    final String property = key.substring(prefix.length());
+                    properties.put(property, entry.getValue());
+                }
+            }
+        }
+
+        SystemInstance.get().getProperties().putAll(properties);
+
+        return appModule;
+    }
+}


Reply via email to