You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ve...@apache.org on 2008/12/30 18:55:42 UTC

svn commit: r730204 - in /synapse/trunk/java: ./ modules/distribution/ modules/experimental/ modules/experimental/src/ modules/experimental/src/main/ modules/experimental/src/main/java/ modules/experimental/src/main/java/org/ modules/experimental/src/m...

Author: veithen
Date: Tue Dec 30 09:55:41 2008
New Revision: 730204

URL: http://svn.apache.org/viewvc?rev=730204&view=rev
Log:
Added a synapse-experimental module. Initial content is a PoC for a potential solution of SYNAPSE-346.

Added:
    synapse/trunk/java/modules/experimental/
    synapse/trunk/java/modules/experimental/pom.xml
    synapse/trunk/java/modules/experimental/src/
    synapse/trunk/java/modules/experimental/src/main/
    synapse/trunk/java/modules/experimental/src/main/java/
    synapse/trunk/java/modules/experimental/src/main/java/org/
    synapse/trunk/java/modules/experimental/src/main/java/org/apache/
    synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/
    synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/
    synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ProxyDeployer.java
Modified:
    synapse/trunk/java/modules/distribution/pom.xml
    synapse/trunk/java/pom.xml

Modified: synapse/trunk/java/modules/distribution/pom.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/distribution/pom.xml?rev=730204&r1=730203&r2=730204&view=diff
==============================================================================
--- synapse/trunk/java/modules/distribution/pom.xml (original)
+++ synapse/trunk/java/modules/distribution/pom.xml Tue Dec 30 09:55:41 2008
@@ -46,6 +46,11 @@
             <artifactId>synapse-samples</artifactId>
             <version>${pom.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.synapse</groupId>
+            <artifactId>synapse-experimental</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
     </dependencies>
 
     <build>

Added: synapse/trunk/java/modules/experimental/pom.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/experimental/pom.xml?rev=730204&view=auto
==============================================================================
--- synapse/trunk/java/modules/experimental/pom.xml (added)
+++ synapse/trunk/java/modules/experimental/pom.xml Tue Dec 30 09:55:41 2008
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  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.
+  -->
+
+<project
+    xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.synapse</groupId>
+        <artifactId>Apache-Synapse</artifactId>
+        <version>SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.synapse</groupId>
+    <artifactId>synapse-experimental</artifactId>
+    
+    <name>Apache Synapse - Experimental code</name>
+    <description>Apache Synapse - Experimental code (use at your own risk!)</description>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.synapse</groupId>
+            <artifactId>synapse-core</artifactId>
+        </dependency>
+    </dependencies>
+</project>

Added: synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ProxyDeployer.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ProxyDeployer.java?rev=730204&view=auto
==============================================================================
--- synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ProxyDeployer.java (added)
+++ synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ProxyDeployer.java Tue Dec 30 09:55:41 2008
@@ -0,0 +1,122 @@
+/*
+ *  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.synapse.experimental;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.deployment.Deployer;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.repository.util.DeploymentFileData;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.synapse.Mediator;
+import org.apache.synapse.SynapseConstants;
+import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.synapse.config.xml.ProxyServiceFactory;
+import org.apache.synapse.core.axis2.ProxyService;
+import org.apache.synapse.endpoints.Endpoint;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.mediators.ListMediator;
+
+public class ProxyDeployer implements Deployer {
+    private ConfigurationContext cfgCtx = null;
+
+    public void init(ConfigurationContext configurationContext) {
+        this.cfgCtx = configurationContext;
+    }
+    
+    public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
+        String filename = deploymentFileData.getAbsolutePath();
+        ProxyService proxy;
+        try {
+            InputStream in = new FileInputStream(filename);
+            try {
+                OMElement element = new StAXOMBuilder(StAXUtils.createXMLStreamReader(in)).getDocumentElement();
+                proxy = ProxyServiceFactory.createProxy(element);
+            } finally {
+                in.close();
+            }
+        } catch (IOException ex) {
+            throw new DeploymentException("Error reading " + filename + ": " + ex.getMessage(), ex);
+        } catch (XMLStreamException ex) {
+            throw new DeploymentException("Error parsing " + filename + ": " + ex.getMessage(), ex);
+        } catch (OMException ex) {
+            throw new DeploymentException("Error parsing " + filename + ": " + ex.getMessage(), ex);
+        }
+        AxisConfiguration axisCfg = cfgCtx.getAxisConfiguration();
+        Parameter synCfgParam = axisCfg.getParameter(SynapseConstants.SYNAPSE_CONFIG);
+        if (synCfgParam == null) {
+            throw new DeploymentException("SynapseConfiguration not found. Are you sure that you are running Synapse?");
+        }
+        SynapseConfiguration synCfg = (SynapseConfiguration)synCfgParam.getValue();
+        // Copy from SynapseXMLConfigurationFactory#defineProxy
+        synCfg.addProxyService(proxy.getName(), proxy);
+        // Copy from SynapseInitializationModule#init (TODO: imcomplete: doesn't take pinnedServers into account)
+        proxy.buildAxisService(synCfg, axisCfg);
+        // Copy from SynapseConfiguration#init
+        if (proxy.getTargetInLineEndpoint() != null) {
+            initEndpoint(proxy.getTargetInLineEndpoint(), cfgCtx);
+        }
+
+        if (proxy.getTargetInLineInSequence() != null) {
+            initEndpointsOfChildren(proxy.getTargetInLineInSequence(), cfgCtx);
+        }
+
+        if (proxy.getTargetInLineOutSequence() != null) {
+            initEndpointsOfChildren(proxy.getTargetInLineOutSequence(), cfgCtx);
+        }
+
+        if (proxy.getTargetInLineFaultSequence() != null) {
+            initEndpointsOfChildren(proxy.getTargetInLineFaultSequence(), cfgCtx);
+        }
+    }
+
+    // Copy from SynapseConfiguration
+    private void initEndpointsOfChildren(ListMediator s, ConfigurationContext cc) {
+        for (Mediator m : s.getList()) {
+            if (m instanceof AbstractMediator) {
+                ((AbstractMediator)m).init(cc);
+            } 
+        }
+    }
+    
+    // Copy from SynapseConfiguration
+    private void initEndpoint(Endpoint e, ConfigurationContext cc) {
+        e.init(cc);
+    }
+
+    public void setDirectory(String arg0) {
+    }
+
+    public void setExtension(String arg0) {
+    }
+
+    public void unDeploy(String arg0) throws DeploymentException {
+    }
+}

Modified: synapse/trunk/java/pom.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/pom.xml?rev=730204&r1=730203&r2=730204&view=diff
==============================================================================
--- synapse/trunk/java/pom.xml (original)
+++ synapse/trunk/java/pom.xml Tue Dec 30 09:55:41 2008
@@ -926,6 +926,7 @@
         <module>modules/war</module>
         <module>modules/handler</module>
         <module>modules/xar-maven-plugin</module>
+        <module>modules/experimental</module>
         <module>modules/distribution</module>
     </modules>