User: d_jencks
  Date: 02/02/21 20:24:55

  Modified:    src/main/org/jboss/deployment DeployerMBean.java
                        DeploymentInfo.java EARDeployer.java
                        MainDeployer.java MainDeployerMBean.java
                        SARDeployer.java
  Log:
  Made classes visible across all subpackages in a deployment such as an ear. (bug 
520676. Restructured deployment process to involve 3 phases: classloading, create 
where components set up their externally visible aspects, and start where components 
connect to other components. Renamed Application to EjbModule.
  
  Revision  Changes    Path
  1.8       +45 -37    jboss/src/main/org/jboss/deployment/DeployerMBean.java
  
  Index: DeployerMBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/DeployerMBean.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DeployerMBean.java        20 Jan 2002 14:36:30 -0000      1.7
  +++ DeployerMBean.java        22 Feb 2002 04:24:55 -0000      1.8
  @@ -21,7 +21,7 @@
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Toby Allsopp</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
  -* @version $Revision: 1.7 $
  +* @version $Revision: 1.8 $
   *
   *   <p><b>20011225 marc fleury:</b>
   *      <ul>
  @@ -33,55 +33,63 @@
   extends ServiceMBean
   {
      /**
  -   * Provides a filter that decides whether a file can be deployed by
  -   * this deployer based on the filename.  This is for the benefit of
  -   * the {@link org.jboss.deployer.AutoDeployer} service.
  -   *
  -   * @return a <tt>FilenameFilter</tt> that only
  -   *         <tt>accept</tt>s files with names that can be
  -   *         deployed by this deployer
  -   */
  -   public boolean accepts(DeploymentInfo sdi);
  +    * The <code>accepts</code> method is called by MainDeployer to 
  +    * determine which deployer is suitable for a DeploymentInfo.
  +    *
  +    * @param sdi a <code>DeploymentInfo</code> value
  +    * @return a <code>boolean</code> value
  +    */
  +   boolean accepts(DeploymentInfo sdi);
      
      
      
  -   /*
  -   * Init a deployment 
  -   *
  -   * parse the XML MetaData.  Init and deploy are separate steps allowing for 
subDeployment
  -   * in between.  
  -   *
  -   * @param url    The URL to deploy.
  -   *
  -   * @throws MalformedURLException    Invalid URL
  -   * @throws IOException              Failed to fetch content
  -   * @throws DeploymentException      Failed to deploy
  -   */
  -   public void init(DeploymentInfo sdi)
  +   /**
  +    * The <code>init</code> method lets the deployer set a few properties
  +    * of the DeploymentInfo, such as the watch url.
  +    *
  +    * @param sdi a <code>DeploymentInfo</code> value
  +    * @exception DeploymentException if an error occurs
  +    */
  +   void init(DeploymentInfo sdi)
      throws DeploymentException;
      
      
      /**
  -   * Deploy a given URL.
  +   * Set up the components of the deployment that do not 
  +   * refer to other components
      *
  -   * @param url    The URL to deploy.
      *
  -   * @throws MalformedURLException    Invalid URL
  -   * @throws IOException              Failed to fetch content
  +    * @param sdi a <code>DeploymentInfo</code> value
      * @throws DeploymentException      Failed to deploy
      */
  -   public void deploy(DeploymentInfo sdi)
  +   void create(DeploymentInfo sdi)
      throws DeploymentException;
      
      /**
  -   * Undeploy a given URL.
  -   *
  -   * @param url    The URL to undeploy.
  -   *
  -   * @throws MalformedURLException    Invalid URL
  -   * @throws IOException              Failed to fetch content
  -   * @throws DeploymentException      Failed to undeploy
  -   */
  -   public void undeploy(DeploymentInfo sdi)
  +    * The <code>start</code> method sets up relationships with other components.
  +    *
  +    * @param sdi a <code>DeploymentInfo</code> value
  +    * @exception DeploymentException if an error occurs
  +    */
  +   void start(DeploymentInfo sdi)
  +   throws DeploymentException;
  +   
  +   /**
  +    * The <code>stop</code> method removes relationships between components.
  +    *
  +    * @param sdi a <code>DeploymentInfo</code> value
  +    * @exception DeploymentException if an error occurs
  +    */
  +   void stop(DeploymentInfo sdi)
  +   throws DeploymentException;
  +
  +
  +   /**
  +    * The <code>destroy</code> method removes individual components
  +    *
  +    * @param sdi a <code>DeploymentInfo</code> value
  +    * @exception DeploymentException if an error occurs
  +    */
  +   void destroy(DeploymentInfo sdi)
      throws DeploymentException;
   }
  
  
  
  1.10      +27 -18    jboss/src/main/org/jboss/deployment/DeploymentInfo.java
  
  Index: DeploymentInfo.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/DeploymentInfo.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DeploymentInfo.java       20 Feb 2002 06:40:38 -0000      1.9
  +++ DeploymentInfo.java       22 Feb 2002 04:24:55 -0000      1.10
  @@ -6,34 +6,35 @@
   */
   package org.jboss.deployment;
   
  -import java.net.URL;
  -import java.net.URLClassLoader;
  +
  +
   import java.io.File;
   import java.io.FileInputStream;
  +import java.net.URL;
  +import java.net.URLClassLoader;
   import java.util.ArrayList;
  -import java.util.Set;
  -import java.util.HashSet;
   import java.util.Collection;
  +import java.util.Date;
   import java.util.HashMap;
  +import java.util.HashSet;
   import java.util.Iterator;
  -import java.util.List;
   import java.util.Iterator;
  +import java.util.List;
  +import java.util.Set;
   import java.util.Vector;
  -import java.util.Date;
   import java.util.jar.JarFile;
   import java.util.jar.Manifest;
  -
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -import org.w3c.dom.Document;
  -import javax.xml.parsers.DocumentBuilderFactory;
  +import javax.management.ObjectName;
   import javax.xml.parsers.DocumentBuilder;
  -
  -import org.jboss.system.UnifiedClassLoader;
  -import org.jboss.system.ServiceLibraries;
  +import javax.xml.parsers.DocumentBuilderFactory;
   import org.jboss.logging.Logger;
   import org.jboss.metadata.ApplicationMetaData;
   import org.jboss.metadata.BeanMetaData;
  +import org.jboss.system.ServiceLibraries;
  +import org.jboss.system.UnifiedClassLoader;
  +import org.w3c.dom.Document;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
   
   /**
   * Service Deployment Info .
  @@ -48,7 +49,7 @@
   * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Schulze</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Christoph G. Jung</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Scott Stark</a>
  -* @version   $Revision: 1.9 $ <p>
  +* @version   $Revision: 1.10 $ <p>
   *
   *      <b>20011211 marc fleury:</b>
   *      <ul>
  @@ -96,13 +97,13 @@
      public ClassLoader localCl;
      
      /** The classpath declared by this xml descriptor, needs <classpath> entry **/
  -   public Collection classpath = new ArrayList();
  +   final public Collection classpath = new ArrayList();
      
      // The mbeans deployed
  -   public List mbeans = new ArrayList();
  +   final public List mbeans = new ArrayList();
      
      // Anyone can have subdeployments
  -   public Set subDeployments = new HashSet();
  +   final public Set subDeployments = new HashSet();
      
      // And the subDeployments have a parent
      public DeploymentInfo parent = null;
  @@ -124,6 +125,14 @@
      
      public boolean isXML;
      public boolean isDirectory;
  +
  +   /**
  +    * The variable <code>deployedObject</code> can contain the MBean that
  +    * is created through the deployment.  for instance, deploying an ejb-jar
  +    * results in an EjbModule mbean, which is stored here.
  +    *
  +    */
  +   public ObjectName deployedObject;
      
      public DeploymentInfo(URL url, DeploymentInfo parent)
      throws DeploymentException
  
  
  
  1.7       +33 -15    jboss/src/main/org/jboss/deployment/EARDeployer.java
  
  Index: EARDeployer.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/EARDeployer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EARDeployer.java  13 Feb 2002 06:00:37 -0000      1.6
  +++ EARDeployer.java  22 Feb 2002 04:24:55 -0000      1.7
  @@ -49,7 +49,7 @@
   /**
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
  -* @version $Revision: 1.6 $
  +* @version $Revision: 1.7 $
   */
   public class EARDeployer
   extends ServiceMBeanSupport
  @@ -127,7 +127,8 @@
         }
         catch (Exception e)
         {
  -         throw new DeploymentException("Error in accessing application metadata: 
"+e.getMessage());
  +         log.error("Error in init step of ear deployment", e);
  +         throw new DeploymentException("Error in accessing application metadata: ", 
e);
         }
         
         // Create the appropriate JSR-77 instance
  @@ -142,25 +143,42 @@
      }
      
      
  -   public void deploy(DeploymentInfo di)
  -   throws DeploymentException
  +   public void create(DeploymentInfo di)
  +      throws DeploymentException
      {
         // now try to deploy
  -      if (log.isInfoEnabled())
  -        log.info("Deploying J2EE application: " + di.url);
  +      log.info("Deploying J2EE application, create step: " + di.url);
  +      // Create the appropriate JSR-77 instance
  +//      /*  
  +      ObjectName lApplication = J2EEApplication.create(
  +         server,
  +         di.shortName,
  +         di.url
  +         // di.getApplicationDeploymentDescriptor()
  +      );
  +//      */
      }
      
  +   public void start(DeploymentInfo di)
  +      throws DeploymentException
  +   {
  +      log.info("Deploying J2EE application, start step, a no-op: " + di.url);
  +   }
  +   
  +   public void stop(DeploymentInfo di) throws DeploymentException
  +   {
  +      log.info("Undeploying J2EE application, stop step, a no-op: " + di.url);
  +   }
      
  -   /** Undeploys the given URL (if it is deployed).
  -   *   Actually only the file name is of interest, so it dont has to be
  -   *   an URL to be undeployed, the file name is ok as well.
  -   *   @param _url the url to to undeploy
  -   *   @throws MalformedURLException in case of a malformed url
  -   *   @throws J2eeDeploymentException if something went wrong (but should have 
removed all files)
  -   *   @throws IOException if file removement fails
  -   */
  -   public void undeploy(DeploymentInfo di) throws DeploymentException
  +   /**
  +    * Describe <code>destroy</code> method here.
  +    *
  +    * @param di a <code>DeploymentInfo</code> value
  +    * @exception DeploymentException if an error occurs
  +    */
  +   public void destroy(DeploymentInfo di) throws DeploymentException
      {
  +      log.info("Undeploying J2EE application, destroy step: " + di.url);
   //      /*
         // Destroy the appropriate JSR-77 instance
         J2EEApplication.destroy(
  
  
  
  1.21      +162 -43   jboss/src/main/org/jboss/deployment/MainDeployer.java
  
  Index: MainDeployer.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/MainDeployer.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- MainDeployer.java 21 Feb 2002 08:41:08 -0000      1.20
  +++ MainDeployer.java 22 Feb 2002 04:24:55 -0000      1.21
  @@ -46,7 +46,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Scott Stark</a>
  - * @version $Revision: 1.20 $
  + * @version $Revision: 1.21 $
    */
   public class MainDeployer
      extends ServiceMBeanSupport
  @@ -170,6 +170,11 @@
      {
         deployers.remove(deployer); 
      }
  +
  +   public Collection listDeployers()
  +   {
  +      return new ArrayList(deployers);
  +   }
      
      
      // ServiceMBeanSupport overrides ---------------------------------
  @@ -323,7 +328,12 @@
      public void undeploy(DeploymentInfo di)
      {
         log.info("Undeploying "+di.url);
  +      stop(di);
  +      destroy(di);
  +   }
   
  +   private void stop(DeploymentInfo di)
  +   {
         // First remove all sub-deployments
         for (Iterator subs = di.subDeployments.iterator(); subs.hasNext();)
         {
  @@ -333,7 +343,7 @@
            {
               log.debug("UNDEPLOYMENT OF SUB "+sub.url);
            }
  -         undeploy(sub);      
  +         stop(sub);      
         }
   
         // Then remove the deployment itself
  @@ -342,7 +352,40 @@
            // Tell the respective deployer to undeploy this one
            if (di.deployer != null)
            {
  -            di.deployer.undeploy(di); 
  +            di.deployer.stop(di); 
  +         }
  +      }
  +      catch (Exception e)
  +      {
  +         log.error("Undeployment failed: " + di.url, e); 
  +      }
  +      catch (Throwable t)
  +      {
  +         log.error("Undeployment failed: " + di.url, t); 
  +      }
  +   }
  +
  +   private void destroy(DeploymentInfo di)
  +   {
  +      // First remove all sub-deployments
  +      for (Iterator subs = di.subDeployments.iterator(); subs.hasNext();)
  +      {
  +         DeploymentInfo sub = (DeploymentInfo) subs.next();
  +         
  +         if (log.isDebugEnabled())
  +         {
  +            log.debug("UNDEPLOYMENT OF SUB "+sub.url);
  +         }
  +         destroy(sub);      
  +      }
  +
  +      // Then remove the deployment itself
  +      try 
  +      { 
  +         // Tell the respective deployer to undeploy this one
  +         if (di.deployer != null)
  +         {
  +            di.deployer.destroy(di); 
            }
         }
         catch (Exception e)
  @@ -422,19 +465,32 @@
      public void deploy(DeploymentInfo deployment) 
         throws DeploymentException
      {      
  -      boolean debug = log.isDebugEnabled();
  -
  -      try
  +      // If we are already deployed return
  +      if (isDeployed(deployment.url))
         {
  -         // If we are already deployed return
  -         if (isDeployed(deployment.url))
  -         {
  -            return;
  -         }
  +         return;
  +      }
   
  -         if (log.isInfoEnabled());
  -           log.info("Deploying: " + deployment.url.toString());
  +      log.info("Deploying: " + deployment.url.toString());
  +      init(deployment);
  +      create(deployment);
  +      start(deployment);
  +   }
  +   
   
  +   /**
  +    * The <code>init</code> method is to copy the code if necessary, 
  +    * set up classloaders, and identify the deployer for the package.
  +    *
  +    * @param deployment a <code>DeploymentInfo</code> value
  +    * @exception DeploymentException if an error occurs
  +    */
  +   private void init(DeploymentInfo deployment) throws DeploymentException
  +   {
  +      log.debug("init on deployment " + deployment.url);
  +      try 
  +      {
  +      
            // Create a local copy of that File, the sdi keeps track of the copy 
directory
            makeLocalCopy(deployment);
            
  @@ -448,26 +504,63 @@
            {
               deployment.deployer.init(deployment); 
            }
  +         else
  +         {
  +            log.info("No deployer for package: " + deployment.url);
  +         } // end of else
  +         
   
            // create subdeployments as needed
  -         deploySubPackages(deployment);
  -         
  +         unpackSubPackages(deployment);
  +         log.debug("found " + deployment.subDeployments.size() + " subpackages of " 
+ deployment.url);
  +         for (Iterator lt = 
sortDeployments(deployment.subDeployments).listIterator(); lt.hasNext();) 
  +         { 
  +            init((DeploymentInfo) lt.next());
  +         }
  +
  +      }
  +      catch (Exception e)
  +      {
  +         throw new DeploymentException("exception in init of " + deployment.url, e);
  +      } // end of try-catch
  +   }
  +
  +   /**
  +    * The <code>create</code> method should set up all information not 
  +    * requiring other components.  for instance, the ejb Container is created,
  +    * and the proxy bound into jndi.
  +    *
  +    * @param deployment a <code>DeploymentInfo</code> value
  +    * @exception DeploymentException if an error occurs
  +    */
  +   private void create(DeploymentInfo deployment) throws DeploymentException
  +   {
  +      log.debug("create on deployment " + deployment.url);
  +      try 
  +      {
  +         for (Iterator lt = 
sortDeployments(deployment.subDeployments).listIterator(); lt.hasNext();) 
  +         { 
  +            create((DeploymentInfo) lt.next());
  +         }
  +
            // Deploy this SDI, if it is a deployable type
            if (deployment.deployer != null)
            {
  -            deployment.deployer.deploy(deployment);
  +            deployment.deployer.create(deployment);
            }
   
  -         deployment.status="Deployed";
  +         deployment.status="Created";
   
  -         if (debug)
  +         if (log.isDebugEnabled())
  +         {
               log.debug("Done deploying " + deployment.shortName);
  +         }
         }  
         catch (Throwable t) 
         { 
  -         log.error("could not deploy :" + deployment.url, t);
  +         log.error("could not create deployment :" + deployment.url, t);
            deployment.status = "Deployment FAILED reason: " + t.getMessage();         
  -         throw new DeploymentException("Could not deploy: " + deployment.url, t);
  +         throw new DeploymentException("Could not create deployment: " + 
deployment.url, t);
         }
         finally 
         {
  @@ -483,15 +576,52 @@
               if (!deployment.url.toString().startsWith(tempDirString)) 
               {
                  deploymentsList.add(deployment);
  -               if (debug)
  -               {
  -                  log.debug("Watching new file: " + deployment.url);  
  -               }
  +               log.debug("Watching new file: " + deployment.url);  
               }
            }
         }
      }
   
  +   /**
  +    * The <code>start</code> method sets up relationships between components.
  +    * for instance, ejb links are set up here.
  +    *
  +    * @param deployment a <code>DeploymentInfo</code> value
  +    * @exception DeploymentException if an error occurs
  +    */
  +   private void start(DeploymentInfo deployment) throws DeploymentException
  +   {
  +      log.debug("start on deployment " + deployment.url);
  +      try 
  +      {
  +         for (Iterator lt = 
sortDeployments(deployment.subDeployments).listIterator(); lt.hasNext();) 
  +         { 
  +            start((DeploymentInfo) lt.next());
  +         }
  +
  +
  +         // Deploy this SDI, if it is a deployable type
  +         if (deployment.deployer != null)
  +         {
  +            deployment.deployer.start(deployment);
  +         }
  +
  +         deployment.status="Deployed";
  +
  +         if (log.isDebugEnabled())
  +         {
  +            log.debug("Done deploying " + deployment.shortName);
  +         }
  +      }  
  +      catch (Throwable t) 
  +      { 
  +         log.error("could not start deployment :" + deployment.url, t);
  +         deployment.status = "Deployment FAILED reason: " + t.getMessage();         
  +         throw new DeploymentException("Could not create deployment: " + 
deployment.url, t);
  +      }
  +
  +   }
  +
   
      public void findDeployer(DeploymentInfo sdi) 
      {
  @@ -683,7 +813,7 @@
       * In case of identifiable sub-deployment we recursively call the deploy method 
       * on the deployer
       */
  -   protected void deploySubPackages(DeploymentInfo di)
  +   protected void unpackSubPackages(DeploymentInfo di)
         throws DeploymentException
      {
         // If XML only no subdeployment to speak of. We also do not
  @@ -700,7 +830,6 @@
         JarFile jarFile =null;
         
         // Then the packages inside the package being deployed
  -      HashSet subDeployments = new HashSet();
         
         // marcf FIXME FIXME FIXME add support for directories not just jar files
         
  @@ -764,7 +893,7 @@
                  DeploymentInfo sub = new DeploymentInfo(subURL, di);
                  
                  // And deploy it, this call is recursive
  -               subDeployments.add(sub);
  +               di.subDeployments.add(sub);
               }
               catch (Exception ex) 
               { 
  @@ -784,20 +913,8 @@
            // We should encapsulate "opening and closing of the jarFile" in the 
DeploymentInfo
            // Here we let it be open and cached
         }
  -      
  -      // Order the deployments
  -      for (Iterator lt = sortDeployments(subDeployments).listIterator(); 
lt.hasNext();) 
  -      { 
  -         try
  -         { 
  -            deploy((DeploymentInfo) lt.next());
  -         }
  -         catch (DeploymentException e)
  -         {
  -            di.subDeployments.remove(di);
  -         }
  -      }
      }
  +
      
      public void parseManifestLibraries(DeploymentInfo sdi) throws DeploymentException
      {
  @@ -969,11 +1086,12 @@
      
      public ArrayList sortDeployments(Set urls)
      {
  +      //sort a copy, so we don't kill the original!
         ArrayList list = new ArrayList(urls.size());
  -      
  +      Set copy = new HashSet(urls);
         for (int i = 0 ; i < order.length ; i++)
         {
  -         for (Iterator it = urls.iterator(); it.hasNext();) 
  +         for (Iterator it = copy.iterator(); it.hasNext();) 
            {
               DeploymentInfo di = (DeploymentInfo) it.next();
               
  @@ -985,7 +1103,7 @@
         }
         
         // Unknown types deployed at the end
  -      list.addAll(urls);
  +      list.addAll(copy);
         if (log.isTraceEnabled()) 
         {
            log.trace("about to do something with: " + list);
  @@ -1022,3 +1140,4 @@
      
      private synchronized int getNextID() { return id++;}
   }
  +
  
  
  
  1.8       +3 -1      jboss/src/main/org/jboss/deployment/MainDeployerMBean.java
  
  Index: MainDeployerMBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/MainDeployerMBean.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MainDeployerMBean.java    15 Feb 2002 06:18:30 -0000      1.7
  +++ MainDeployerMBean.java    22 Feb 2002 04:24:55 -0000      1.8
  @@ -26,7 +26,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Toby Allsopp</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    *      <p><b>20011223 marc fleury:</b>
    *      <ul> 
    *      <li>add/RemoveURL, added the capacity to dynamically add a URL to watch
  @@ -65,6 +65,8 @@
      
      /** get all the watched URLs in this deployment **/
      Collection listDeployed();
  +
  +   Collection listDeployers();
      
      /** Get set scan-period**/
      void setScan( boolean scan);
  
  
  
  1.14      +51 -36    jboss/src/main/org/jboss/deployment/SARDeployer.java
  
  Index: SARDeployer.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/SARDeployer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SARDeployer.java  15 Feb 2002 06:18:30 -0000      1.13
  +++ SARDeployer.java  22 Feb 2002 04:24:55 -0000      1.14
  @@ -67,7 +67,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>David Maplesden</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
  - * @version $Revision: 1.13 $
  + * @version $Revision: 1.14 $
    *
    * <p><b>20010830 marc fleury:</b>
    * <ul>
  @@ -203,17 +203,14 @@
         }
      }
   
  -   public void deploy(DeploymentInfo di)
  +   public void create(DeploymentInfo di)
         throws DeploymentException
      {
  -      boolean debug = log.isDebugEnabled();
  -
         try
         {
            // install the MBeans in this descriptor
  -         if (debug) {
  -            log.debug("Deploying SAR: url " + di.url);
  -      }
  +         log.debug("Deploying SAR, create step: url " + di.url);
  +
            
            List mbeans = di.mbeans;
            mbeans.clear();
  @@ -234,24 +231,38 @@
               }
            }
            
  -      Iterator iter;
  -      ObjectName service;
   
            // create the services
  -         iter = di.mbeans.iterator();
  -         while (iter.hasNext()) 
  +         for (Iterator iter = di.mbeans.iterator(); iter.hasNext(); ) 
            {
  -            service = (ObjectName)iter.next();
  +            ObjectName service = (ObjectName)iter.next();
               
               // The service won't be created until explicitely dependent mbeans are 
created
            serviceController.create(service);
            }
  -         
  +      }
  +      catch (Exception e) {
  +      log.error("operation failed", e);
  +      throw new DeploymentException(e);
  +      }
  +   }
  +
  +   /**
  +    * The <code>start</code> method starts all the mbeans in this DeploymentInfo..
  +    *
  +    * @param di a <code>DeploymentInfo</code> value
  +    * @exception DeploymentException if an error occurs
  +    */
  +   public void start(DeploymentInfo di) throws DeploymentException
  +   {
  +      log.debug("Deploying SAR, start step: url " + di.url);
  +      try 
  +      {
            // start the services
  -         iter = di.mbeans.iterator();
  -         while (iter.hasNext()) 
  +         
  +         for (Iterator iter = di.mbeans.iterator(); iter.hasNext(); ) 
            {
  -            service = (ObjectName)iter.next();
  +            ObjectName service = (ObjectName)iter.next();
               
               // The service won't be started until explicitely dependent mbeans are 
started
            serviceController.start(service);
  @@ -495,23 +506,15 @@
       * we undeployed so that they can be redeployed should this one be
       * redeployed.
       *
  -    * @param urlString    The location of the package to be
  -    *                     undeployed (used to index the packages, not to read 
  -    *                     service.xml on undeploy!
       *
  -    * @exception MalformedURLException  Thrown if the url string is not valid.
  -    * @exception IOException            Thrown if something could not be read.
  +    * @param service the <code>DeploymentInfo</code> value to stop.
       * @exception DeploymentException    Thrown if the package could not be
       *                                   undeployed
       */
  -   public void undeploy(DeploymentInfo sdi)
  +   public void stop(DeploymentInfo sdi)
         throws DeploymentException
      {
  -      boolean debug = log.isDebugEnabled();
  -
  -      if (debug) {
  -         log.debug("undeploying document " + sdi.url);
  -      }
  +      log.debug("undeploying document " + sdi.url);
         
         List services = sdi.mbeans;
         int lastService = services.size();
  @@ -521,27 +524,39 @@
         for (ListIterator i = services.listIterator(lastService); i.hasPrevious();)
         {
            ObjectName name = (ObjectName)i.previous();
  -            if (debug) {
  -               log.debug("stopping mbean " + name);
  -            }
  +            log.debug("stopping mbean " + name);
            serviceController.stop(name);
         }
  +      }
  +      catch (Exception e) {
  +      throw new DeploymentException(e);
  +      }
  +   }
   
  +   /**
  +    * Describe <code>destroy</code> method here.
  +    *
  +    * @param service a <code>DeploymentInfo</code> value
  +    * @exception DeploymentException if an error occurs
  +    */
  +   public void destroy(DeploymentInfo sdi) throws DeploymentException
  +   {
  +      List services = sdi.mbeans;
  +      int lastService = services.size();
  +
  +      try 
  +      {
         for (ListIterator i = services.listIterator(lastService); i.hasPrevious();)
            {
            ObjectName name = (ObjectName)i.previous();
  -            if (debug) {
  -               log.debug("destroying mbean " + name);
  -            }
  +            log.debug("destroying mbean " + name);
            serviceController.destroy(name);
         }
   
         for (ListIterator i = services.listIterator(lastService); i.hasPrevious();)
            {
            ObjectName name = (ObjectName)i.previous();
  -            if (debug) {
  -               log.debug("removing mbean " + name);
  -            }
  +            log.debug("removing mbean " + name);
            serviceController.remove(name);
         }
         }
  
  
  

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

Reply via email to