User: schulze 
  Date: 00/11/06 13:10:27

  Modified:    src/main/org/jboss/deployment Deployment.java
                        J2eeDeployer.java URLWizzard.java
  Log:
  made it resistent against some Windowz cant remove file once an url connection was 
opened on it bug...
  now the deployer cleans up the deploymnet dir on startService() and doesnt abort if 
any file deletion fails
  
  finally made some minor changes in the deployment structure
  
  Revision  Changes    Path
  1.4       +1 -4      jboss/src/main/org/jboss/deployment/Deployment.java
  
  Index: Deployment.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/deployment/Deployment.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Deployment.java   2000/11/02 22:43:53     1.3
  +++ Deployment.java   2000/11/06 21:10:26     1.4
  @@ -15,7 +15,7 @@
   /** Represents a J2EE application or module (EJB.jar, Web.war or App.ear). <br>
   *
   *  @author <a href="mailto:[EMAIL PROTECTED]">Daniel Schulze</a>
  -*  @version $Revision: 1.3 $
  +*  @version $Revision: 1.4 $
   */
   public class Deployment
      implements java.io.Serializable
  @@ -25,9 +25,6 @@
      
      /** the local position of the apps root directory */
      protected URL localUrl;
  -   
  -   /** the directory for common libraries */
  -   protected URL commonLibs;
      
      /** the content of the <code>commonLibs</code> directory as 
      URL Collection */
  
  
  
  1.9       +28 -28    jboss/src/main/org/jboss/deployment/J2eeDeployer.java
  
  Index: J2eeDeployer.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/deployment/J2eeDeployer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- J2eeDeployer.java 2000/11/03 17:38:51     1.8
  +++ J2eeDeployer.java 2000/11/06 21:10:26     1.9
  @@ -54,7 +54,7 @@
   *  (ContainerFactory for jBoss and EmbededTomcatService for Tomcat).
   *
   *   @author <a href="mailto:[EMAIL PROTECTED]">Daniel Schulze</a>
  -*   @version $Revision: 1.8 $
  +*   @version $Revision: 1.9 $
   */
   public class J2eeDeployer 
   extends ServiceMBeanSupport
  @@ -281,7 +281,20 @@
      {
         if (!warDeployerAvailable ())
            log.log ("No war deployer found - only EJB deployment available...");
  -   
  +         
  +      // clean up the deployment directory since on some Windowz the file removement
  +      // during runtime doesnt work...
  +      log.log("cleaning up deployment directory "+DEPLOYMENT_DIR.toURL());
  +      File[] files =  DEPLOYMENT_DIR.listFiles();
  +      for (int i = 0, l = files.length; i<l; ++i)
  +         try
  +         {
  +            URLWizzard.deleteTree(files[i].toURL());
  +         }
  +         catch (IOException _ioe)
  +         {
  +            log.log("couldnd remove file tree: "+files[i].toURL().toString());
  +         }
      }
      
      
  @@ -472,23 +485,14 @@
         m.name = getAppName (_source);
         log.log ("installing ejb package: " + m.name);
         
  -      // the base dir for this EJB package
  -      URL destDir = URLWizzard.createTempDir (_d.localUrl, "ejb");
  -      
         // download the package...
  -      URL localUrl = URLWizzard.download(_source, new URL (destDir, "ejb.jar"));
  +      URL localUrl = URLWizzard.downloadTemporary(_source, _d.localUrl, "ejb", 
".jar");
         
         // download alternative Descriptors (ejb-jar.xml, jboss.xml, ...)
         // DOESNT WORK YET!!!
         if (_altDD != null && _altDD.length > 0)
         {
  -         URL metaDir = new URL (destDir.getFile () + "/META-INF"); 
  -         for (int i = 0, l = _altDD.length; i < l; ++i)
  -         {
  -            URLWizzard.download (_altDD[i], new URL (metaDir,"bla"));
  -         }
  -         // this in the classpath before the real jar file to find this descriptors 
first
  -         m.localUrls.add (destDir);
  +         ;
         }
         
         m.localUrls.add (localUrl);
  @@ -508,11 +512,8 @@
         m.name = getAppName (_source);
         log.log ("installing web package: " + m.name);
         
  -      // the base dir for this WAR package
  -      URL destDir = URLWizzard.createTempDir (_d.localUrl, "war");
  -      
         // download the package...
  -      URL localUrl = URLWizzard.downloadAndInflate (_source, new URL (destDir, 
"expandedWar"));
  +      URL localUrl = URLWizzard.downloadAndInflateTemporary (_source, _d.localUrl, 
"war");
         
         // save the contextName
         m.webContext = _context;
  @@ -521,12 +522,7 @@
         // DOESNT WORK YET!!!
         if (_altDD != null && _altDD.length > 0)
         {
  -         URL metaDir = new URL (destDir.getFile () + "/WEB-INF"); 
  -         for (int i = 0, l = _altDD.length; i < l; ++i)
  -         {
  -            URLWizzard.download (_altDD[i], new URL (metaDir,"bla"));
  -         }
  -         m.localUrls.add (destDir);
  +         ;
         }
         
         m.localUrls.add (localUrl);
  @@ -550,9 +546,6 @@
      */
      private void addCommonLibs (Deployment _d, Manifest _mf, URL _base) throws 
