User: mnf999  
  Date: 02/02/01 18:00:44

  Modified:    tomcat/src/main/org/jboss/tomcat EmbeddedTomcatService.java
                        EmbeddedTomcatServiceSX.java
  Log:
  Registration
  
  Revision  Changes    Path
  1.12      +76 -67    
contrib/tomcat/src/main/org/jboss/tomcat/EmbeddedTomcatService.java
  
  Index: EmbeddedTomcatService.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/tomcat/src/main/org/jboss/tomcat/EmbeddedTomcatService.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- EmbeddedTomcatService.java        2001/02/20 15:29:20     1.11
  +++ EmbeddedTomcatService.java        2002/02/02 02:00:44     1.12
  @@ -1,9 +1,9 @@
   /*
  - * JBoss, the OpenSource EJB server
  - *
  - * Distributable under LGPL license.
  - * See terms of license at gnu.org.
  - */
  +* JBoss, the OpenSource EJB server
  +*
  +* Distributable under LGPL license.
  +* See terms of license at gnu.org.
  +*/
   
   package org.jboss.tomcat;
   
  @@ -29,82 +29,91 @@
   import org.jboss.ejb.DeploymentException;
   
   /**
  - *   <description>
  - *
  - *   @see <related>
  - *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @author Dewayne McNair ([EMAIL PROTECTED])
  - *   @version $Revision: 1.11 $
  - */
  +*   <description>
  +*
  +*   @see <related>
  +*   @author Rickard �berg ([EMAIL PROTECTED])
  +*   @author Dewayne McNair ([EMAIL PROTECTED])
  +*   @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
  +*   @version $Revision: 1.12 $
  +*/
   
   public class EmbeddedTomcatService
   extends ServiceMBeanSupport
   implements EmbeddedTomcatServiceMBean, MBeanRegistration
   {
  -    // Constants -----------------------------------------------------
  -    public static final String NAME = "EmbeddedTomcat";
  -
  -    TomcatEntry tomcat = null;
  -
  -    // repository for deployed URLs and the associated servletContexts
  -    Hashtable deployedURLs = new Hashtable();
  -
  -    public ObjectName getObjectName (MBeanServer server, ObjectName name)
  -    throws javax.management.MalformedObjectNameException
  -    {
  -        return new ObjectName(OBJECT_NAME);
  -    }
  -
  -    public String getName()
  -    {
  -        return NAME;
  -    }
  -
  -    public void startService()
  -    throws Exception
  -    {
  -        final Log log = this.log;
  -
  -        log.log ("Starting " + NAME + "....");
  -        tomcat = new TomcatEntry();
  -        log.log ("OK");
  -    }
  -
  -    public void stopService()
  -    {
  -        if (tomcat != null)
  -        {
  -            try
  -            {
  -                tomcat.stopTomcat();
  -            }
  -            catch (Exception e)
  -            {
  -                // nothing -- we're shutting down
  -            }
  -        }
  +   // Constants -----------------------------------------------------
  +   public static final String NAME = "EmbeddedTomcat";
  +   
  +   TomcatEntry tomcat = null;
  +   
  +   // repository for deployed URLs and the associated servletContexts
  +   Hashtable deployedURLs = new Hashtable();
  +   
  +   public ObjectName getObjectName (MBeanServer server, ObjectName name)
  +   throws javax.management.MalformedObjectNameException
  +   {
  +      return new ObjectName(OBJECT_NAME);
      }
  -
  +   
  +   public String getName()
  +   {
  +      return NAME;
  +   }
  +   
  +   public void startService()
  +   throws Exception
  +   {
  +    
  +      final Log log = this.log;
  +      
  +      log.log ("Starting " + NAME + "....");
  +      tomcat = new TomcatEntry();
  +      
  +      //Register with the Main Deployer
  +      super.startService();
  +      
  +      log.log ("OK");
  +   }
  +   
  +   public void stopService()
  +   {
  +      if (tomcat != null)
  +      {
  +         
  +         try
  +         {
  +            super.stopService();
  +            
  +            tomcat.stopTomcat();
  +         }
  +         catch (Exception e)
  +         {
  +            // nothing -- we're shutting down
  +         }
  +      }
  +   }
  +   
      // warURL could be given as a java.net.URL,
      // but the JMX RI's html adaptor can't
      // show inputs for URLs in HTML forms.
      public void deploy(String ctxPath, String warUrl)
      throws DeploymentException
      {
  -        final Log log = this.log;
  -
  +      final Log log = this.log;
  +      
         ClassLoader oldCcl = Thread.currentThread().getContextClassLoader();
         try
         {
            // add the context
            ServletContext servletCtx = tomcat.addContext(ctxPath, new URL(warUrl));
  -
  +         
            // init the context
            tomcat.initContext(servletCtx);
  -
  +         
            // keep track of deployed contexts for undeployment
            deployedURLs.put(warUrl, servletCtx);
  -
  +      
         } catch(Error e)
         {
            e.printStackTrace();
  @@ -118,22 +127,22 @@
            Thread.currentThread().setContextClassLoader(oldCcl);
         }
      }
  -
  +   
      public void undeploy(String warUrl) throws DeploymentException
      {
  -        final Log log = this.log;
  -
  +      final Log log = this.log;
  +      
         try
         {
            // find the javax.servlet.ServletContext in the repository
            ServletContext servletCtx = (ServletContext)deployedURLs.get(warUrl);
  -
  +         
            if(servletCtx == null)
               throw new DeploymentException("URL " + warUrl + " is not deployed");
  -
  +         
            // remove the context
            tomcat.removeContext(servletCtx);
  -
  +      
         } catch(Exception e)
         {
            throw new DeploymentException(e.getMessage());
  @@ -141,7 +150,7 @@
         {
         }
      }
  -
  +   
      public boolean isDeployed(String warUrl)
      {
         return deployedURLs.containsKey(warUrl);
  
  
  
  1.5       +8 -1      
contrib/tomcat/src/main/org/jboss/tomcat/EmbeddedTomcatServiceSX.java
  
  Index: EmbeddedTomcatServiceSX.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/tomcat/src/main/org/jboss/tomcat/EmbeddedTomcatServiceSX.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EmbeddedTomcatServiceSX.java      2002/01/05 07:53:43     1.4
  +++ EmbeddedTomcatServiceSX.java      2002/02/02 02:00:44     1.5
  @@ -44,7 +44,9 @@
   @see org.jboss.web.AbstractWebContainer
   
   @author [EMAIL PROTECTED]
  -@version $Revision: 1.4 $
  +@author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
  +
  +@version $Revision: 1.5 $
   */
   public class EmbeddedTomcatServiceSX extends AbstractWebContainer
       implements EmbeddedTomcatServiceSXMBean
  @@ -71,6 +73,7 @@
   
       public void startService() throws Exception
       {
  +        
           String baseName = AbstractWebContainer.category.getName();
           category = Category.getInstance(baseName+"."+NAME);
           category.info("Starting " + NAME + "....");
  @@ -89,6 +92,8 @@
           try
           {
              tomcat = new TomcatEntry(args);
  +        
  +            super.startService();
           }
           finally
           {
  @@ -103,6 +108,8 @@
           {
               try
               {
  +               super.stopService();
  +               
                   tomcat.stopTomcat();
               }
               catch(Exception e)
  
  
  

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

Reply via email to