Author: ruwan
Date: Sun May  3 01:16:40 2009
New Revision: 34687
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=34687

Log:
SynapseConfiguration & SynapseEnvironment as OSGi services,
pom file and OSGi meta info cleanup
Declarative services to manage the ESB startup


Added:
   trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/
   
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseConfigurationService.java
   
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseConfigurationServiceImpl.java
   
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseEnvironmentService.java
   
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseEnvironmentServiceImpl.java
Modified:
   trunk/esb/java/modules/core/pom.xml
   
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/ServiceBusInitializer.java
   trunk/esb/java/modules/distribution/pom.xml
   trunk/esb/java/modules/distribution/src/main/assembly/dist.xml
   trunk/esb/java/modules/samples/pom.xml
   trunk/esb/java/modules/styles/pom.xml
   trunk/esb/java/pom.xml

Modified: trunk/esb/java/modules/core/pom.xml
URL: 
http://wso2.org/svn/browse/wso2/trunk/esb/java/modules/core/pom.xml?rev=34687&r1=34686&r2=34687&view=diff
==============================================================================
--- trunk/esb/java/modules/core/pom.xml (original)
+++ trunk/esb/java/modules/core/pom.xml Sun May  3 01:16:40 2009
@@ -47,10 +47,10 @@
         <dependency>
             <groupId>org.apache.synapse</groupId>
             <artifactId>synapse-core</artifactId>
-            <version>1.3-wso2v1</version>
+            <version>${synapse.version}</version>
         </dependency>
     
-        <dependency>
+        <!--<dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.framework</artifactId>
             <version>1.0.3</version>
@@ -76,14 +76,21 @@
             <artifactId>org.osgi.compendium</artifactId>
             <version>1.0.0</version>
             <scope>provided</scope>
-        </dependency>
+        </dependency>-->
 
         <dependency>
             <groupId>org.wso2.carbon</groupId>
             <artifactId>org.wso2.carbon.core</artifactId>
+            <version>${carbon.version}</version>
         </dependency>
 
         <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.mediation.registry</artifactId>
+            <version>${carbon.version}</version>
+        </dependency>
+
+        <!--<dependency>
             <groupId>au.com.bytecode.opencsv</groupId>
             <artifactId>opencsv</artifactId>
         </dependency>
@@ -109,7 +116,7 @@
             <groupId>commons-pool</groupId>
             <artifactId>commons-pool</artifactId>
             <version>1.3</version>
-        </dependency> 
+        </dependency>--> 
 
     </dependencies>
 
@@ -146,12 +153,10 @@
                         
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                         <Bundle-Name>${pom.artifactId}</Bundle-Name>
                         <Bundle-Version>1.0.0</Bundle-Version>
-                        <Export-Package>
-                            org.wso2.esb.core.*; version=1.0.0,
-                        </Export-Package>
+                        <Private-Package>
+                            org.wso2.esb.core.*,
+                        </Private-Package>
                         <Import-Package>
-                            !org.wso2.esb.core,
-                            org.apache.synapse.*,
                             *;resolution:=optional
                         </Import-Package>
                         <Require-Bundle>

Modified: 
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/ServiceBusInitializer.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/ServiceBusInitializer.java?rev=34687&r1=34686&r2=34687&view=diff
==============================================================================
--- 
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/ServiceBusInitializer.java
      (original)
+++ 
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/ServiceBusInitializer.java
      Sun May  3 01:16:40 2009
@@ -23,45 +23,86 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.*;
-import org.osgi.framework.*;
+import org.osgi.framework.BundleContext;
 import org.osgi.service.component.ComponentContext;
 import org.wso2.carbon.utils.ConfigurationContextService;
+import org.wso2.esb.core.services.SynapseConfigurationService;
+import org.wso2.esb.core.services.SynapseConfigurationServiceImpl;
+import org.wso2.esb.core.services.SynapseEnvironmentService;
+import org.wso2.esb.core.services.SynapseEnvironmentServiceImpl;
+import org.wso2.carbon.mediation.registry.services.SynapseRegistryService;
 
 import java.io.File;
