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 2005/05/25 15:14:48 UTC

svn commit: r178434 - in /webservices/axis/trunk/java/modules/core/src/org/apache/axis: deployment/DeploymentEngine.java deployment/repository/utill/ArchiveFileData.java deployment/repository/utill/ArchiveReader.java engine/AxisConfigurationImpl.java

Author: deepal
Date: Wed May 25 06:14:47 2005
New Revision: 178434

URL: http://svn.apache.org/viewcvs?rev=178434&view=rev
Log:
provide the facility to bundle module into single jar and engage those modules (this is really need in clien side)

Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/DeploymentEngine.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/repository/utill/ArchiveFileData.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/repository/utill/ArchiveReader.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfigurationImpl.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/DeploymentEngine.java?rev=178434&r1=178433&r2=178434&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/DeploymentEngine.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/DeploymentEngine.java Wed May 25 06:14:47 2005
@@ -41,6 +41,7 @@
 import javax.xml.stream.XMLStreamException;
 import java.io.*;
 import java.util.*;
+import java.util.zip.ZipInputStream;
 
 
 public class DeploymentEngine implements DeploymentConstants {
@@ -702,6 +703,5 @@
         }
         return axismodule;
     }
-
-
+   
 }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/repository/utill/ArchiveFileData.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/repository/utill/ArchiveFileData.java?rev=178434&r1=178433&r2=178434&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/repository/utill/ArchiveFileData.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/repository/utill/ArchiveFileData.java Wed May 25 06:14:47 2005
@@ -114,7 +114,7 @@
             } catch (Exception e) {
                 throw new AxisFault(e.getMessage(), e);
             }
-        }
+        } 
     }
     
     public void addModule(QName moduleName){

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/repository/utill/ArchiveReader.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/repository/utill/ArchiveReader.java?rev=178434&r1=178433&r2=178434&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/repository/utill/ArchiveReader.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/repository/utill/ArchiveReader.java Wed May 25 06:14:47 2005
@@ -25,9 +25,11 @@
 import org.apache.axis.description.ServiceDescription;
 import org.apache.axis.wsdl.builder.wsdl4j.WSDL1ToWOMBuilder;
 
-import java.io.FileInputStream;
+import java.io.*;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+import java.util.jar.JarInputStream;
 
 public class ArchiveReader implements DeploymentConstants {
 
@@ -115,6 +117,69 @@
             throw new DeploymentException(e.getMessage());
         }
     }
+
+    /**
+     * This method first check whether the given module is there in the user home dirctory if so return
+     * that , else try to read the given module form classpath (from resources ) if found first get the module.mar
+     * file from the resourceStream and write that into user home/axis2home/nodule directory
+     * @param moduleName
+     * @return
+     * @throws DeploymentException
+     */
+    public File creatModuleArchivefromResource(String moduleName) throws DeploymentException {
+        File modulearchiveFile = null;
+        try {
+            int BUFFER = 2048;
+            String userHome = System.getProperty("user.home");
+            File userHomedir = new File(userHome);
+            File modules = null;
+            File repository = new File(userHomedir, "Axis2Home");
+            if (!repository.exists()) {
+                repository.mkdirs();
+                modules = new File(repository, "modules");
+                modules.mkdirs();
+            }
+            String modulearchiveName =moduleName + ".mar";
+            modulearchiveFile = new File(modules,modulearchiveName);
+            if (modulearchiveFile.exists()) {
+                return modulearchiveFile;
+            } else {
+                modulearchiveFile.createNewFile();
+            }
+            FileOutputStream dest = new
+                    FileOutputStream(modulearchiveFile);
+            ZipOutputStream out = new ZipOutputStream(new
+                    BufferedOutputStream(dest));
+            byte data[] = new byte[BUFFER];
+
+            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            InputStream in = cl.getResourceAsStream("modules/" + moduleName + ".mar");
+            if(in == null ){
+                cl.getResourceAsStream("modules/" + moduleName + ".jar");
+            }
+            if(in == null){
+                throw new DeploymentException( moduleName + " dose not found");
+            }
+            ZipInputStream zin = null;
+            zin = new ZipInputStream(in);
+            ZipEntry entry;
+            while ((entry = zin.getNextEntry()) != null) {
+                ZipEntry zip = new ZipEntry(entry);
+                out.putNextEntry(zip);
+                System.out.println("entry = " + entry.getName());
+                int count;
+                while ((count = zin.read(data, 0, BUFFER)) != -1) {
+                    out.write(data, 0, count);
+                }
+            }
+            out.close();
+            zin.close();
+        } catch (Exception e) {
+            throw new DeploymentException(e.getMessage());
+        }
+        return  modulearchiveFile;
+    }
+
 }
 
 

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfigurationImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfigurationImpl.java?rev=178434&r1=178433&r2=178434&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfigurationImpl.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfigurationImpl.java Wed May 25 06:14:47 2005
@@ -18,9 +18,12 @@
 import org.apache.axis.description.*;
 import org.apache.axis.phaseresolver.PhaseMetadata;
 import org.apache.axis.phaseresolver.PhaseResolver;
+import org.apache.axis.deployment.repository.utill.ArchiveReader;
+import org.apache.axis.deployment.DeploymentEngine;
 
 import javax.xml.namespace.QName;
 import java.util.*;
+import java.io.File;
 
 /**
  * Class EngineRegistryImpl
@@ -317,6 +320,10 @@
 
     public void engageModule(QName moduleref) throws AxisFault {
         ModuleDescription module = getModule(moduleref);
+        if(module == null ) {
+            File file =  new  ArchiveReader().creatModuleArchivefromResource(moduleref.getLocalPart());
+            module =  new DeploymentEngine().buildModule(file);
+        }
         if (module != null) {
             new PhaseResolver(this).engageModuleGlobally(module);
         }