tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r585038 - in /openejb/trunk/openejb3: assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/TomcatLoader.java container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
Date Tue, 16 Oct 2007 04:56:27 GMT
Author: dain
Date: Mon Oct 15 21:56:19 2007
New Revision: 585038

URL: http://svn.apache.org/viewvc?rev=585038&view=rev
Log:
added system.properties support to tomcat

Modified:
    openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/TomcatLoader.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/TomcatLoader.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/TomcatLoader.java?rev=585038&r1=585037&r2=585038&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/TomcatLoader.java
(original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/TomcatLoader.java
Mon Oct 15 21:56:19 2007
@@ -45,6 +45,10 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.BufferedInputStream;
 import java.util.Properties;
 
 /**
@@ -62,6 +66,22 @@
             ejbServer = SystemInstance.get().getComponent(EjbServer.class);
             return;
         }
+
+        // Read in and apply the conf/system.properties
+        try {
+            File conf = SystemInstance.get().getBase().getDirectory("conf");
+            File file = new File(conf, "system.properties");
+            if (file.exists()){
+                Properties systemProperties = new Properties();
+                FileInputStream fin = new FileInputStream(file);
+                InputStream in = new BufferedInputStream(fin);
+                systemProperties.load(in);
+                System.getProperties().putAll(systemProperties);
+            }
+        } catch (IOException e) {
+            System.out.println("Processing conf/system.properties failed: "+e.getMessage());
+        }
+
 
         // initialize system instance before doing anything
         System.setProperty("openejb.deployments.classpath", "true");

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=585038&r1=585037&r2=585038&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
Mon Oct 15 21:56:19 2007
@@ -85,7 +85,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Iterator;
 
 public class ConfigurationFactory implements OpenEjbConfigurationFactory {
 
@@ -455,7 +454,7 @@
                         resourceInfo.properties.setProperty(name, value);
                     }
                 }
-                resourceInfo.properties.putAll(getSystemProperties(resourceInfo.id));
+                resourceInfo.properties.putAll(getSystemProperties(resourceInfo.id, "RESOURCE"));
                 connectorInfo.resourceAdapter = resourceInfo;
             }
 
@@ -495,7 +494,7 @@
                     }
                     resourceInfo.properties.setProperty("TransactionSupport", transactionSupport);
                     resourceInfo.properties.setProperty("ResourceAdapter", connectorInfo.resourceAdapter.id);
-                    resourceInfo.properties.putAll(getSystemProperties(resourceInfo.id));
+                    resourceInfo.properties.putAll(getSystemProperties(resourceInfo.id, "RESOURCE"));
                     connectorInfo.outbound.add(resourceInfo);
                 }
             }
@@ -524,7 +523,7 @@
                     mdbContainerInfo.constructorArgs.addAll(Arrays.asList("id", "transactionManager",
"securityService", "ResourceAdapter", "MessageListenerInterface", "ActivationSpecClass", "InstanceLimit"));
                     mdbContainerInfo.properties.setProperty("InstanceLimit", "10");
 
-                    mdbContainerInfo.properties.putAll(getSystemProperties(mdbContainerInfo.id));
+                    mdbContainerInfo.properties.putAll(getSystemProperties(mdbContainerInfo.id,
"CONTAINER"));
                     connectorInfo.inbound.add(mdbContainerInfo);
                 }
             }
@@ -549,7 +548,7 @@
                         resourceInfo.properties.setProperty(name, value);
                     }
                 }
-                resourceInfo.properties.putAll(getSystemProperties(resourceInfo.id));
+                resourceInfo.properties.putAll(getSystemProperties(resourceInfo.id, "RESOURCE"));
                 connectorInfo.adminObject.add(resourceInfo);
             }
 
@@ -680,7 +679,7 @@
         Properties props = new Properties();
         props.putAll(provider.getProperties());
         props.putAll(service.getProperties());
-        props.putAll(getSystemProperties(service.getId()));
+        props.putAll(getSystemProperties(service.getId(), provider.getService()));
 
         if (providerType != null && !provider.getService().equals(providerType))
{
             throw new OpenEJBException(messages.format("conf.4902", service.getId(), providerType));
@@ -764,19 +763,33 @@
         return configureService(service, type);
     }
 
-    private Properties getSystemProperties(String serviceId) {
+    private Properties getSystemProperties(String serviceId, String serviceType) {
+        String fullPrefix = serviceType.toUpperCase() + "." + serviceId + ".";
+        String fullPrefix2 = serviceType.toUpperCase() + "." + serviceId + "|";
+        String shortPrefix = serviceId + ".";
+        String shortPrefix2 = serviceId + "|";
+
         // Override with system properties
         Properties serviceProperties = new Properties();
-        String prefix = serviceId + ".";
         Properties sysProps = new Properties(System.getProperties());
         sysProps.putAll(SystemInstance.get().getProperties());
-        for (Iterator iterator1 = sysProps.entrySet().iterator(); iterator1.hasNext();) {
-            Map.Entry entry1 = (Map.Entry) iterator1.next();
-            String key = (String) entry1.getKey();
-            Object value = entry1.getValue();
-            if (value instanceof String && key.startsWith(prefix)) {
-                key = key.replaceFirst(prefix, "");
-                serviceProperties.setProperty(key, (String) value);
+        for (Map.Entry<Object, Object> entry : sysProps.entrySet()) {
+            String name = (String) entry.getKey();
+            Object value = entry.getValue();
+            if (value instanceof String) {
+                if (name.startsWith(fullPrefix)) {
+                    name = name.substring(fullPrefix.length());
+                    serviceProperties.setProperty(name, (String) value);
+                } else if (name.startsWith(fullPrefix2)) {
+                    name = name.substring(fullPrefix2.length());
+                    serviceProperties.setProperty(name, (String) value);
+                } else if (name.startsWith(shortPrefix)) {
+                    name = name.substring(shortPrefix.length());
+                    serviceProperties.setProperty(name, (String) value);
+                } else if (name.startsWith(shortPrefix2)) {
+                    name = name.substring(shortPrefix2.length());
+                    serviceProperties.setProperty(name, (String) value);
+                }
             }
         }
         return serviceProperties;



Mime
View raw message