FileDocCategorySizeDatePackage
TomcatStarter.javaAPI DocApache Tomcat 6.0.143360Fri Jul 20 04:20:32 BST 2007org.apache.jk.apr

TomcatStarter

public class TomcatStarter extends Object implements Runnable
Start some tomcat.

Fields Summary
Class
c
String[]
args
AprImpl
apr
public static String[]
mainClasses
Constructors Summary
public TomcatStarter(Class c, String[] args)

        this.c=c;
        this.args=args;
    
Methods Summary
public static voidmain(java.lang.String[] args)


    // If someone has time - we can also guess the classpath and do other
    // fancy guessings.
    
           
        System.err.println("TomcatStarter: main()");
        int nClasses = 0;
        
        try {
            AprImpl.jniMode();            
            // Find the class
            Class c=null;
            for( int i=0; i<mainClasses.length; i++ ) {
                try {
                    System.err.println("Try  " + mainClasses[i]);
                    c=Class.forName( mainClasses[i] );
                } catch( ClassNotFoundException ex  ) {
                    continue;
                }
                if( c!= null ) {
                    ++nClasses;
                    Thread startThread=new Thread( new TomcatStarter(c, args));
                    c=null;
                    startThread.start();
                    break;
                }
            }
            if (nClasses==0)
                System.err.println("No class found  ");

        } catch (Throwable t ) {
            t.printStackTrace(System.err);
        }
    
public voidrun()

        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 } );
            System.out.println("TomcatStarter: Done");
            if (apr.isLoaded())
                apr.jkSetAttribute(0, 0, "channel:jni", "done");
            if (args[0].equals("stop")) {
                  Thread.sleep(5000);
                  Runtime.getRuntime().exit(0);
            }
        } catch( Throwable t ) {
            t.printStackTrace(System.err);
        }