ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r373800 - in /webservices/axis2/trunk/java/modules/core: src/org/apache/axis2/deployment/ src/org/apache/axis2/deployment/listener/ src/org/apache/axis2/deployment/repository/util/ test-resources/deployment/module1/ test-resources/deploymen...
Date Tue, 31 Jan 2006 12:13:19 GMT
Author: deepal
Date: Tue Jan 31 04:13:00 2006
New Revision: 373800

URL: http://svn.apache.org/viewcvs?rev=373800&view=rev
Log:
- added a way to load modules from class path
(see the mail for more info)

Removed:
    webservices/axis2/trunk/java/modules/core/test-resources/deployment/outservice/META-INF/service.wsdl
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/listener/RepositoryListenerImpl.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveFileData.java
    webservices/axis2/trunk/java/modules/core/test-resources/deployment/module1/build.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=373800&r1=373799&r2=373800&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
Tue Jan 31 04:13:00 2006
@@ -335,36 +335,27 @@
         if (wsToDeploy.size() > 0) {
             for (int i = 0; i < wsToDeploy.size(); i++) {
                 currentArchiveFile = (ArchiveFileData) wsToDeploy.get(i);
-
                 boolean explodedDir = currentArchiveFile.getFile().isDirectory();
                 int type = currentArchiveFile.getType();
-
                 try {
                     ArchiveReader archiveReader;
                     StringWriter errorWriter = new StringWriter();
-
                     switch (type) {
                         case TYPE_SERVICE :
                             currentArchiveFile.setClassLoader(explodedDir,
                                     axisConfig.getServiceClassLoader());
                             archiveReader = new ArchiveReader();
-
                             String serviceStatus = "";
-
                             try {
                                 HashMap wsdlservice = archiveReader.processWSDLs(currentArchiveFile,
                                         this);
-
                                 AxisServiceGroup sericeGroup = new AxisServiceGroup(axisConfig);
-
                                 sericeGroup.setServiceGroupClassLoader(
                                         currentArchiveFile.getClassLoader());
-
                                 ArrayList serviceList = archiveReader.processServiceGroup(
                                         currentArchiveFile.getAbsolutePath(), this,
                                         sericeGroup, explodedDir, wsdlservice,
                                         axisConfig);
-
                                 addServiceGroup(sericeGroup, serviceList);
                                 log.debug(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS,
                                         currentArchiveFile.getName()));
@@ -372,27 +363,21 @@
                                 log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE,
                                         currentArchiveFile.getName(),
                                         de.getMessage()));
-
                                 PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
-
                                 de.printStackTrace(error_ptintWriter);
                                 serviceStatus = "Error:\n" + errorWriter.toString();
                             } catch (AxisFault axisFault) {
                                 log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE,
                                         currentArchiveFile.getName(),
                                         axisFault.getMessage()));
-
                                 PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
-
                                 axisFault.printStackTrace(error_ptintWriter);
                                 serviceStatus = "Error:\n" + errorWriter.toString();
                             } catch (Exception e) {
                                 log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE,
                                         currentArchiveFile.getName(),
                                         e.getMessage()));
-
                                 PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
-
                                 e.printStackTrace(error_ptintWriter);
                                 serviceStatus = "Error:\n" + errorWriter.toString();
                             } finally {
@@ -401,22 +386,16 @@
                                             getAxisServiceName(currentArchiveFile.getName()),
                                             serviceStatus);
                                 }
-
                                 currentArchiveFile = null;
                             }
-
                             break;
-
                         case TYPE_MODULE :
                             currentArchiveFile.setClassLoader(explodedDir,
                                     axisConfig.getModuleClassLoader());
                             archiveReader = new ArchiveReader();
-
                             String moduleStatus = "";
-
                             try {
                                 AxisModule metaData = new AxisModule();
-
                                 metaData.setModuleClassLoader(currentArchiveFile.getClassLoader());
                                 metaData.setParent(axisConfig);
                                 archiveReader.readModuleArchive(currentArchiveFile.getAbsolutePath(),
@@ -430,18 +409,14 @@
                                 log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_MODULE,
                                         currentArchiveFile.getName(),
                                         e.getMessage()));
-
                                 PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
-
                                 e.printStackTrace(error_ptintWriter);
                                 moduleStatus = "Error:\n" + errorWriter.toString();
                             } catch (AxisFault axisFault) {
                                 log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_MODULE,
                                         currentArchiveFile.getName(),
                                         axisFault.getMessage()));
-
                                 PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
-
                                 axisFault.printStackTrace(error_ptintWriter);
                                 moduleStatus = "Error:\n" + errorWriter.toString();
                             } finally {
@@ -449,10 +424,8 @@
                                     axisConfig.getFaultyModules().put(
                                             getAxisServiceName(currentArchiveFile.getName()),
moduleStatus);
                                 }
-
                                 currentArchiveFile = null;
                             }
