1 16 17 package org.apache.jk.apr; 18 19 import java.lang.reflect.Method ; 20 21 24 28 public class TomcatStarter implements Runnable { 29 Class c; 30 String args[]; 31 AprImpl apr = new AprImpl(); 32 33 public static String mainClasses[]={ "org.apache.tomcat.startup.Main", 34 "org.apache.catalina.startup.BootstrapService", 35 "org.apache.catalina.startup.Bootstrap"}; 36 37 40 public static void main( String args[] ) { 41 System.err.println("TomcatStarter: main()"); 42 int nClasses = 0; 43 44 try { 45 AprImpl.jniMode(); 46 Class c=null; 48 for( int i=0; i<mainClasses.length; i++ ) { 49 try { 50 System.err.println("Try " + mainClasses[i]); 51 c=Class.forName( mainClasses[i] ); 52 } catch( ClassNotFoundException ex ) { 53 continue; 54 } 55 if( c!= null ) { 56 ++nClasses; 57 Thread startThread=new Thread ( new TomcatStarter(c, args)); 58 c=null; 59 startThread.start(); 60 break; 61 } 62 } 63 if (nClasses==0) 64 System.err.println("No class found "); 65 66 } catch (Throwable t ) { 67 t.printStackTrace(System.err); 68 } 69 } 70 71 public TomcatStarter( Class c, String args[] ) { 72 this.c=c; 73 this.args=args; 74 } 75 76 public void run() { 77 System.err.println("Starting " + c.getName()); 78 try { 79 Class argClass=args.getClass(); 80 Method m=c.getMethod( "main", new Class [] {argClass} ); 81 m.invoke( c, new Object [] { args } ); 82 System.out.println("TomcatStarter: Done"); 83 if (apr.isLoaded()) 84 apr.jkSetAttribute(0, 0, "channel:jni", "done"); 85 if (args[0].equals("stop")) { 86 Thread.sleep(5000); 87 Runtime.getRuntime().exit(0); 88 } 89 } catch( Throwable t ) { 90 t.printStackTrace(System.err); 91 } 92 } 93 } 94 | Popular Tags |