User: d_jencks
  Date: 01/11/18 22:58:56

  Modified:    src/main/org/jboss/deployment DeployerMBeanSupport.java
                        ServiceDeployer.java
  Log:
  Cleaned up deployment a bit and enabled jar in sar
  
  Revision  Changes    Path
  1.10      +220 -222  jboss/src/main/org/jboss/deployment/DeployerMBeanSupport.java
  
  Index: DeployerMBeanSupport.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/deployment/DeployerMBeanSupport.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DeployerMBeanSupport.java 2001/11/12 06:52:15     1.9
  +++ DeployerMBeanSupport.java 2001/11/19 06:58:56     1.10
  @@ -31,13 +31,15 @@
   import org.jboss.deployment.DeploymentException;
   import org.jboss.logging.Logger;
   import org.jboss.system.ServiceMBeanSupport;
  +import org.jboss.system.URLClassLoader;
  +import java.util.List;
   
   /**
    * An abstract base class for deployer service implementations.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Toby Allsopp</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
  - * @version $Revision: 1.9 $
  + * @version $Revision: 1.10 $
    *
    * <p><b>Revisions:</b>
    *
  @@ -61,7 +63,7 @@
      /*
       * log4j Category for logging
       */
  -   protected Logger category;
  +   //protected Logger category;
   
      /**
       *  The directory that will contain local copies of deployed packages
  @@ -72,16 +74,16 @@
      
      private static int nextNum = 0;
   
  -   private static String generateUniqueDirName()
  +   private static synchronized String generateUniqueDirName()
      {
         int thisNum = nextNum++;
  -      return "deploy." + thisNum + ".";
  +      return "deploy." + thisNum;
      }
   
      // Constructors --------------------------------------------------
      public DeployerMBeanSupport()
      {
  -      category =  Logger.create(getClass());
  +      //category =  Logger.create(getClass());
      }
   
      
  @@ -99,23 +101,6 @@
            {
               log.info("not deploying package because it is already deployed: " + u);
               return;
  -            /*Object info = deployments.get(u);
  -            try
  -            {
  -               undeploy(u, info);
  -            }
  -            catch (Throwable t)
  -            {
  -               log.error("undeploy failed", t);
  -               if (t instanceof Exception)
  -               {
  -                  if (t instanceof IOException) throw (IOException) t;
  -                  if (t instanceof DeploymentException)
  -                     throw (DeploymentException) t;
  -                  throw (RuntimeException) t;
  -               }
  -               throw (Error) t;
  -               }*/
            }
            try
            {
  @@ -182,12 +167,12 @@
         deployDir = new File(deployTmpDir, getName());
         if (deployDir.exists())
         {
  -         category.info("Found a temp directory left over from a previous run - " +
  +         getLog().info("Found a temp directory left over from a previous run - " +
                  "deleting it.");
            // What could it mean?
            if (!recursiveDelete(deployDir))
            {
  -            category.warn("Unable to recursively delete temp directory '" +
  +            getLog().warn("Unable to recursively delete temp directory '" +
                     deployDir + "' that appears to be left over from " +
                     "the previous run. This might cause problems.");
            }
  @@ -197,7 +182,7 @@
            throw new DeploymentException("Can't create temp directory '" +
                  deployDir + "'");
         }
  -      category.info("Temporary deploy directory is " + deployDir);
  +      getLog().info("Temporary deploy directory is " + deployDir);
      }
   
       /**
  @@ -210,7 +195,7 @@
         // Remove our temp directory
         if (!recursiveDelete(deployDir))
         {
  -         category.warn("Unable to recursively delete the temp directory '" +
  +         getLog().warn("Unable to recursively delete the temp directory '" +
                  deployDir + "' - it should be cleaned up when the " +
                  "server is next restarted.");
         }
  @@ -285,80 +270,6 @@
       // unpacking packages recursively, finding things in packages,
       // and similar tasks needed for most deployment activities.
        //
  -    
  -   protected Collection recursiveFind(File dir, FileFilter filter)
  -   {
  -      Collection files = new ArrayList();
  -      File[] candidates = dir.listFiles();
  -      if (candidates == null)
  -      {
  -         return null;
  -      }
  -
  -      for (int i = 0; i < candidates.length; ++i)
  -      {
  -         File candidate = candidates[i];
  -         if (candidate.isDirectory())
  -         {
  -            files.addAll(recursiveFind(candidate, filter));
  -         }
  -         else if (filter.accept(candidate))
  -         {
  -            files.add(candidate);
  -         }
  -      }
  -
  -      return files;
  -   }
  -
  -   protected void copyDirectory(File srcDir, File destDir)
  -          throws DeploymentException, IOException
  -   {
  -      File[] files = srcDir.listFiles();
  -      if (files == null)
  -      {
  -         throw new DeploymentException("Not a directory: '" +
  -               srcDir + "'");
  -      }
  -
  -      destDir.mkdirs();
  -      for (int i = 0; i < files.length; ++i)
  -      {
  -         File file = files[i];
  -         File dest = new File(destDir, file.getName());
  -         if (file.isDirectory())
  -         {
  -            copyDirectory(file, dest);
  -         }
  -         else
  -         {
  -            copyFile(file, dest);
  -         }
  -      }
  -   }
  -
  -   protected void copyFile(File src, File dest)
  -          throws IOException
  -   {
  -      InputStream in = new FileInputStream(src);
  -      try
  -      {
  -         OutputStream out = new FileOutputStream(dest);
  -         try
  -         {
  -            copy(in, out);
  -         }
  -         finally
  -         {
  -            out.close();
  -         }
  -      }
  -      finally
  -      {
  -         in.close();
  -      }
  -   }
  -
       /**
        * The <code>inflateJar</code> copies the jar entries
        * from the jar url jarUrl to the directory destDir.
  @@ -374,6 +285,8 @@
       protected void inflateJar(URL url, File destDir, String path)
             throws DeploymentException, IOException
      {
  +      /*
  +      //Why doesn't this work???? Maybe in java 1.4?
         URL jarUrl;
         try
         {
  @@ -387,7 +300,9 @@
         JarURLConnection jarConnection =
               (JarURLConnection)jarUrl.openConnection();
         JarFile jarFile = jarConnection.getJarFile();
  -
  +      */
  +      String filename = url.getFile();
  +      JarFile jarFile = new JarFile(filename);
         try
         {
            for (Enumeration e = jarFile.entries(); e.hasMoreElements(); )
  @@ -436,6 +351,113 @@
         }
      }
   
  +   protected void extractPackages(URL url, DeploymentInfo di)
  +          throws DeploymentException, IOException
  +   {
  +      if (url.getFile().endsWith(".xml")) 
  +      {
  +         di.addXmlUrl(url);
  +         return;
  +      }
  +      
  +      //if its a jar or war, add to list and stop
  +      if (url.getFile().endsWith(".jar") || url.getFile().endsWith(".war")) 
  +      {
  +         di.addClassUrl(url);
  +         return;
  +      }
  +      //Sars may contain files or other packages
  +      if (url.getFile().endsWith(".sar")) 
  +      {
  +         di.addClassUrl(url);
  +      }
  +      
  +
  +      URL jarUrl;
  +      try
  +      {
  +         jarUrl = new URL("jar:" + url.toString() + "!/");
  +      }
  +      catch (MalformedURLException mfue)
  +      {
  +         throw new DeploymentException("Oops! Couldn't convert URL to a jar URL", 
mfue);
  +      }
  +
  +      JarURLConnection jarConnection =
  +            (JarURLConnection)jarUrl.openConnection();
  +      JarFile jarFile = jarConnection.getJarFile();
  +
  +      try
  +      {
  +         for (Enumeration e = jarFile.entries(); e.hasMoreElements(); )
  +         {
  +            JarEntry entry = (JarEntry)e.nextElement();
  +            String name = entry.getName();
  +            /*
  +//jar urls don't seem to work!
  
+jar:file:/usr/java/jboss/co6/jboss-all/build/output/jboss-3.0.0alpha/tmp/deploy/ServiceDeployer/copydeploy.28/jmx-ejb-connector-server.sar!/META-INF/jboss-service.xml
  +cannot be opened!
  +            if (name.endsWith(".xml")) 
  +            {
  +               di.addXmlUrl(new URL(jarUrl, name));
  +            } // end of if ()
  +            
  +            else 
  +            */
  +            if (name.endsWith(".jar") 
  +                || name.endsWith(".xml") 
  +                || name.endsWith(".sar") 
  +                || name.endsWith(".ear") 
  +                || name.endsWith(".rar") 
  +                || name.endsWith(".war") 
  +                || name.endsWith(".zip")) 
  +            {
  +               File outFile = new File(getUniqueDir(di), name);
  +               File outFileParent = outFile.getParentFile();
  +               outFileParent.mkdirs();
  +               
  +               InputStream in = jarFile.getInputStream(entry);
  +               try
  +               {
  +                  OutputStream out = new FileOutputStream(outFile);
  +                  try
  +                  {
  +                     copy(in, out);
  +                  }
  +                  finally
  +                  {
  +                     out.close();
  +                  }
  +               }
  +               finally
  +               {
  +                  in.close();
  +               }
  +               //stop for these,
  +               URL packageURL = new URL("file:" + outFile.toString());
  +               if (name.endsWith(".jar") 
  +                   || name.endsWith(".zip") 
  +                   || name.endsWith(".war")) 
  +               {
  +                  di.addClassUrl(packageURL);
  +               } // end of if ()
  +               //continue for others (xml, rar, ear, sar)
  +               else 
  +               {
  +                  extractPackages(packageURL, di);    
  +               } // end of else
  +            }
  +
  +            
  +         } // end of if ()
  +
  +      }
  +      finally
  +      {
  +         jarFile.close();
  +      }
  +   }
  +
      protected void copy(InputStream in, OutputStream out)
             throws IOException
      {
  @@ -446,7 +468,7 @@
            out.write(buffer, 0, read);
         }
      }
  -
  +   
      protected boolean recursiveDelete(File f)
      {
         if (f.isDirectory())
  @@ -462,23 +484,21 @@
         }
         return f.delete();
      }
  -
  +   
      protected File getDeployDir()
      {
         return deployDir;
      }
   
   
  -   protected File getLocalCopy(URL url, String dirName)
  +   protected File getLocalCopy(URL url, DeploymentInfo di)
          throws IOException
      {
  -      if (dirName == null ) 
  -      {
  -         dirName = generateUniqueDirName();     
  -      }
  +      File localDir = getUniqueDir(di);
  +      localDir.mkdirs();
         String name = new File(url.getFile()).getName();//end of file name,no path
          
  -      File copyFile = new File(getDeployDir(), "copy" + dirName + name);
  +      File copyFile = new File(localDir, name);
         InputStream input = url.openStream();
         try
         {
  @@ -498,119 +518,6 @@
         }
         return copyFile;
      }
  -
  -   protected Collection getUrlsInDir(File unpackedDir, FileFilter filter)
  -       throws MalformedURLException
  -   {
  -      Collection jars = new ArrayList();
  -
  -      Collection jarFiles = recursiveFind(unpackedDir, filter);
  -      category.debug("Adding the following URLs to classpath:");
  -      for (Iterator i = jarFiles.iterator(); i.hasNext(); )
  -      {
  -         File file = (File)i.next();
  -         URL jarUrl = file.toURL();
  -         jars.add(jarUrl);
  -         category.debug(jarUrl.toString());
  -      }
  -      return jars;
  -   }
  -
  -    /**
  -     * The <code>recursiveUnpack</code> method unpacks packages
  -     * such as rar, ear, war and then calls itself to unpack
  -     * contained packages.  It returns urls to all packages added to
  -     * the urls collection parameter and urls to all xml files 
  -     * added to the xmls parameter.  It returns a File representing the 
  -     * jar or xml file if that is what was supplied or the directory 
  -     * into which the supplied url was unpacked.
  -     *
  -     * @param url an <code>URL</code> value
  -     * @param urls a <code>Collection</code> value
  -     * @param xmls a <code>Collection</code> value
  -     * @return a <code>File</code> value
  -     * @exception MalformedURLException if an error occurs
  -     * @exception DeploymentException if an error occurs
  -     * @exception IOException if an error occurs
  -     */
  -    protected File recursiveUnpack(URL url, Collection urls, Collection xmls) 
  -       throws MalformedURLException, DeploymentException, IOException
  -  {
  -      //TODO: get xml files out of jars that remain packed.
  -     if (url.getFile().endsWith(".xml")) 
  -     {
  -        xmls.add(url);
  -        return new File(url.getFile());          
  -     }
  -      
  -     if (url.getFile().endsWith(".jar") || url.getFile().endsWith(".sar")) 
  -     {
  -        urls.add(url);
  -        return new File(url.getFile());          
  -     }
  -      
  -     String unpackedDirName = generateUniqueDirName();
  -     File unpackedDir = new File(getDeployDir(), unpackedDirName);
  -     category.debug("unpacking " + url + " into  " + unpackedDir);
  -     inflateJar(url, unpackedDir, null);
  -     FileFilter jarFilter = new FileFilter() 
  -        {
  -            /**
  -             *  #Description of the Method
  -             *
  -             * @param  file  Description of Parameter
  -             * @return       Description of the Returned Value
  -             */
  -           public boolean accept(File file)
  -           {
  -              return !(file.getName().endsWith(".sar") 
  -                 || file.getName().endsWith(".war")
  -                 || file.getName().endsWith(".ear")
  -                 || file.getName().endsWith(".rar"));
  -           }
  -        };
  -     //these go directly into classpath
  -     urls.addAll(getUrlsInDir(unpackedDir, jarFilter));
  -     FileFilter xmlFilter = new FileFilter() 
  -        {
  -            /**
  -             *  #Description of the Method
  -             *
  -             * @param  file  Description of Parameter
  -             * @return       Description of the Returned Value
  -             */
  -           public boolean accept(File file)
  -           {
  -              return file.getName().endsWith(".xml");
  -           }
  -        };
  -     xmls.addAll(getUrlsInDir(unpackedDir, xmlFilter));
  -     //now find what we need to recursively deploy
  -     FileFilter unpackFilter = new FileFilter()
  -        {
  -            /**
  -             *  #Description of the Method
  -             *
  -             * @param  file  Description of Parameter
  -             * @return       Description of the Returned Value
  -             */
  -           public boolean accept(File file)
  -           {
  -              return file.getName().endsWith(".sar") 
  -                 || file.getName().endsWith(".war")
  -                 || file.getName().endsWith(".ear")
  -                 || file.getName().endsWith(".rar");
  -           }
  -        };
  -     Collection deployables = getUrlsInDir(unpackedDir, unpackFilter);
  -     Iterator subdeploy = deployables.iterator();
  -     while (subdeploy.hasNext()) 
  -     {
  -        recursiveUnpack((URL)subdeploy.next(), urls, xmls);         
  -     }
  -     return unpackedDir;
  -   }
  -
      protected ObjectName getServiceControllerName() throws DeploymentException
      {
         if (serviceControllerName == null)
  @@ -629,6 +536,97 @@
   
   
      // Private -------------------------------------------------------
  +   private File getUniqueDir(DeploymentInfo di)
  +   {
  +      File dir = new File(getDeployDir(), generateUniqueDirName() + File.separator);
  +      di.addDir(dir);
  +      return dir;
  +   }
   
      // Inner classes -------------------------------------------------
  +   protected static class DeploymentInfo
  +   {
  +      private URL key;
  +      private List dirs = new ArrayList();
  +      private List classUrls = new ArrayList();
  +      private List xmlUrls = new ArrayList();
  +      private URLClassLoader cl;
  +
  +      public DeploymentInfo(URL key)
  +      {
  +         this.key = key;
  +      }
  +
  +      public void addDir(File dir)
  +      {
  +         dirs.add(dir);
  +      }
  +
  +      public void addClassUrl(URL url)
  +      {
  +         classUrls.add(url);
  +      }
  +
  +      public void addXmlUrl(URL url)
  +      {
  +         xmlUrls.add(url);
  +      }
  +
  +      public List getClassUrls()
  +      {
  +         return classUrls;
  +      }
  +
  +      public List getXmlUrls()
  +      {
  +         return xmlUrls;
  +      }
  +
  +      public URLClassLoader createClassLoader()
  +      {
  +         URL[] urlArray = (URL[])classUrls.toArray(new URL[classUrls.size()]);
  +         cl = new URLClassLoader(urlArray, key);
  +         return cl;
  +      }
  +
  +      public URLClassLoader removeClassLoader()
  +      {
  +         URLClassLoader localcl = cl;
  +         cl = null;
  +         return localcl;
  +      }
  +
  +      public void cleanup(Logger log)
  +      {
  +         classUrls.clear();
  +         xmlUrls.clear();
  +         for (Iterator i = dirs.iterator(); i.hasNext(); ) 
  +         {
  +            File dir = (File)i.next();
  +            if (!recursiveDelete(dir)) 
  +            {
  +               log.info("could not delete directory " + dir + ". Will be removed on 
server shutdown or restart");
  +            } // end of if ()
  +           ;
  +         } // end of for ()
  +         dirs.clear();
  +      }
  +
  +      private boolean recursiveDelete(File f)
  +      {
  +         if (f.isDirectory())
  +         {
  +            File[] files = f.listFiles();
  +            for (int i = 0; i < files.length; ++i)
  +            {
  +               if (!recursiveDelete(files[i]))
  +               {
  +                  return false;
  +               }
  +            }
  +         }
  +         return f.delete();
  +      }
  +
  +   }
   }
  
  
  
  1.14      +72 -103   jboss/src/main/org/jboss/deployment/ServiceDeployer.java
  
  Index: ServiceDeployer.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/ServiceDeployer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ServiceDeployer.java      2001/11/12 06:52:16     1.13
  +++ ServiceDeployer.java      2001/11/19 06:58:56     1.14
  @@ -58,7 +58,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>David Maplesden</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
  - * @version   $Revision: 1.13 $ <p>
  + * @version   $Revision: 1.14 $ <p>
    *
    *      <b>20010830 marc fleury:</b>
    *      <ul>initial import
  @@ -144,11 +144,17 @@
   
   
      /**
  -    * Deploys a package identified by a url string. This undeploys a previous
  -    * version if necessary, checks for a classpath element with codebase and
  -    * archives attributes to locate packages this package depends on, deploys
  -    * them (if not suspended by an undeploy, adds this package to the
  -    * ServiceLibraries classpath, and loads the mbeans specified.
  +    * Deploys a package identified by a url string. This stops if a previous
  +    * version exists. The package can be a *service.xml file, a sar service 
  +    * archive, or a plain jar or zip file with no deployment descriptor.
  +    * In any case, all classes found in the package or sar subpackages are 
  +    * added to the extensible classloader.  If there are classpath elements 
  +    * in the configuration file, the named packages are loaded 
  +    * (in separate classloaders) unless they have been explicitly undeployed, 
  +    * in which case deployment of this package is suspended until they have been
  +    * redeployed.  Then the mbeans named in the configuration file are created 
  +    * using the ServiceController.  Dependencies between mbeans are handled by 
  +    * the ServiceController.
       *
       * @param urlString                  The location of the package to deploy
       * @exception MalformedURLException  Thrown if a malformed url string is
  @@ -191,7 +197,7 @@
                   File jbossHomeDir = new 
File(System.getProperty("jboss.system.home"));
                   File localBaseDir = new File(jbossHomeDir, "db"+File.separator);
                   //Get the url of the local copy from the classloader.
  -                URL localUrl = sdi.classloader.getURLs()[0];
  +                URL localUrl = (URL)sdi.getClassUrls().get(0);
                   log.debug("copying from " + localUrl.toString() + path);
                   log.debug("copying to " + localBaseDir);
   
  @@ -261,45 +267,51 @@
            try 
            {
               log.debug("deploying document " + url);
  -            File localCopy = getLocalCopy(url, null);
  +            File localCopy = getLocalCopy(url, sdi);
               URL localUrl = localCopy.toURL();
               String localName = localCopy.getName();//just the filename, no path
  -            ArrayList jars = new ArrayList();
  -            ArrayList xmls = new ArrayList();
  -            File unpackedDir = recursiveUnpack(localUrl, jars, xmls);
  +            extractPackages(localUrl, sdi);
  +            log.debug("jars from deployment: " + sdi.getClassUrls());
  +            log.debug("xml's from deployment: " + sdi.getXmlUrls());
   
  -
  -            /**
  -             * First register the classloaders for this deployment If it is a jsr, 
the
  -             * jsr points to itself If it is a something-service.xml then it looks 
for
  -             * <classpath><codebase>http://bla.com (or file://bla.com)</codebase>
  -             * default is system library dir <archives>bla.jar, bla2.jar, bla3.jar
  -             * </archives>where bla is relative to codebase</classpath>
  -             */
  -         // Support for the new packaged format
  +            //OK, what are we trying to deploy?
  +            //A plain xml file with mbean classpath elements and mbean config.
               if (localName.endsWith("service.xml"))
               {
  -               sdi.dd = getDocument(localUrl.toString(), null);
  +               sdi.dd = getDocument(localUrl);
                  sdi.state = LOCALCLASSESLOADED;
               }
  +            //a service archive with classes, jars, and META-INF/jboss-service.xml 
  +            //configuration file
               else if (localName.endsWith(".sar"))
               {
  -               URLClassLoader cl = new URLClassLoader(new URL[] {localUrl}, url);
  -               sdi.dd = getDocument("META-INF/jboss-service.xml", cl);
  -               sdi.classloader = cl;
  +               sdi.createClassLoader();
  +            docfound:
  +               {
  +                  for (Iterator i = sdi.getXmlUrls().iterator(); i.hasNext();) 
  +                  {
  +                     URL docUrl = (URL)i.next(); 
  +                     if (docUrl.getFile().endsWith("META-INF/jboss-service.xml")) 
  +                     {
  +                        sdi.dd = getDocument(docUrl);
  +                        break docfound;
  +                     } // end of if ()
  +                  
  +                  } // end of for ()
  +                  throw new DeploymentException("No META-INF/jboss-service.xml 
found in alleged sar!");
  +               }
                  sdi.state = LOCALCLASSESLOADED;
                  log.debug("got document jboss-service.xml from cl");
               }
   
  -            //no mbeans to deploy for jars
  +            //Or maybe its just a jar to be put in the extensible classloader.
               else if(localName.endsWith(".jar")
                      || localName.endsWith(".zip"))
               {
  -               URLClassLoader cl = new URLClassLoader(new URL[] {localUrl}, url);
  -               sdi.classloader = cl;
  +               sdi.createClassLoader();
                  sdi.state = CLASSESLOADED;
               }
  -
  +            //Not for us.
               else
               {
                  throw new Exception("not a deployable file type");
  @@ -314,7 +326,7 @@
   
         } // end of if (EMPTY)
   
  -      //in any case, we may need to add dependency info
  +      //in any case, we may need to add class dependency info
         if ((needsme != null) && !sdi.weSupplyClassesTo.contains(needsme))
         {
            sdi.weSupplyClassesTo.add(needsme);   
  @@ -493,7 +505,7 @@
      public void undeploy(URL url, Object localurlObject)
             throws MalformedURLException, IOException, DeploymentException
      {
  -      log.debug("undeploying document " + url, new Exception("trace"));
  +      log.debug("undeploying document " + url);
   
         SarDeploymentInfo sdi = getSdi(url, false);
         
  @@ -547,9 +559,11 @@
         } // end of while ()
         //Ok, we're done with upwards and downwards dependencies: 
         //we can decide if we're a ghost, and remove our classloader, and maybe 
ourselves.
  -      ServiceLibraries.getLibraries().removeClassLoader(sdi.classloader);
  +      ServiceLibraries.getLibraries().removeClassLoader(sdi.removeClassLoader());
  +      //delete the copied directories if possible.
  +      sdi.cleanup(getLog());
   
  -      sdi.classloader = null;
  +      //sdi.classloader = null;
         if (sdi.weSupplyClassesTo.isEmpty()) 
         {
            //no one is using us, we can disappear without a trace
  @@ -597,98 +611,48 @@
         try
         {
            super.postRegister(registrationDone);
  -         //super.startService();//set up the deploy temp directory
  +         //Start us up, which also sets up the deploy temp directory
            getServer().invoke(getServiceControllerName(),
                               "registerAndStartService",
                               new Object[] {objectName, null},
  -                            new String[] {"javax.management.ObjectName", 
"java.lang.String"});
  -         //Initialize the libraries for the server by default we add the libraries 
in lib/services
  -         // and client
  -         String urlString = 
System.getProperty("jboss.system.configurationDirectory") + "jboss-service.xml";
  -         Document document = null;
  -
  -         try
  -         {
  -            document = getDocument(urlString, null);
  -         }
  -         catch (Exception e)
  -         {
  -            log.error("problem getting jboss-service.xml.", e);
  -            // for legacy reasons try jboss.jcml
  -            urlString = System.getProperty("jboss.system.configurationDirectory") + 
"jboss.jcml";
  -            document = getDocument(urlString, null);
  -
  -         }
  -
  -         deploy(new URL(urlString));
  +                            new String[] {"javax.management.ObjectName", 
  +                                          "java.lang.String"});
         }
         catch (Exception e)
         {
            log.error("Problem postregistering ServiceDeployer", e);
         }
  +         
      }
   
  -   private Document getDocument(String urlString, ClassLoader cl)
  -          throws DeploymentException, MalformedURLException, IOException
  +   protected Document getDocument(URL url)
  +      throws DeploymentException
      {
  -      // Define the input stream to the configuration file
  -      InputStream input = null;
  -
  -      // Try the contextClassLoader
  -      if (cl == null)
  -      {
  -         input = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(urlString);
  -      }
  -      else
  -      {
  -         input = cl.getResourceAsStream(urlString);
  -      }
  -
  -      //If still no document, try to interpret the url as an absolute URL
  -      if (input == null)
  +      try 
         {
  -
  -         // Try to understand the URL litterally
  -         input = (new URL(urlString)).openStream();
  -      }
  -
  -      //Load the configuration with a buffered reader
  -      StringBuffer sbufData = new StringBuffer();
  -      BufferedReader br = new BufferedReader(new InputStreamReader(input));
  -
  -      //String sTmp;
  -      char[] buffer = new char[1024];
  -      int read;
  -      try
  -      {
  -         while ((read = br.read(buffer)) > 0)
  -         {
  -            sbufData.append(buffer, 0, read);
  -         }
  -      }
  -      finally
  -      {
  -         br.close();
  -      }
  -
  -      try
  -      {
  -         // Parse XML
            DocumentBuilder parser = 
DocumentBuilderFactory.newInstance().newDocumentBuilder();
  -
  -         return parser.parse(new InputSource(new 
StringReader(sbufData.toString())));
  +         InputStream stream = url.openStream();
  +         InputSource is = new InputSource(stream);
  +         return parser.parse(is);
         }
         catch (SAXException e)
         {
  +         log.warn("SaxException getting document:", e);
            throw new DeploymentException(e.getMessage());
         }
         catch (ParserConfigurationException pce)
         {
  +         log.warn("ParserConfigurationException getting document:", pce);
            throw new DeploymentException(pce.getMessage());
         }
  -
  +      catch (Exception e) 
  +      {
  +         log.warn("Exception getting document:", e);
  +         throw new DeploymentException(e.getMessage());
  +      } // end of try-catch
      }
   
  +
      // Private --------------------------------------------------------
      private void addMBeans(URL url, SarDeploymentInfo sdi) throws DeploymentException
      {
  @@ -802,7 +766,7 @@
         {
            if (createIfMissing)
            {
  -            sdi = new SarDeploymentInfo();
  +            sdi = new SarDeploymentInfo(url);
               urlToSarDeploymentInfoMap.put(url, sdi);          
            } // end of if ()
            else 
  @@ -821,16 +785,21 @@
      private static final int GHOST = 5; //undeployed but packages are suspended on 
us.
   
   
  -   private static class SarDeploymentInfo
  +   protected static class SarDeploymentInfo extends 
DeployerMBeanSupport.DeploymentInfo
      {
  -      URLClassLoader classloader;
         Collection weNeedClassesFrom = new ArrayList();
         Collection weSupplyClassesTo = new ArrayList();
         List mbeans = new ArrayList();
         Document dd;
         int state = EMPTY;
  +
  +      public SarDeploymentInfo(URL key)
  +      {
  +         super(key);
  +      }
      }
   
   
   }
  +
   
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to