+import java.util.Properties;
 
 /**
  * @scr.component name="esb.core.initializer" immediate="true"
  * @scr.reference name="config.context.service" 
interface="org.wso2.carbon.utils.ConfigurationContextService" 
cardinality="1..1" policy="dynamic"  bind="setConfigurationContextService" 
unbind="unsetConfigurationContextService"
+ * @scr.reference name="synapse.registry.service" 
interface="org.wso2.carbon.mediation.registry.services.SynapseRegistryService" 
cardinality="1..1" policy="dynamic"  bind="setSynapseRegistryService" 
unbind="unsetSynapseRegistryService"
  */
 public class ServiceBusInitializer {
 
     private static final Log log = 
LogFactory.getLog(ServiceBusInitializer.class);
 
-    BundleContext bundleContext;
+    ConfigurationContextService configCtxSvc;
+    SynapseRegistryService synRegSvc;
 
     protected void activate(ComponentContext ctxt) {
-        this.bundleContext = ctxt.getBundleContext();
+
+        log.info("Starting ESB...");
+        
         try {
-            initESB();
+            BundleContext bndCtx = ctxt.getBundleContext();
+            ServerContextInformation contextInfo = initESB();
+
+            if (contextInfo.getSynapseConfiguration() != null) {
+
+                Properties props = new Properties();
+                SynapseConfigurationService synCfgSvc
+                        = new 
SynapseConfigurationServiceImpl(contextInfo.getSynapseConfiguration());
+                bndCtx.registerService(
+                        SynapseConfigurationService.class.getName(), 
synCfgSvc, props);
+
+                if (log.isDebugEnabled()) {
+                    log.debug("SynapseConfigurationService Registered");
+                }
+
+            } else {
+                handleFatal("Couldn't register the 
SynapseConfigurationService, " +
+                        "SynapseConfiguration not found");
+            }
+
+            if (contextInfo.getSynapseEnvironment() != null) {
+
+                Properties props = new Properties();
+                SynapseEnvironmentService synEnvSvc
+                        = new 
SynapseEnvironmentServiceImpl(contextInfo.getSynapseEnvironment());
+                bndCtx.registerService(
+                        SynapseEnvironmentService.class.getName(), synEnvSvc, 
props);
+
+                if (log.isDebugEnabled()) {
+                    log.debug("SynapseEnvironmentService Registered");
+                }
+
+            } else {
+                handleFatal("Couldn't register the SynapseEnvironmentService, 
" +
+                        "SynapseEnvironment not found");
+            }
+            
         } catch (Exception e) {
-            String message = "Couldn't initialize the ESB...";
-            log.fatal(message, e);
-            throw new RuntimeException(message);
+            handleFatal("Couldn't initialize the ESB...", e);
         }
     }
 
     protected void deactivate(ComponentContext ctxt) {
     }
 
-    private void initESB() throws AxisFault {
-        ServiceReference ref = bundleContext.getServiceReference(
-                ConfigurationContextService.class.getName());
-        Object serviceObject = bundleContext.getService(ref);
-        if (serviceObject instanceof ConfigurationContextService) {
-            ConfigurationContext configContext = ((ConfigurationContextService)
-                    serviceObject).getServerConfigContext();
+    private ServerContextInformation initESB() throws AxisFault {
+
+        if (configCtxSvc != null && synRegSvc != null) {
+            ConfigurationContext configContext = 
configCtxSvc.getServerConfigContext();
 
-            log.info("Initializing Synapse");
+            log.info("Initializing Apache Synapse...");
             ServerConfigurationInformation configurationInformation =
                     
ServerConfigurationInformationFactory.createServerConfigurationInformation(
                             configContext.getAxisConfiguration());
@@ -79,18 +120,58 @@
             serverManager.start();
 
             AxisConfiguration axisConf = configContext.getAxisConfiguration();
-
             AxisServiceGroup serviceGroup = axisConf.getServiceGroup(
                     SynapseConstants.SYNAPSE_SERVICE_NAME);
             serviceGroup.addParameter("hiddenService", "true");
+
+            return contextInfo;
+
+        } else {
+            handleFatal("Couldn't initialize Synapse, " +
+                    "ConfigurationContext service or SynapseRegistryService is 
not available");
+        }
+
+        // never executes, but keeps the compiler happy
+        return null;
+    }
+
+    protected void setConfigurationContextService(
+            ConfigurationContextService configurationContextService) {
+        if (log.isDebugEnabled()) {
+            log.debug("ConfigurationContextService bound to the ESB 
initialization process");
+        }
+        this.configCtxSvc = configurationContextService;
+    }
+
+    protected void unsetConfigurationContextService(
+            ConfigurationContextService configurationContextService) {
+        if (log.isDebugEnabled()) {
+            log.debug("ConfigurationContextService unbound from the ESB 
environment");
+        }
+        this.configCtxSvc = null;
+    }
+
+    protected void setSynapseRegistryService(SynapseRegistryService 
synapseRegistryService) {
+        if (log.isDebugEnabled()) {
+            log.debug("SynapseRegistryService bound to the ESB initialization 
process");
+        }
+        this.synRegSvc = synapseRegistryService;
+    }
+
+    protected void unsetSynapseRegistryService(SynapseRegistryService 
synapseRegistryService) {
+        if (log.isDebugEnabled()) {
+            log.debug("SynapseRegistryService unbound from the ESB 
environment");
         }
+        this.synRegSvc = null;
     }
 
-    protected void setConfigurationContextService(ConfigurationContextService 
configurationContextService) {
-        log.info("ConfigContextService available");
+    private void handleFatal(String message) {
+        log.fatal(message);
+        throw new RuntimeException(message);
     }
 
-    protected void 
unsetConfigurationContextService(ConfigurationContextService 
configurationContextService) {
-        log.info("ConfigContextService unavailable");
+    private void handleFatal(String message, Exception e) {
+        log.fatal(message, e);
+        throw new RuntimeException(message, e);
     }
 }

Added: 
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseConfigurationService.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseConfigurationService.java?pathrev=34687
==============================================================================
--- (empty file)
+++ 
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseConfigurationService.java
       Sun May  3 01:16:40 2009
@@ -0,0 +1,29 @@
+/**
+ * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed 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.wso2.esb.core.services;
+
+import org.apache.synapse.config.SynapseConfiguration;
+
+/**
+ * 
+ */
+public interface SynapseConfigurationService {
+
+    SynapseConfiguration getSynapseConfiguration();
+
+    void setSynapseConfiguration(SynapseConfiguration synapseConfiguration);
+}

Added: 
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseConfigurationServiceImpl.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseConfigurationServiceImpl.java?pathrev=34687
==============================================================================
--- (empty file)
+++ 
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseConfigurationServiceImpl.java
   Sun May  3 01:16:40 2009
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed 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.wso2.esb.core.services;
+
+import org.apache.synapse.config.SynapseConfiguration;
+
+/**
+ *
+ */
+public class SynapseConfigurationServiceImpl implements 
SynapseConfigurationService {
+
+    private SynapseConfiguration synapseConfiguration;
+
+    public SynapseConfigurationServiceImpl(SynapseConfiguration 
synapseConfiguration) {
+        this.synapseConfiguration = synapseConfiguration;
+    }
+
+    public SynapseConfiguration getSynapseConfiguration() {
+        return synapseConfiguration;
+    }
+
+    public void setSynapseConfiguration(SynapseConfiguration 
synapseConfiguration) {
+        this.synapseConfiguration = synapseConfiguration;
+    }
+}

Added: 
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseEnvironmentService.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseEnvironmentService.java?pathrev=34687
==============================================================================
--- (empty file)
+++ 
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseEnvironmentService.java
 Sun May  3 01:16:40 2009
@@ -0,0 +1,29 @@
+/**
+ * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed 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.wso2.esb.core.services;
+
+import org.apache.synapse.core.SynapseEnvironment;
+
+/**
+ * 
+ */
+public interface SynapseEnvironmentService {
+
+    SynapseEnvironment getSynapseEnvironment();
+
+    public void setSynapseEnvironment(SynapseEnvironment synapseEnvironment);
+}

Added: 
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseEnvironmentServiceImpl.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseEnvironmentServiceImpl.java?pathrev=34687
==============================================================================
--- (empty file)
+++ 
trunk/esb/java/modules/core/src/main/java/org/wso2/esb/core/services/SynapseEnvironmentServiceImpl.java
     Sun May  3 01:16:40 2009
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed 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.wso2.esb.core.services;
+
+import org.apache.synapse.core.SynapseEnvironment;
+
+/**
+ *
+ */
+public class SynapseEnvironmentServiceImpl implements 
SynapseEnvironmentService {
+
+    private SynapseEnvironment synapseEnvironment;
+
+    public SynapseEnvironmentServiceImpl(SynapseEnvironment 
synapseEnvironment) {
+        this.synapseEnvironment = synapseEnvironment;
+    }
+
+    public SynapseEnvironment getSynapseEnvironment() {
+        return synapseEnvironment;
+    }
+
+    public void setSynapseEnvironment(SynapseEnvironment synapseEnvironment) {
+        this.synapseEnvironment = synapseEnvironment;
+    }
+}

Modified: trunk/esb/java/modules/distribution/pom.xml
URL: 
http://wso2.org/svn/browse/wso2/trunk/esb/java/modules/distribution/pom.xml?rev=34687&r1=34686&r2=34687&view=diff
==============================================================================
--- trunk/esb/java/modules/distribution/pom.xml (original)
+++ trunk/esb/java/modules/distribution/pom.xml Sun May  3 01:16:40 2009
@@ -69,7 +69,22 @@
         </dependency>
         <dependency>
             <groupId>org.apache.synapse</groupId>
-            <artifactId>synapse-transports</artifactId>
+            <artifactId>synapse-nhttp-transport</artifactId>
+            <version>${synapse.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.synapse</groupId>
+            <artifactId>synapse-vfs-transport</artifactId>
+            <version>${synapse.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.synapse</groupId>
+            <artifactId>synapse-pipe-transport</artifactId>
+            <version>${synapse.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.synapse</groupId>
+            <artifactId>synapse-fix-transport</artifactId>
             <version>${synapse.version}</version>
         </dependency>
         <dependency>

Modified: trunk/esb/java/modules/distribution/src/main/assembly/dist.xml
URL: 
http://wso2.org/svn/browse/wso2/trunk/esb/java/modules/distribution/src/main/assembly/dist.xml?rev=34687&r1=34686&r2=34687&view=diff
==============================================================================
--- trunk/esb/java/modules/distribution/src/main/assembly/dist.xml      
(original)
+++ trunk/esb/java/modules/distribution/src/main/assembly/dist.xml      Sun May 
 3 01:16:40 2009
@@ -194,7 +194,10 @@
                 <include>org.opensymphony.wso2:quartz:jar</include>
                 <include>net.sf.saxon.wso2:saxon:jar</include>
                 <!-- Synapse bundles -->
-                <include>org.apache.synapse:synapse-transports:jar</include>
+                
<include>org.apache.synapse:synapse-nhttp-transport:jar</include>
+                <include>org.apache.synapse:synapse-vfs-transport:jar</include>
+                
<include>org.apache.synapse:synapse-pipe-transport:jar</include>
+                <include>org.apache.synapse:synapse-fix-transport:jar</include>
                 <include>org.apache.synapse:synapse-core:jar</include>
                 <include>org.apache.synapse:synapse-utils:jar</include>
                 <include>org.apache.synapse:synapse-tasks:jar</include>

Modified: trunk/esb/java/modules/samples/pom.xml
URL: 
http://wso2.org/svn/browse/wso2/trunk/esb/java/modules/samples/pom.xml?rev=34687&r1=34686&r2=34687&view=diff
==============================================================================
--- trunk/esb/java/modules/samples/pom.xml      (original)
+++ trunk/esb/java/modules/samples/pom.xml      Sun May  3 01:16:40 2009
@@ -40,25 +40,19 @@
         <dependency>
             <groupId>org.apache.synapse</groupId>
             <artifactId>synapse-core</artifactId>
-            <version>1.3-wso2v1</version>
+            <version>${synapse.version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.synapse</groupId>
             <artifactId>synapse-utils</artifactId>
-            <version>1.3-wso2v1</version>
+            <version>${synapse.version}</version>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.synapse</groupId>
-            <artifactId>synapse-transports</artifactId>
-            <version>1.3-wso2v1</version>
-        </dependency>
-
-        <dependency>
+        <!--<dependency>
             <groupId>org.wso2.carbon</groupId>
             <artifactId>org.wso2.carbon.core</artifactId>
-        </dependency>
+        </dependency>-->
 
         <dependency>
             <groupId>org.apache.ws.security.wso2</groupId>
@@ -72,11 +66,11 @@
             <version>${carbon.version}</version>
        </dependency>
 
-       <dependency>
+       <!--<dependency>
             <groupId>org.wso2.carbon</groupId>
             <artifactId>org.wso2.carbon.security.rahas</artifactId>
             <version>${carbon.version}</version>
-       </dependency>
+       </dependency>-->
 
     </dependencies>
 
@@ -104,8 +98,6 @@
                             samples.*; version=1.0.0,
                         </Export-Package>
                         <Import-Package>
-                            !org.wso2.esb.core,
-                            org.apache.synapse.*,
                             *;resolution:=optional
                         </Import-Package>
                         <DynamicImport-Package>*</DynamicImport-Package>

Modified: trunk/esb/java/modules/styles/pom.xml
URL: 
http://wso2.org/svn/browse/wso2/trunk/esb/java/modules/styles/pom.xml?rev=34687&r1=34686&r2=34687&view=diff
==============================================================================
--- trunk/esb/java/modules/styles/pom.xml       (original)
+++ trunk/esb/java/modules/styles/pom.xml       Sun May  3 01:16:40 2009
@@ -70,7 +70,7 @@
         </plugins>
     </build>
 
-    <dependencies>
+    <!--<dependencies>
 
         <dependency>
             <groupId>org.wso2.carbon</groupId>
@@ -111,5 +111,5 @@
             <groupId>org.eclipse.equinox</groupId>
             <artifactId>javax.servlet.jsp</artifactId>
         </dependency>
-    </dependencies>
+    </dependencies>-->
 </project>

Modified: trunk/esb/java/pom.xml
URL: 
http://wso2.org/svn/browse/wso2/trunk/esb/java/pom.xml?rev=34687&r1=34686&r2=34687&view=diff
==============================================================================
--- trunk/esb/java/pom.xml      (original)
+++ trunk/esb/java/pom.xml      Sun May  3 01:16:40 2009
@@ -43,7 +43,7 @@
         <module>modules/distribution</module>
     </modules>
 
-    <dependencyManagement>
+    <!--<dependencyManagement>
         <dependencies>
 
             <dependency>
@@ -140,7 +140,7 @@
             <version>3.8.1</version>
             <scope>test</scope>
         </dependency>
-    </dependencies>
+    </dependencies>-->
 
     <scm>
         
<connection>scm:svn:http://wso2.org/repos/wso2/trunk/esb/java</connection>

_______________________________________________
Esb-java-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to