Author: gnodet
Date: Wed Oct 18 16:34:00 2006
New Revision: 465420

URL: http://svn.apache.org/viewvc?view=rev&rev=465420
Log:
SM-714: component.properties in conf directory

Modified:
    
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpBootstrap.java
    
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
    
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java

Modified: 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpBootstrap.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpBootstrap.java?view=diff&rev=465420&r1=465419&r2=465420
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpBootstrap.java
 (original)
+++ 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpBootstrap.java
 Wed Oct 18 16:34:00 2006
@@ -36,21 +36,12 @@
     protected HttpConfiguration configuration;
     
     public HttpBootstrap() {
-        configuration = new HttpConfiguration();
     }
     
     public ObjectName getExtensionMBeanName() {
         return mbeanName;
     }
 
-    protected Object getExtensionMBean() throws Exception {
-        return configuration;
-    }
-    
-    protected ObjectName createExtensionMBeanName() throws Exception {
-        return 
this.context.getContext().getMBeanNames().createCustomComponentMBeanName("bootstrap");
-    }
-
     /* (non-Javadoc)
      * @see 
javax.jbi.component.Bootstrap#init(javax.jbi.component.InstallationContext)
      */
@@ -66,18 +57,18 @@
     }
 
     protected void doInit() throws Exception {
-        Object mbean = getExtensionMBean();
-        if (mbean != null) {
-            this.mbeanName = createExtensionMBeanName();
-            MBeanServer server = this.context.getContext().getMBeanServer();
-            if (server == null) {
-                throw new JBIException("null mBeanServer");
-            }
-            if (server.isRegistered(this.mbeanName)) {
-                server.unregisterMBean(this.mbeanName);
-            }
-            server.registerMBean(mbean, this.mbeanName);
+        configuration = new HttpConfiguration();
+        configuration.setRootDir(this.context.getInstallRoot());
+        configuration.setComponentName(this.context.getComponentName());
+        mbeanName = 
this.context.getContext().getMBeanNames().createCustomComponentMBeanName("bootstrap");
+        MBeanServer server = this.context.getContext().getMBeanServer();
+        if (server == null) {
+            throw new JBIException("null mBeanServer");
+        }
+        if (server.isRegistered(this.mbeanName)) {
+            server.unregisterMBean(this.mbeanName);
         }
+        server.registerMBean(configuration, this.mbeanName);
     }
     
     /* (non-Javadoc)
@@ -109,32 +100,12 @@
      * @see javax.jbi.component.Bootstrap#onInstall()
      */
     public void onInstall() throws JBIException {
-        try {
-            doOnInstall();
-        } catch (JBIException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new JBIException("Error calling onInstall", e);
-        }
     }
 
-    protected void doOnInstall() throws Exception {
-    }
-    
     /* (non-Javadoc)
      * @see javax.jbi.component.Bootstrap#onUninstall()
      */
     public void onUninstall() throws JBIException {
-        try {
-            doOnUninstall();
-        } catch (JBIException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new JBIException("Error calling onUninstall", e);
-        }
     }
 
-    protected void doOnUninstall() throws Exception {
-    }
-    
 }

Modified: 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java?view=diff&rev=465420&r1=465419&r2=465420
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
 (original)
+++ 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
 Wed Oct 18 16:34:00 2006
@@ -118,6 +118,7 @@
         super.doInit();
         // Load configuration
         configuration.setRootDir(context.getWorkspaceRoot());
