You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by de...@apache.org on 2008/04/24 07:45:27 UTC

svn commit: r651160 - in /webservices/axis2/trunk/java/modules/kernel: conf/axis2.xml src/org/apache/axis2/deployment/AxisConfigBuilder.java src/org/apache/axis2/deployment/TransportDeployer.java src/org/apache/axis2/deployment/axis2_default.xml

Author: deepal
Date: Wed Apr 23 22:45:25 2008
New Revision: 651160

URL: http://svn.apache.org/viewvc?rev=651160&view=rev
Log:
As we discussed in the mailing list I created a prototype deployer for transport deployment. With the deployer I wrote we can deploy transport as we deploy service or module. The only thing we need to do is to add a descriptor file called “transport.xml” into the META-INF directory of the transport jar file. Then axis2 will read the xml file and populate the transport. One such an xml file can have any number of transport senders and receivers. So sample tarnsport.xml would look like below;

<transports>
  <transportSender name="tcp"
                     class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
    <transportSender name="local"
                     class="org.apache.axis2.transport.local.LocalTransportSender"/>

 <transportReceiver name="http"
                       class="org.apache.axis2.transport.http.SimpleHTTPServer">
        <parameter name="port">8080</parameter>
    </transportReceiver>
 </transports> 

If you want your transport to be auto start then add the following parameter to the  transportReceiver.
<parameter name=”AutoStart”>true</parameter>


[If any of the user does not like what I have done , please comment on this , I have no objection reverting my commits ]

Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/TransportDeployer.java
Modified:
    webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml

Modified: webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml?rev=651160&r1=651159&r2=651160&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml Wed Apr 23 22:45:25 2008
@@ -89,6 +89,7 @@
     <!--POJO deployer , this will alow users to drop .class file and make that into a service-->
     <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>
     <deployer extension=".jar" directory="servicejars" class="org.apache.axis2.jaxws.framework.JAXWSDeployer"/>
+    <deployer extension=".jar" directory="transports" class="org.apache.axis2.deployment.TransportDeployer"/>
 
     <!--<deployer extension=".jsa" directory="rmiservices" class="org.apache.axis2.rmi.deploy.RMIServiceDeployer"/>-->
     

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java?rev=651160&r1=651159&r2=651160&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java Wed Apr 23 22:45:25 2008
@@ -80,6 +80,11 @@
         this.deploymentEngine = deploymentEngine;
     }
 
+
+    public AxisConfigBuilder(AxisConfiguration axisConfiguration) {
+        this.axisConfig = axisConfiguration;
+    }
+
     public void populateConfig() throws DeploymentException {
         try {
             OMElement config_element = buildOM();
@@ -569,7 +574,8 @@
         }
     }
 
-    private void processTransportReceivers(Iterator trs_senders) throws DeploymentException {
+    public ArrayList  processTransportReceivers(Iterator trs_senders) throws DeploymentException {
+        ArrayList transportReceivers = new ArrayList();
         while (trs_senders.hasNext()) {
             TransportInDescription transportIN;
             OMElement transport = (OMElement) trs_senders.next();
@@ -610,14 +616,16 @@
                     processParameters(itr, transportIN, axisConfig);
                     // adding to axis2 config
                     axisConfig.addTransportIn(transportIN);
+                    transportReceivers.add(transportIN);
                 } catch (AxisFault axisFault) {
                     throw new DeploymentException(axisFault);
                 }
             }
         }
+        return transportReceivers;
     }
 
-    private void processTransportSenders(Iterator trs_senders) throws DeploymentException {
+    public void processTransportSenders(Iterator trs_senders) throws DeploymentException {
         while (trs_senders.hasNext()) {
             TransportOutDescription transportout;
             OMElement transport = (OMElement) trs_senders.next();

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/TransportDeployer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/TransportDeployer.java?rev=651160&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/TransportDeployer.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/TransportDeployer.java Wed Apr 23 22:45:25 2008
@@ -0,0 +1,99 @@
+/*
+ * 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.axis2.deployment;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.deployment.repository.util.DeploymentFileData;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.util.XMLUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class TransportDeployer implements Deployer {
+
+    private static Log log = LogFactory.getLog(TransportDeployer.class);
+
+    private ConfigurationContext configCtx;
+    private AxisConfiguration axisConfig;
+
+    public void init(ConfigurationContext configCtx) {
+        this.configCtx = configCtx;
+        axisConfig = configCtx.getAxisConfiguration();
+    }
+
+    public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
+        boolean isDirectory = deploymentFileData.getFile().isDirectory();
+        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            deploymentFileData.setClassLoader(isDirectory,
+                    axisConfig.getModuleClassLoader(),
+                    (File) axisConfig.getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR));
+
+            ClassLoader loader = deploymentFileData.getClassLoader();
+            Thread.currentThread().setContextClassLoader(loader);
+            InputStream xmlStream = loader.getResourceAsStream("META-INF/transport.xml");
+            OMElement element = (OMElement) XMLUtils.toOM(xmlStream);
+            element.build();
+            AxisConfigBuilder builder = new AxisConfigBuilder(axisConfig);
+            // Processing Transport Receivers
+            Iterator trs_Reivers =
+                    element.getChildrenWithName(new QName(DeploymentConstants.TAG_TRANSPORT_RECEIVER));
+            ArrayList transportReceivers = builder.processTransportReceivers(trs_Reivers);
+            for (int i = 0; i < transportReceivers.size(); i++) {
+                TransportInDescription transportInDescription = (TransportInDescription) transportReceivers.get(i);
+                Parameter paramter = transportInDescription.getParameter("AutoStart");
+                if (paramter != null) {
+                    configCtx.getListenerManager().addListener(transportInDescription, false);
+                    log.info("starting the transport : " + transportInDescription.getName());
+                }
+            }
+
+            // Processing Transport Senders
+            Iterator trs_senders =
+                    element.getChildrenWithName(new QName(DeploymentConstants.TAG_TRANSPORT_SENDER));
+
+            builder.processTransportSenders(trs_senders);
+
+
+        } catch (Exception e) {
+            log.error(e.getMessage());
+        } finally {
+            Thread.currentThread().setContextClassLoader(contextClassLoader);
+        }
+    }
+
+    public void setDirectory(String directory) {
+    }
+
+    public void setExtension(String extension) {
+    }
+
+    public void unDeploy(String fileName) throws DeploymentException {
+    }
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml?rev=651160&r1=651159&r2=651160&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml Wed Apr 23 22:45:25 2008
@@ -67,6 +67,7 @@
 
     <!--POJO deployer , this will alow users to drop .class file and make that into a service-->
     <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>
+    <deployer extension=".jar" directory="transports" class="org.apache.axis2.deployment.TransportDeployer"/>
 
     <!-- Following parameter will set the host name for the epr-->
     <!--<parameter name="hostname" locked="true">myhost.com</parameter>-->



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org