tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/java/org/apache/jk/apr TomcatStarter.java
Date Thu, 18 Apr 2002 17:41:51 GMT
costin      02/04/18 10:41:51

  Added:       jk/java/org/apache/jk/apr TomcatStarter.java
  Log:
  Moved the starter hack, cleaned it up.
  
  Added auto-detection of tomcat to simplify the C code and the config.
  
  The only problem is that if you set both TOMCAT_HOME and CATALINA_HOME,
  the jni worker will start both. That's ok if you have different ports
  and mappings :-)
  
  Revision  Changes    Path
  1.1                  jakarta-tomcat-connectors/jk/java/org/apache/jk/apr/TomcatStarter.java
  
  Index: TomcatStarter.java
  ===================================================================
  package org.apache.jk.apr;
  
  import java.io.*;
  import java.lang.reflect.*;
  import java.util.*;
  import org.apache.jk.core.*;
  
  // Hack for Catalina 4.1 who hungs the calling thread.
  // Also avoids delays in apache initialization ( tomcat can take a while )
  
  /** 
   * Start some tomcat.
   * 
   */
  public class TomcatStarter implements Runnable {
      Class c;
      String args[];
      
      public static String mainClasses[]={ "org.apache.tomcat.startup.Main",
                                           "org.apache.catalina.startup.Bootstrap" };
      
      // If someone has time - we can also guess the classpath and do other
      // fancy guessings.
      
      public static void main( String args[] ) {
          System.err.println("TomcatStarter: main()");
          
          try {
              // Find the class
              Class c=null;
              for( int i=0; i<mainClasses.length; i++ ) {
                  try {
                      c=Class.forName( mainClasses[i] );
                  } catch( ClassNotFoundException ex  ) {
                      continue;
                  }
                  if( c!= null ) {
                      Thread startThread=new Thread( new TomcatStarter(c, args));
                      c=null;
                      startThread.start();
                  }
              }
  
          } catch (Throwable t ) {
              t.printStackTrace(System.err);
          }
      }
  
      public TomcatStarter( Class c, String args[] ) {
          this.c=c;
          this.args=args;
      }
      
      public void run() {
          System.err.println("Starting " + c.getName());
          try {
              Class argClass=args.getClass();
              Method m=c.getMethod( "main", new Class[] {argClass} );
              m.invoke( c, new Object[] { args } );
          } catch( Throwable t ) {
              t.printStackTrace(System.err);
          }
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message