+        configuration.setComponentName(context.getComponentName());
         configuration.load();
         // Lookup keystoreManager and authenticationService
         if (configuration.getKeystoreManager() == null) {

Modified: 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java?view=diff&rev=465420&r1=465419&r2=465420
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java
 (original)
+++ 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java
 Wed Oct 18 16:34:00 2006
@@ -21,6 +21,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Properties;
+import java.io.InputStream;
 
 import org.apache.servicemix.jbi.security.auth.AuthenticationService;
 import org.apache.servicemix.jbi.security.keystore.KeystoreManager;
@@ -38,6 +39,7 @@
     public final static String CONFIG_FILE = "component.properties"; 
     
     private String rootDir;
+    private String componentName = "servicemix-http";
     private Properties properties = new Properties();
     private boolean streamingEnabled = false;
     private String jettyConnectorClassName = 
DEFAULT_JETTY_CONNECTOR_CLASS_NAME;
@@ -114,6 +116,20 @@
     }
 
     /**
+     * @return Returns the componentName.
+     */
+    public String getComponentName() {
+        return componentName;
+    }
+
+    /**
+     * @param componentName The componentName to set.
+     */
+    public void setComponentName(String componentName) {
+        this.componentName = componentName;
+    }
+
+    /**
      * @return the mapping
      */
     public String getMapping() {
@@ -284,16 +300,16 @@
 
     
     public void save() {
-        properties.setProperty("jettyThreadPoolSize", 
Integer.toString(jettyThreadPoolSize));
-        properties.setProperty("jettyConnectorClassName", 
jettyConnectorClassName);
-        properties.setProperty("streamingEnabled", 
Boolean.toString(streamingEnabled));
-        properties.setProperty("maxConnectionsPerHost", 
Integer.toString(maxConnectionsPerHost));
-        properties.setProperty("maxTotalConnections", 
Integer.toString(maxTotalConnections));
-        properties.setProperty("keystoreManagerName", keystoreManagerName);
-        properties.setProperty("authenticationServiceName", 
authenticationServiceName);
-        properties.setProperty("jettyManagement", 
Boolean.toString(jettyManagement));
-        properties.setProperty("connectorMaxIdleTime", 
Integer.toString(connectorMaxIdleTime));
-        properties.setProperty("consumerProcessorSuspendTime", 
Integer.toString(consumerProcessorSuspendTime));
+        properties.setProperty(componentName + ".jettyThreadPoolSize", 
Integer.toString(jettyThreadPoolSize));
+        properties.setProperty(componentName + ".jettyConnectorClassName", 
jettyConnectorClassName);
+        properties.setProperty(componentName + ".streamingEnabled", 
Boolean.toString(streamingEnabled));
+        properties.setProperty(componentName + ".maxConnectionsPerHost", 
Integer.toString(maxConnectionsPerHost));
+        properties.setProperty(componentName + ".maxTotalConnections", 
Integer.toString(maxTotalConnections));
+        properties.setProperty(componentName + ".keystoreManagerName", 
keystoreManagerName);
+        properties.setProperty(componentName + ".authenticationServiceName", 
authenticationServiceName);
+        properties.setProperty(componentName + ".jettyManagement", 
Boolean.toString(jettyManagement));
+        properties.setProperty(componentName + ".connectorMaxIdleTime", 
Integer.toString(connectorMaxIdleTime));
+        properties.setProperty(componentName + 
".consumerProcessorSuspendTime", 
Integer.toString(consumerProcessorSuspendTime));
         if (rootDir != null) {
             File f = new File(rootDir, CONFIG_FILE);
             try {
@@ -305,47 +321,61 @@
     }
     
     public boolean load() {
-        if (rootDir == null) {
-            return false;
+        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;
+            }
         }
-        File f = new File(rootDir, CONFIG_FILE);
-        if (!f.exists()) {
-            return false;
+        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 {
-            properties.load(new FileInputStream(f));
+            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("jettyThreadPoolSize") != null) {
-            jettyThreadPoolSize = 
Integer.parseInt(properties.getProperty("jettyThreadPoolSize"));
+        if (properties.getProperty(componentName + ".jettyThreadPoolSize") != 
null) {
+            jettyThreadPoolSize = 
Integer.parseInt(properties.getProperty(componentName + 
".jettyThreadPoolSize"));
         }
-        if (properties.getProperty("jettyConnectorClassName") != null) {
-            jettyConnectorClassName = 
properties.getProperty("jettyConnectorClassName");
+        if (properties.getProperty(componentName + ".jettyConnectorClassName") 
!= null) {
+            jettyConnectorClassName = properties.getProperty(componentName + 
".jettyConnectorClassName");
         }
-        if (properties.getProperty("streamingEnabled") != null) {
-            streamingEnabled = 
Boolean.valueOf(properties.getProperty("streamingEnabled")).booleanValue();
+        if (properties.getProperty(componentName + ".streamingEnabled") != 
null) {
+            streamingEnabled = 
Boolean.valueOf(properties.getProperty(componentName + 
".streamingEnabled")).booleanValue();
         }
-        if (properties.getProperty("maxConnectionsPerHost") != null) {
-            maxConnectionsPerHost = 
Integer.parseInt(properties.getProperty("maxConnectionsPerHost"));
+        if (properties.getProperty(componentName + ".maxConnectionsPerHost") 
!= null) {
+            maxConnectionsPerHost = 
Integer.parseInt(properties.getProperty(componentName + 
".maxConnectionsPerHost"));
         }
-        if (properties.getProperty("maxTotalConnections") != null) {
-            maxTotalConnections = 
Integer.parseInt(properties.getProperty("maxTotalConnections"));
+        if (properties.getProperty(componentName + ".maxTotalConnections") != 
null) {
+            maxTotalConnections = 
Integer.parseInt(properties.getProperty(componentName + 
".maxTotalConnections"));
         }
-        if (properties.getProperty("keystoreManagerName") != null) {
-            keystoreManagerName = 
properties.getProperty("keystoreManagerName");
+        if (properties.getProperty(componentName + ".keystoreManagerName") != 
null) {
+            keystoreManagerName = properties.getProperty(componentName + 
".keystoreManagerName");
         }
-        if (properties.getProperty("authenticationServiceName") != null) {
-            authenticationServiceName = 
properties.getProperty("authenticationServiceName");
+        if (properties.getProperty(componentName + 
".authenticationServiceName") != null) {
+            authenticationServiceName = properties.getProperty(componentName + 
".authenticationServiceName");
         }
-        if (properties.getProperty("jettyManagement") != null) {
-            jettyManagement = 
Boolean.valueOf(properties.getProperty("jettyManagement")).booleanValue();
+        if (properties.getProperty(componentName + ".jettyManagement") != 
null) {
+            jettyManagement = 
Boolean.valueOf(properties.getProperty(componentName + 
".jettyManagement")).booleanValue();
         }
-        if (properties.getProperty("connectorMaxIdleTime") != null) {
-            connectorMaxIdleTime = 
Integer.parseInt(properties.getProperty("connectorMaxIdleTime"));
+        if (properties.getProperty(componentName + ".connectorMaxIdleTime") != 
null) {
+            connectorMaxIdleTime = 
Integer.parseInt(properties.getProperty(componentName + 
".connectorMaxIdleTime"));
         }
-        if (properties.getProperty("consumerProcessorSuspendTime") != null) {
-            consumerProcessorSuspendTime = 
Integer.parseInt(properties.getProperty("consumerProcessorSuspendTime"));
+        if (properties.getProperty(componentName + 
".consumerProcessorSuspendTime") != null) {
+            consumerProcessorSuspendTime = 
Integer.parseInt(properties.getProperty(componentName + 
".consumerProcessorSuspendTime"));
         }
         return true;
     }


Reply via email to