Author: mmerz
Date: Tue Oct 19 10:52:21 2004
New Revision: 55079

Modified:
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
Log:
The JWS is now copied rather than moved to the compile location so the user 
won't
lose the original when APT hangs indefinitely.  The classloader is reused so the
SOAPService doesn't have to be reinitialized on each request.

Contributor: Jonathan Colwell



Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
    (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
    Tue Oct 19 10:52:21 2004
@@ -28,6 +28,7 @@
 import java.io.File;
 import java.io.FileFilter;
 import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.FileWriter;
@@ -92,8 +93,8 @@
     protected static Log log =
         LogFactory.getLog(DropInDeploymentHandler.class.getName());
 
-    private Map<Class, SOAPService> mSoapServiceMap =
-        new HashMap<Class, SOAPService>();
+    protected Map<String, SOAPService> soapServices = new HashMap<String,
+                                                                  
SOAPService>();
 
     /**
      * @param mc
@@ -142,7 +143,7 @@
         
         if (null != clazz)
         {
-            rpc = mSoapServiceMap.get(clazz);
+            rpc = soapServices.get(clazz.getName());
             if (null == rpc)
             {
                 WebServiceTYPEMetadata wsm =
@@ -213,7 +214,7 @@
             rpc.setStyle(sd.getStyle());
             rpc.setUse(sd.getUse());
                 
-            mSoapServiceMap.put(cls, rpc);                
+            soapServices.put(cls.getName(), rpc);
         }
         return rpc;
     }
@@ -326,16 +327,19 @@
                 {
                     File javaFile = new File(jFile);
                     try {
-                        srcFile.renameTo(javaFile);
-                        if (0 != 
compile(ClasspathUtils.getDefaultClasspath(mc), outDirPath, jFile))
+                        copyFile(srcFile,javaFile);
+                        if (0 != compile(ClasspathUtils
+                                            .getDefaultClasspath(mc),
+                                            outDirPath, jFile))
                         {
                             clsFile.delete();
                         }
                         ClassUtils.removeClassLoader(clsName);
-                        mSoapServiceMap.remove(clsName); // clean out the 
cached service
+                        soapServices.remove(clsName); 
+                        // clean out the cached service
                     }
                     finally {
-                        javaFile.renameTo(srcFile);
+                        javaFile.delete();
                     }
                 }
 
@@ -348,6 +352,7 @@
                         new URL[]{outDirectory.toURL()},
                         mc.getClassLoader()
                     ); 
+                    ClassUtils.setClassLoader(clsName, cl);
                 }
                 mc.setClassLoader(cl);
 
@@ -357,6 +362,19 @@
         return null;
     }
 
+    private void copyFile(File src, File dest) 
+        throws IOException
+    {
+        byte[] buf = new byte[4096];
+        FileInputStream fis = new FileInputStream(src);
+        FileOutputStream fos = new FileOutputStream(dest);
+        for (int count = 0; (count = fis.read(buf)) > 0;) {
+            fos.write(buf, 0, count);
+        }
+        fis.close();
+        fos.close();
+    }
+
     /**
      * @param classpath
      * @param outDirPath
@@ -415,4 +433,4 @@
         
         return result;
     }
-}
\ No newline at end of file
+}

Reply via email to