-
                             break;
                     }
                 } catch (AxisFault axisFault) {
@@ -483,6 +456,8 @@
             AxisConfigBuilder builder = new AxisConfigBuilder(in, this, axisConfig);
             builder.populateConfig();
             axisConfig.setPhasesinfo(phasesinfo);
+            //To load modules from the class path
+            new RepositoryListenerImpl(this);
             return axisConfig;
         } else if (axis2repository != null) {
             InputStream in;

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/listener/RepositoryListenerImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/listener/RepositoryListenerImpl.java?rev=373800&r1=373799&r2=373800&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/listener/RepositoryListenerImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/listener/RepositoryListenerImpl.java
Tue Jan 31 04:13:00 2006
@@ -45,7 +45,7 @@
      * First, it initializes the system, by loading all the modules in the /modules directory
      * and then creates a WSInfoList to store information about available modules and services.
      *
-     * @param folderName    path to parent directory that the listener should listen to
+     * @param folderName       path to parent directory that the listener should listen to
      * @param deploymentEngine reference to engine registry for updates
      */
     public RepositoryListenerImpl(String folderName, DeploymentEngine deploymentEngine) {
@@ -53,6 +53,13 @@
         wsInfoList = new WSInfoList(deploymentEngine);
         this.deploymentEngine = deploymentEngine;
         init();
+        loadClassPathModules();
+    }
+
+    //The constructor , which loads moduls from class path
+    public RepositoryListenerImpl(DeploymentEngine deploymentEngine) {
+        this.deploymentEngine = deploymentEngine;
+        loadClassPathModules();
     }
 
     /**
@@ -80,6 +87,58 @@
         }
     }
 
+    private void loadClassPathModules() {
+        String classPath = getLocation();
+        System.out.println("classpath1" + classPath);
+        int lstindex = classPath.lastIndexOf(File.separatorChar);
+        if (lstindex > 0) {
+            classPath = classPath.substring(0, lstindex);
+        } else {
+            classPath = ".";
+        }
+        System.out.println("classptah = " + classPath);
+        File root = new File(classPath);
+        File[] files = root.listFiles();
+        if (files != null) {
+            for (int i = 0; i < files.length; i++) {
+                File file = files[i];
+                if (!file.isDirectory()) {
+                    if (ArchiveFileData.isModuleArchiveFile(file.getName())) {
+                        //adding moduls in the class path
+                        wsInfoList.addWSInfoItem(file, TYPE_MODULE);
+                        System.out.println("added a module: " + file.getName());
+                    }
+                }
+            }
+        }
+        deploymentEngine.doDeploy();
+    }
+
+    /**
+     * To get the location of the Axis2.jar from that I can drive the location of class path
+     *
+     * @return String (location of the axis2 jar)
+     */
+    private String getLocation() {
+        try {
+            Class clazz = Class.forName("org.apache.axis2.engine.AxisEngine");
+            java.net.URL url = clazz.getProtectionDomain().getCodeSource().getLocation();
+            String location = url.toString();
+            if (location.startsWith("jar")) {
+                url = ((java.net.JarURLConnection) url.openConnection()).getJarFileURL();
+                location = url.toString();
+            }
+            if (location.startsWith("file")) {
+                java.io.File file = new java.io.File(url.getFile());
+                return file.getAbsolutePath();
+            } else {
+                return url.toString();
+            }
+        } catch (Throwable t) {
+            return "an unknown location";
+        }
+    }
+
     /**
      * Finds a list of services in the folder and adds to wsInfoList.
      */
@@ -101,7 +160,7 @@
     }
 
     /**
-     * Searches a given folder for jar files and adds them to a list in the 
+     * Searches a given folder for jar files and adds them to a list in the
      * WSInfolist class.
      */
     private void findServicesInDirectory(String folderName) {

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveFileData.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveFileData.java?rev=373800&r1=373799&r2=373800&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveFileData.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveFileData.java
Tue Jan 31 04:13:00 2006
@@ -86,7 +86,7 @@
     }
 
     public static boolean isModuleArchiveFile(String filename) {
-        return ((filename.endsWith(".jar")) || (filename.endsWith(".mar")));
+        return (filename.endsWith(".mar"));
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/core/test-resources/deployment/module1/build.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test-resources/deployment/module1/build.xml?rev=373800&r1=373799&r2=373800&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test-resources/deployment/module1/build.xml
(original)
+++ webservices/axis2/trunk/java/modules/core/test-resources/deployment/module1/build.xml
Tue Jan 31 04:13:00 2006
@@ -31,14 +31,14 @@
         </copy>
 
         <mkdir dir="${jar.dir}"/>
-        <jar jarfile="${jar.dir}/module1.jar" basedir="${build.classes}">
+        <jar jarfile="${jar.dir}/module1.mar" basedir="${build.classes}">
             <include name="**"/>
         </jar>
         <delete dir="${build}"/>
     </target>
 
     <target name="init">
-        <uptodate property="jars.uptodate" targetfile="${jar.dir}/module1.jar">
+        <uptodate property="jars.uptodate" targetfile="${jar.dir}/module1.mar">
             <srcfiles dir="${src}">
                 <include name="**/*.java"/>
                 <include name="**/*.xml"/>



Mime
View raw message