User: sylvain 
  Date: 00/06/19 20:31:59

  Modified:    src/main/org/jboss/tomcat TomcatService.java
  Log:
  implemented the MBean which launches Tomcat
  
  Revision  Changes    Path
  1.2       +26 -24    jboss/src/main/org/jboss/tomcat/TomcatService.java
  
  Index: TomcatService.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/tomcat/TomcatService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TomcatService.java        2000/04/22 14:30:13     1.1
  +++ TomcatService.java        2000/06/20 03:31:59     1.2
  @@ -12,11 +12,10 @@
   import java.io.IOException;
   import java.io.File;
   import java.net.URL;
  +import java.lang.reflect.Method;
   
   import javax.management.*;
   
  -import org.apache.tomcat.startup.Tomcat;
  -
   import org.jboss.logging.Log;
   import org.jboss.util.ServiceMBeanSupport;
   
  @@ -25,7 +24,7 @@
    *      
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   public class TomcatService
      extends ServiceMBeanSupport
  @@ -34,7 +33,7 @@
      // Constants -----------------------------------------------------
       
      // Attributes ----------------------------------------------------
  -   Tomcat server;
  +   //Tomcat server;
   //   Process proc;
      Thread runner;
      
  @@ -67,28 +66,31 @@
            {
               try
               {
  -               Tomcat.main(new String[0]);
  -               log.log("Tomcat done");
  -               
  -/*               proc = Runtime.getRuntime().exec("java -classpath 
../lib/ext/hsql.jar org.hsql.Server");
  +               Class tomcatClass;
                  
  -               DataInputStream din = new DataInputStream(proc.getInputStream());
  -               String line;
  -               while((line = din.readLine()) != null)
  +               System.out.println("Testing if Tomcat is present....");
  +               try{
  +                   tomcatClass = Class.forName("org.apache.tomcat.startup.Tomcat");
  +                   System.out.println("OK");
  +               }catch(Exception e)
                  {
  -                  // Notify that something happened
  -                  synchronized(runner)
  -                  {
  -                     runner.notifyAll();
  -                  }
  -                  
  -                  if (!line.equals("Press [Ctrl]+[C] to abort"))
  -                     log.log(line);
  -               }
  -                  
  -               runner = null;
  -               proc = null;
  -*/               
  +                    System.out.println("failed");
  +                    System.out.println("Tomcat wasn't found. Be sure to have your 
CLASSPATH correctly set");
  +                    //e.printStackTrace();
  +                    return;
  +               } 
  +               
  +               Class tomcatArgsClasses[] = new Class[1];
  +               String args[] = new String[0];
  +               tomcatArgsClasses[0] = args.getClass();
  +               Method mainMethod = tomcatClass.getMethod("main", tomcatArgsClasses);
  +               
  +               Object tomcatArgs[] = new Object[1];
  +               tomcatArgs[0] = args;
  +               
  +               System.out.println("Starting Tomcat...");
  +               mainMethod.invoke(null,tomcatArgs); 
  +               
               } catch (Exception e)
               {
                  log.error("Tomcat failed");
  
  
  

Reply via email to