IOException
      {
  -      if (_d.commonLibs == null)
  -         _d.commonLibs = URLWizzard.createTempDir (_d.localUrl, "common");
  -
         String cp = _mf.getMainAttributes ().getValue(Attributes.Name.CLASS_PATH);
         
         if (cp != null)
  @@ -564,8 +557,7 @@
               try
               {
                  URL src = new URL(_base, classPath);
  -               URL dest = new URL (_d.commonLibs, getAppName (src));
  -               _d.commonUrls.add (URLWizzard.download (src, dest));
  +               _d.commonUrls.add (URLWizzard.downloadTemporary (src, _d.localUrl, 
"lib", ".jar"));
                  log.error("added " + classPath + " to common classpath");
               } 
               catch (Exception e)
  @@ -587,6 +579,14 @@
         try 
         {
            url = new URL (DEPLOYMENT_DIR.toURL (), _name);
  +         
  +         // because of the deletion problem in some WIndowz 
  +         // we remove the CONFIG separatly (this should always work)
  +         // so that on stopService () now exceptions were thrown when he thinks
  +         // some apps are still deployed...
  +         URLWizzard.deleteTree (new URL (url, CONFIG));      
  +         log.log (CONFIG+" file deleted.");
  +         
            URLWizzard.deleteTree (url);      
            log.log ("file tree "+url.toString ()+" deleted.");
         } catch (MalformedURLException _mfe) { // should never happen
  
  
  
  1.5       +10 -6     jboss/src/main/org/jboss/deployment/URLWizzard.java
  
  Index: URLWizzard.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/deployment/URLWizzard.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- URLWizzard.java   2000/11/03 02:19:05     1.4
  +++ URLWizzard.java   2000/11/06 21:10:26     1.5
  @@ -33,7 +33,7 @@
   * Very scratchy! Any improvements are welcome!
   *      
   *    @author Daniel Schulze <[EMAIL PROTECTED]>
  -*    @version $Revision: 1.4 $
  +*    @version $Revision: 1.5 $
   */
   public class URLWizzard
   {
  @@ -150,11 +150,7 @@
      }
      
      
  -   
  -   
  -   
  -   
  -   /** inflates the given zip file into the given directory */
  +   /** inflates the given zip file into the given directory  */
      public static URL downloadAndInflate (URL _src, URL _dest) throws IOException
      {
         InputStream in;
  @@ -203,6 +199,14 @@
         
         return _dest;
      }
  +
  +   /** inflates the given zip file into a directory created in the dest directory 
with the 
  +   given prefix */
  +   public static URL downloadAndInflateTemporary (URL _src, URL _destDir, String 
_prefix) throws IOException
  +   {
  +      return downloadAndInflate (_src, createTempDir (_destDir, _prefix));
  +   }
  +   
      
      /** creates a directory like the File.createTempFile method */
      public static URL createTempDir (URL _baseDir, String _prefix) throws IOException
  
  
  

Reply via email to