Author: ffang
Date: Fri Jun 26 06:31:26 2009
New Revision: 788601
URL: http://svn.apache.org/viewvc?rev=788601&view=rev
Log:
[SMXCOMP-574]CXF-BC and CXF-SE should allow separate configuration for
non-default busCfg at component level.
Added:
servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeConfiguration.java
Modified:
servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
Modified:
servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
URL:
http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java?rev=788601&r1=788600&r2=788601&view=diff
==============================================================================
---
servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
(original)
+++
servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
Fri Jun 26 06:31:26 2009
@@ -41,6 +41,7 @@
private CxfSeEndpoint[] endpoints;
private Bus bus;
+ private CxfSeConfiguration configuration = new CxfSeConfiguration();
public CxfSeComponent() {
@@ -73,6 +74,13 @@
@Override
protected void doInit() throws Exception {
+ //Load configuration
+ configuration.setRootDir(context.getWorkspaceRoot());
+ configuration.setComponentName(context.getComponentName());
+ configuration.load();
+ if (configuration.getBusCfg() != null &&
configuration.getBusCfg().length() > 0) {
+ CXF_CONFIG[0] = configuration.getBusCfg();
+ }
if (bus == null) {
bus = new SpringBusFactory().createBus(CXF_CONFIG);
}
@@ -99,4 +107,4 @@
public void setBus(Bus bus) {
this.bus = bus;
}
-}
\ No newline at end of file
+}
Added:
servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeConfiguration.java
URL:
http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeConfiguration.java?rev=788601&view=auto
==============================================================================
---
servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeConfiguration.java
(added)
+++
servicemix/components/engines/servicemix-cxf-se/trunk/src/main/java/org/apache/servicemix/cxfse/CxfSeConfiguration.java
Fri Jun 26 06:31:26 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;
+ }
+
+}