You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2009/06/26 08:32:11 UTC

svn commit: r788602 - in /servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc: CxfBcComponent.java CxfBcConfiguration.java

Author: ffang
Date: Fri Jun 26 06:32:11 2009
New Revision: 788602

URL: http://svn.apache.org/viewvc?rev=788602&view=rev
Log:
[SMXCOMP-574]CXF-BC and CXF-SE should allow separate configuration for non-default busCfg at component level.

Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConfiguration.java

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java?rev=788602&r1=788601&r2=788602&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java Fri Jun 26 06:32:11 2009
@@ -67,9 +67,13 @@
 
     @Override
     protected void doInit() throws Exception {
-        if (getBusConfig() != null) {
+        //Load configuration
+        configuration.setRootDir(context.getWorkspaceRoot());
+        configuration.setComponentName(context.getComponentName());
+        configuration.load();
+        if (configuration.getBusCfg() != null && configuration.getBusCfg().length() > 0) {
             SpringBusFactory bf = new SpringBusFactory();
-            bus = bf.createBus(getBusConfig());
+            bus = bf.createBus(configuration.getBusCfg());
         } else {
             bus = BusFactory.newInstance().createBus();
         }

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConfiguration.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConfiguration.java?rev=788602&r1=788601&r2=788602&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConfiguration.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConfiguration.java Fri Jun 26 06:32:11 2009
@@ -16,8 +16,21 @@
  */
 package org.apache.servicemix.cxfbc;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
 public class CxfBcConfiguration {
 
+    public static final String CONFIG_FILE = "component.properties"; 
+    
+    private String rootDir;
+    private String componentName = "servicemix-cxf-bc";
+    private Properties properties = new Properties();
+    private String busCfg;
+
     private transient Object authenticationService;
     
     /**
@@ -54,5 +67,77 @@
         this.authenticationServiceName = authenticationServiceName;
     }
 
+    public boolean load() {
+        File f = null;
+        InputStream in = null;
+        if (rootDir != null) {
+            // try to find the property file in the workspace folder
+            f = new File(rootDir, CONFIG_FILE);
+            if (!f.exists()) {
+                f = null;
+            }
+        }
+        if (f == null) {
+            // find property file in classpath if it is not available in workspace 
+            in = this.getClass().getClassLoader().getResourceAsStream(CONFIG_FILE);
+            if (in == null) {
+                return false;
+            }
+        }
+
+        try {
+            if (f != null) {
+                properties.load(new FileInputStream(f));
+            } else {
+                properties.load(in);
+            }
+        } catch (IOException e) {
+            throw new RuntimeException("Could not load component configuration", e);
+        }
+        if (properties.getProperty(componentName + ".busCfg") != null) {
+            setBusCfg(properties.getProperty(componentName + ".busCfg"));
+        }
+        
+        return true;
+    }
+
+    /**
+     * @return Returns the rootDir.
+     * @org.apache.xbean.Property hidden="true"
+     */
+    public String getRootDir() {
+        return rootDir;
+    }
+
+    /**
+     * @param rootDir The rootDir to set.
+     */
+    public void setRootDir(String rootDir) {
+        this.rootDir = rootDir;
+    }
+
+    /**
+     * @return Returns the componentName.
+     * @org.apache.xbean.Property hidden="true"
+     */
+    public String getComponentName() {
+        return componentName;
+    }
+
+    /**
+     * @param componentName The componentName to set.
+     */
+    public void setComponentName(String componentName) {
+        this.componentName = componentName;
+    }
+
+    public void setBusCfg(String busCfg) {
+        this.busCfg = busCfg;
+    }
+
+    public String getBusCfg() {
+        return busCfg;
+    }
+
     
 }