You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by de...@apache.org on 2006/04/06 14:38:50 UTC

svn commit: r391973 - in /webservices/axis2/trunk/java/modules: core/src/org/apache/axis2/deployment/ core/src/org/apache/axis2/deployment/repository/util/ core/src/org/apache/axis2/transport/http/ webapp/conf/

Author: deepal
Date: Thu Apr  6 05:38:47 2006
New Revision: 391973

URL: http://svn.apache.org/viewcvs?rev=391973&view=rev
Log:
added War based Axisconfigurator 
- There can be 4 parameters in web.xml to give repo and axis2.xml
- remove static variable in WSInfoList.java

Added:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/WarBasedAxisConfigurator.java
Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentEngine.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfoList.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java
    webservices/axis2/trunk/java/modules/webapp/conf/web.xml

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentEngine.java?rev=391973&r1=391972&r2=391973&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentEngine.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentEngine.java Thu Apr  6 05:38:47 2006
@@ -29,11 +29,13 @@
 import org.apache.axis2.deployment.util.Utils;
 import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.engine.Phase;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.phaseresolver.PhaseMetadata;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.wsdl.WSDLConstants;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -210,7 +212,9 @@
         }
     }
 
-    private ArrayList populateService(AxisServiceGroup serviceGroup, URL servicesURL, String serviceName) throws DeploymentException {
+    private ArrayList populateService(AxisServiceGroup serviceGroup,
+                                      URL servicesURL,
+                                      String serviceName) throws DeploymentException {
         try {
             serviceGroup.setServiceGroupName(serviceName);
             DeploymentClassLoader serviceClassLoader = new DeploymentClassLoader(
@@ -272,6 +276,16 @@
                                     new WSDL2AxisServiceBuilder(wsdlStream, axisService);
                             axisService = wsdl2AxisServiceBuilder.populateService();
                             axisService.setWsdlfound(true);
+                            // Set the default message receiver for the operations that were
+                            // not listed in the services.xml
+                            Iterator operations = axisService.getOperations();
+                            while (operations.hasNext()) {
+                                AxisOperation operation = (AxisOperation) operations.next();
+                                if (operation.getMessageReceiver() == null) {
+                                    operation.setMessageReceiver(loadDefaultMessageReceiver(
+                                            operation.getMessageExchangePattern(), axisService));
+                                }
+                            }
                         }
                     }
                 }
@@ -283,6 +297,19 @@
             throw new DeploymentException(e);
         }
         return null;
