You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by in...@apache.org on 2008/06/01 17:52:05 UTC

svn commit: r662238 - in /synapse/branches/1.2/modules/core/src/main/java/org/apache/synapse: SynapseConstants.java config/SynapseConfigurationBuilder.java

Author: indika
Date: Sun Jun  1 08:52:05 2008
New Revision: 662238

URL: http://svn.apache.org/viewvc?rev=662238&view=rev
Log:
add loads synapse.properties file loading from classfath with resource name conf/synapse.properties or synapse.properties

Modified:
    synapse/branches/1.2/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java
    synapse/branches/1.2/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigurationBuilder.java

Modified: synapse/branches/1.2/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java
URL: http://svn.apache.org/viewvc/synapse/branches/1.2/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java?rev=662238&r1=662237&r2=662238&view=diff
==============================================================================
--- synapse/branches/1.2/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java (original)
+++ synapse/branches/1.2/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java Sun Jun  1 08:52:05 2008
@@ -100,6 +100,8 @@
     public static final String SYNAPSE_XML = "synapse.xml";
     /** The name of the system property used to specify/override the Synapse properties location */
     public static final String SYNAPSE_PROPERTIES = "synapse.properties";
+    /** conf directory name **/
+    public static final String CONF_DIRECTORY = "conf";
 
     //- Synapse Message Context Properties -
         /** The Synapse MC property name that holds the name of the Proxy service thats handling it */

Modified: synapse/branches/1.2/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/synapse/branches/1.2/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigurationBuilder.java?rev=662238&r1=662237&r2=662238&view=diff
==============================================================================
--- synapse/branches/1.2/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigurationBuilder.java (original)
+++ synapse/branches/1.2/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigurationBuilder.java Sun Jun  1 08:52:05 2008
@@ -32,6 +32,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.InputStream;
 import java.util.Properties;
 
 /**
@@ -89,11 +90,43 @@
     }
 
     private static Properties loadSynapseProperties() {
+
         try {
             Properties properties = new Properties();
-            properties.load(Thread.currentThread().getContextClassLoader().
-                getResourceAsStream(SynapseConstants.SYNAPSE_PROPERTIES));
+            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+            if (log.isDebugEnabled()) {
+                log.debug("synapse.properties file is loading from classpath");
+            }
+
+            InputStream in = cl.getResourceAsStream(SynapseConstants.SYNAPSE_PROPERTIES);
+            if (in == null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Unable to load synapse.propeties file");
+                }
+
+                String path = SynapseConstants.CONF_DIRECTORY +
+                        File.separatorChar + SynapseConstants.SYNAPSE_PROPERTIES;
+                if (log.isDebugEnabled()) {
+                    log.debug("synapse.properties file is loading from classpath" +
+                            " with resource path '" + path + " '");
+                }
+
+                in = cl.getResourceAsStream(path);
+                if (in == null) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Unable to load the synapse.properties file from classpath" +
+                                " with resource name '" + path + " '");
+                    }
+                }
+            }
+
+            if (in != null) {
+                properties.load(in);
+            }
+            
             return properties;
+
         } catch (Exception e) {
             log.info("Using the default tuning parameters for Synapse");
         }