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 10:05:34 UTC

svn commit: r788622 - in /servicemix/smx3/branches/servicemix-3.2/deployables: bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/ serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/

Author: ffang
Date: Fri Jun 26 08:05:34 2009
New Revision: 788622

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

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeConfiguration.java
Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConfiguration.java
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java?rev=788622&r1=788621&r2=788622&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcComponent.java Fri Jun 26 08:05:34 2009
@@ -70,9 +70,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.getDefaultBus();
         }

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConfiguration.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConfiguration.java?rev=788622&r1=788621&r2=788622&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConfiguration.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConfiguration.java Fri Jun 26 08:05:34 2009
@@ -16,12 +16,25 @@
  */
 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;
+
 import org.apache.servicemix.jbi.security.auth.AuthenticationService;
 
 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 AuthenticationService authenticationService;
     
+    
     /**
      * The JNDI name of the AuthenticationService object
      */
@@ -57,4 +70,76 @@
     }
 
     
+    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;
+    }
+    
 }

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java?rev=788622&r1=788621&r2=788622&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java Fri Jun 26 08:05:34 2009
@@ -20,6 +20,7 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.servicemix.common.BaseServiceUnitManager;
 import org.apache.servicemix.common.DefaultComponent;
 import org.apache.servicemix.common.Deployer;
@@ -36,6 +37,8 @@
     private CxfSeEndpoint[] endpoints;
     private Bus bus;
     
+    private CxfSeConfiguration configuration = new CxfSeConfiguration();
+    
     public CxfSeComponent() {
         
     }
@@ -77,7 +80,16 @@
     
     @Override
     protected void doInit() throws Exception {
-        bus = BusFactory.getDefaultBus();
+        //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(configuration.getBusCfg());
+        } else {
+            bus = BusFactory.getDefaultBus();
+        }
         super.doInit();
     }
     

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeConfiguration.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeConfiguration.java?rev=788622&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeConfiguration.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeConfiguration.java Fri Jun 26 08:05:34 2009
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.cxfse;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class CxfSeConfiguration {
+
+    public static final String CONFIG_FILE = "component.properties"; 
+    
+    private String rootDir;
+    private String componentName = "servicemix-cxf-se";
+    private Properties properties = new Properties();
+    private String busCfg;
+    
+    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;
+    }
+    
+}