cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r467894 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/configuration/ rt/core/src/main/java/org/apache/cxf/bus/spring/ rt/core/src/test/java/org/apache/cxf/bus/spring/
Date Thu, 26 Oct 2006 07:30:03 GMT
Author: ningjiang
Date: Thu Oct 26 00:30:02 2006
New Revision: 467894

URL: http://svn.apache.org/viewvc?view=rev&rev=467894
Log:
[CXF-146] made springBus to take the configuration file URL from system properties cxf.config.file.url


Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/Configurer.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/Messages.properties
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/Configurer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/Configurer.java?view=diff&rev=467894&r1=467893&r2=467894
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/Configurer.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/Configurer.java
Thu Oct 26 00:30:02 2006
@@ -24,6 +24,8 @@
     String DEFAULT_USER_CFG_FILE = "cxf.xml";
 
     String USER_CFG_FILE_PROPERTY_NAME = "cxf.config.file";
+    
+    String USER_CFG_FILE_PROPERTY_URL = "cxf.config.file.url";
 
     void configureBean(Object beanInstance);
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java?view=diff&rev=467894&r1=467893&r2=467894
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
Thu Oct 26 00:30:02 2006
@@ -20,6 +20,7 @@
 package org.apache.cxf.bus.spring;
 
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Enumeration;
@@ -83,7 +84,7 @@
         
         if (null == cfgFile) {
             cfgFile = System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME);
-        }
+        }        
         if (null == cfgFile) {
             cfgFile = Configurer.DEFAULT_USER_CFG_FILE;
         }
@@ -92,6 +93,22 @@
             resources.add(cpr);
         } else {
             LOG.log(Level.INFO, new Message("USER_CFG_FILE_NOT_FOUND_MSG", LOG, cfgFile).toString());
+        }
+        
+        String cfgFileUrl = System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_URL);
+        if (null != cfgFileUrl) {
+            try {
+                UrlResource ur = new UrlResource(cfgFileUrl);
+                if (ur.exists()) {
+                    resources.add(ur);
+                } else {
+                    LOG.log(Level.INFO, 
+                            new Message("USER_CFG_FILE_URL_NOT_FOUND_MSG", LOG, cfgFileUrl).toString());
+                }            
+            } catch (MalformedURLException e) {            
+                LOG.log(Level.WARNING, 
+                        new Message("USER_CFG_FILE_URL_ERROR_MSG", LOG, cfgFileUrl).toString());
+            }
         }
         
         if (LOG.isLoggable(Level.FINE)) {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/Messages.properties?view=diff&rev=467894&r1=467893&r2=467894
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/Messages.properties
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/Messages.properties
Thu Oct 26 00:30:02 2006
@@ -19,4 +19,6 @@
 #
 #
 USER_CFG_FILE_NOT_FOUND_MSG = Could not find the configuration file {0} on the classpath.
+USER_CFG_FILE_URL_ERROR_MSG = The configuration file URL {0} is a a malformed URL.
+USER_CFG_FILE_URL_NOT_FOUND_MSG = Could not find the configuration file in the url of {0}.
 APP_CONTEXT_CREATION_FAILED_MSG = Failed to create application context.

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java?view=diff&rev=467894&r1=467893&r2=467894
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
(original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
Thu Oct 26 00:30:02 2006
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.bus.spring;
 
+import java.net.URL;
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -72,9 +73,20 @@
         
     }
     
-    public void testCustom() {
+    public void testCustomFileName() {
         String cfgFile = "org/apache/cxf/bus/spring/resources/bus-overwrite.xml";
         Bus bus = new SpringBusFactory().createBus(cfgFile, true);
+        checkCustomerConfiguration(bus);
+    }
+    
+    public void testCustomFileURL() {
+        URL cfgFileURL = this.getClass().getResource("resources/bus-overwrite.xml");    
   
+        System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_URL, cfgFileURL.toString());
+        Bus bus = new SpringBusFactory().createBus(null, true);
+        checkCustomerConfiguration(bus);
+    }
+    
+    private void checkCustomerConfiguration(Bus bus) {
         assertNotNull(bus);
         List<Interceptor> interceptors = bus.getInInterceptors();
         assertEquals("Unexpected number of interceptors", 2, interceptors.size());
@@ -89,7 +101,6 @@
         interceptors = bus.getOutInterceptors();
         assertEquals("Unexpected number of interceptors", 1, interceptors.size());
         assertEquals("Unexpected interceptor", "out", interceptors.get(0).toString());
-        
     }
     
     public void testForLifeCycle() {



Mime
View raw message