+    }
+
+    protected MessageReceiver loadDefaultMessageReceiver(String mepURL, AxisService service) {
+        MessageReceiver messageReceiver;
+        if (mepURL == null) {
+            mepURL = WSDLConstants.MEP_URI_IN_OUT;
+        }
+        if (service != null) {
+            messageReceiver = service.getMessageReceiver(mepURL);
+            if (messageReceiver != null)
+                return messageReceiver;
+        }
+        return axisConfig.getMessageReceiver(mepURL);
     }
 
     /**

Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/WarBasedAxisConfigurator.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/WarBasedAxisConfigurator.java?rev=391973&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/WarBasedAxisConfigurator.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/WarBasedAxisConfigurator.java Thu Apr  6 05:38:47 2006
@@ -0,0 +1,110 @@
+package org.apache.axis2.deployment;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisConfigurator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* 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.
+*
+*
+*/
+
+public class WarBasedAxisConfigurator implements AxisConfigurator {
+
+    private AxisConfiguration axisConfig;
+    private Log log = LogFactory.getLog(getClass());
+
+    public WarBasedAxisConfigurator(ServletConfig config) {
+        try {
+            DeploymentEngine deploymentEngine = new DeploymentEngine();
+            String axis2xmlpath = config.getInitParameter("axis2.xml.path");
+            String repository;
+            InputStream axis2Steram;
+            if (axis2xmlpath != null) {
+                axis2Steram = new FileInputStream(axis2xmlpath);
+                axisConfig = deploymentEngine.populateAxisConfiguration(axis2Steram);
+            } else {
+                String axisurl = config.getInitParameter("axis2.xml.url");
+                if (axisurl != null) {
+                    axis2Steram = new URL(axisurl).openStream();
+                    deploymentEngine.populateAxisConfiguration(axis2Steram);
+                } else {
+                    try {
+                        repository = config.getServletContext().getRealPath("/WEB-INF");
+                        axis2Steram = new FileInputStream(repository + "/conf/axis2.xml");
+                        axisConfig = deploymentEngine.populateAxisConfiguration(axis2Steram);
+                        setWebLocationProperty(config.getServletContext());
+                    } catch (Exception e) {
+                        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+                        axis2Steram = cl.getResourceAsStream(DeploymentConstants.AXIS2_CONFIGURATION_RESOURCE);
+                        axisConfig = deploymentEngine.populateAxisConfiguration(axis2Steram);
+                    }
+                }
+            }
+            String axis2repopath = config.getInitParameter("axis2.repository.path");
+            if (axis2repopath != null) {
+                deploymentEngine.loadRepository(axis2repopath);
+            } else {
+                String axis2repourl = config.getInitParameter("axis2.repository.url");
+                if (axis2repourl != null) {
+                    deploymentEngine.loadRepositoryFromURL(new URL(axis2repourl));
+                } else {
+                    try {
+                        repository = config.getServletContext().getRealPath("/WEB-INF");
+                        deploymentEngine.loadRepository(repository);
+                    } catch (Exception e) {
+                        deploymentEngine.loadFromClassPath();
+                    }
+                    deploymentEngine.loadFromClassPath();
+                }
+            }
+        } catch (FileNotFoundException e) {
+            log.info(e.getMessage());
+        } catch (DeploymentException e) {
+            log.info(e.getMessage());
+        } catch (MalformedURLException e) {
+            log.info(e.getMessage());
+        } catch (IOException e) {
+            log.info(e.getMessage());
+        }
+    }
+
+    /**
+     * To find out the location where web reposurce need to be coiped, when
+     * deployment fine any service aar with web resources.
+     *
+     * @param context
+     */
+    private void setWebLocationProperty(ServletContext context) {
+        String webpath = context.getRealPath("");
+        if (webpath == null || "".equals(webpath)) {
+            return;
+        }
+        File weblocation = new File(webpath);
+        System.setProperty("web.location", weblocation.getAbsolutePath());
+    }
+
+    public AxisConfiguration getAxisConfiguration() throws AxisFault {
+        return axisConfig;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfoList.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfoList.java?rev=391973&r1=391972&r2=391973&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfoList.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfoList.java Thu Apr  6 05:38:47 2006
@@ -30,7 +30,7 @@
     /**
      * This is to store all the jar files in a specified folder (WEB_INF)
      */
-    private static List jarList = new ArrayList();
+    private List jarList = new ArrayList();
     private boolean check = false;
 
     /**

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java?rev=391973&r1=391972&r2=391973&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java Thu Apr  6 05:38:47 2006
@@ -24,6 +24,7 @@
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.SessionContext;
+import org.apache.axis2.deployment.WarBasedAxisConfigurator;
 import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.engine.AxisConfiguration;
@@ -237,30 +238,9 @@
      */
     protected ConfigurationContext initConfigContext(ServletConfig config) throws ServletException {
         try {
-            ServletContext context = config.getServletContext();
-            String repoDir = config.getInitParameter("repository");
-            File rootDir = null;
-            if (repoDir == null) {
-                try {
-                    repoDir = context.getRealPath("/WEB-INF");
-                    rootDir = new File(context.getRealPath("/WEB-INF"));
-                    setWebLocationProperty(context);
-                } catch (Exception e) {
-                    String user_home = System.getProperty("user.home");
-                    File axis2repo = new File(user_home, "axis2repository");
-                    if (axis2repo.exists()) {
-                        repoDir = axis2repo.getAbsolutePath();
-                        log.error("Axis2 run using the repositoty found in : " + repoDir);
-                    } else {
-                        log.error("Axis2 run without having a repository");
-                    }
-                }
-            }
-            //adding weblocation property
             ConfigurationContext configContext =
-                    ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoDir, null);
+                    ConfigurationContextFactory.createConfigurationContext(new WarBasedAxisConfigurator(config));
             configContext.setProperty(Constants.CONTAINER_MANAGED, Constants.VALUE_TRUE);
-            configContext.setRootDir(rootDir);
             return configContext;
         } catch (Exception e) {
             throw new ServletException(e);

Modified: webservices/axis2/trunk/java/modules/webapp/conf/web.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/webapp/conf/web.xml?rev=391973&r1=391972&r2=391973&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/webapp/conf/web.xml (original)
+++ webservices/axis2/trunk/java/modules/webapp/conf/web.xml Thu Apr  6 05:38:47 2006
@@ -9,8 +9,14 @@
         <display-name>Apache-Axis Servlet</display-name>
         <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
         <!--<init-param>-->
-            <!--<param-name>repository</param-name>-->
+            <!--<param-name>axis2.xml.path</param-name>-->
+            <!--<param-value>/WEB-INF/conf/axis2.xml</param-value>-->
+            <!--<param-name>axis2.xml.url</param-name>-->
+            <!--<param-value>http://localhot/myrepo/axis2.xml</param-value>-->
+            <!--<param-name>axis2.repository.path</param-name>-->
             <!--<param-value>/WEB-INF</param-value>-->
+            <!--<param-name>axis2.repository.url</param-name>-->
+            <!--<param-value>http://localhot/myrepo</param-value>-->
         <!--</init-param>-->
         <load-on-startup>1</load-on-startup>
     </servlet>