You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by aj...@apache.org on 2006/03/31 12:03:14 UTC

svn commit: r390386 - /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java

Author: ajith
Date: Fri Mar 31 02:03:12 2006
New Revision: 390386

URL: http://svn.apache.org/viewcvs?rev=390386&view=rev
Log:
Adding a system property that allows the users to set an external codegen configurator property file. This allows the users to use custom configurations with the codegenerator.
The system property key is "org.apache.axis2.codegen.config"

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java?rev=390386&r1=390385&r2=390386&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java Fri Mar 31 02:03:12 2006
@@ -5,6 +5,7 @@
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.FileNotFoundException;
 import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -44,19 +45,44 @@
     private static final String DATA_BINDING_TEST_OBJECT_TEMPLATE_NAME_KEY = "codegen.databinding.testobject.template";
 
 
-    public static final String CODEGEN_CONFIG_PROPERTIES = "/org/apache/axis2/wsdl/codegen/codegen-config.properties";
+    public static final String DEFAULT_CODEGEN_CONFIG_PROPERTIES =
+            "/org/apache/axis2/wsdl/codegen/codegen-config.properties";
 
     /* Note - Should be a non regular expression character. If not it should be properly escaped */
     private static final String SEPARATOR_CHAR = ",";
 
+    /**
+     * Loads a stream from the given
+     * @param propertiesReference
+     * @return
+     * @throws FileNotFoundException
+     */
+    private static InputStream getStream(String propertiesReference) throws FileNotFoundException {
+        InputStream stream = ConfigPropertyFileLoader.class.getResourceAsStream(propertiesReference);
+        if (stream == null) {
+            URL url = ConfigPropertyFileLoader.class.getResource(propertiesReference);
+            stream = new FileInputStream(url.toString());
+        }
+        return stream;
+    }
+
     static {
         try {
+            //look for the system property "org.apache.axis2.codegen.config" to for a property
+            //entry refering to the config properties
+            String property = System.getProperty("org.apache.axis2.codegen.config");
+            InputStream stream = null;
+
+            if (property!=null){
+                stream = getStream(property);
+            }else{
+                stream = getStream(DEFAULT_CODEGEN_CONFIG_PROPERTIES);
+            }
 
-            InputStream stream = ConfigPropertyFileLoader.class.getResourceAsStream(CODEGEN_CONFIG_PROPERTIES);
-            if (stream == null) {
-                URL url = ConfigPropertyFileLoader.class.getResource(CODEGEN_CONFIG_PROPERTIES);
-                stream = new FileInputStream(url.toString());
+            if (stream==null){
+                throw new RuntimeException(CodegenMessages.getMessage("propfileload.generalException"));
             }
+
             Properties props = new Properties();
             props.load(stream);