Return-Path: Delivered-To: apmail-jakarta-avalon-cvs-archive@apache.org Received: (qmail 42617 invoked from network); 15 Dec 2001 22:51:38 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 15 Dec 2001 22:51:38 -0000 Received: (qmail 11402 invoked by uid 97); 15 Dec 2001 22:51:44 -0000 Delivered-To: qmlist-jakarta-archive-avalon-cvs@jakarta.apache.org Received: (qmail 11385 invoked by uid 97); 15 Dec 2001 22:51:43 -0000 Mailing-List: contact avalon-cvs-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list avalon-cvs@jakarta.apache.org Received: (qmail 11374 invoked by uid 97); 15 Dec 2001 22:51:43 -0000 Date: 15 Dec 2001 22:51:35 -0000 Message-ID: <20011215225135.84646.qmail@icarus.apache.org> From: donaldp@apache.org To: jakarta-avalon-phoenix-cvs@apache.org Subject: cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends CLIMain.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N donaldp 01/12/15 14:51:35 Modified: src/java/org/apache/avalon/phoenix/launcher Main.java src/java/org/apache/avalon/phoenix/frontends CLIMain.java Log: Converted Main so that it can launch phoenix in a thread that blocks and only returns when Phoenix is completed (if called from command line) or can launch a new thread to montor Phoenix and shutdown it appropriately but the thread will return imediately (when called from DaemonLauncher). Submitted By: Leif Mortenson Revision Changes Path 1.8 +7 -2 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/launcher/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/launcher/Main.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Main.java 2001/12/11 10:13:35 1.7 +++ Main.java 2001/12/15 22:51:34 1.8 @@ -35,6 +35,9 @@ ///The code to return to system using exit code private static int c_exitCode; + ///The code to return to system using exit code + private static boolean c_blocking; + /** * Main entry point for Phoenix. * @@ -44,6 +47,7 @@ public final static void main( final String[] args ) throws Exception { + c_blocking = true; startup( args, new Hashtable() ); System.exit( c_exitCode ); } @@ -75,13 +79,14 @@ //Create main launcher final Class clazz = classLoader.loadClass( MAIN_CLASS ); - final Class[] paramTypes = new Class[] { args.getClass(), Hashtable.class }; + final Class[] paramTypes = + new Class[] { args.getClass(), Hashtable.class, Boolean.TYPE }; final Method method = clazz.getMethod( "main", paramTypes ); c_frontend = clazz.newInstance(); //kick the tires and light the fires.... final Integer integer = - (Integer)method.invoke( c_frontend, new Object[] { args, data } ); + (Integer)method.invoke( c_frontend, new Object[] { args, data, new Boolean( c_blocking ) } ); c_exitCode = integer.intValue(); } catch( final Exception e ) 1.19 +22 -3 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/CLIMain.java Index: CLIMain.java =================================================================== RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/CLIMain.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- CLIMain.java 2001/12/11 10:13:34 1.18 +++ CLIMain.java 2001/12/15 22:51:34 1.19 @@ -25,6 +25,7 @@ * @author Leo Simons */ public final class CLIMain + implements Runnable { private static final Resources REZ = ResourceManager.getPackageResources( CLIMain.class ); @@ -42,7 +43,9 @@ * * @param args[] the command line arguments */ - public int main( final String args[], final Hashtable data ) + public int main( final String args[], + final Hashtable data, + final boolean blocking ) { try { @@ -61,7 +64,7 @@ final Parameters parameters = setup.getParameters(); final String phoenixHome = System.getProperty( "phoenix.home", ".." ); parameters.setParameter( "phoenix.home", phoenixHome ); - execute( parameters, data ); + execute( parameters, data, blocking ); } catch( final Throwable throwable ) { @@ -76,7 +79,9 @@ * * @exception Exception if an error occurs */ - private void execute( final Parameters parameters, final Hashtable data ) + private void execute( final Parameters parameters, + final Hashtable data, + final boolean blocking ) throws Exception { if( false == startup( parameters, data ) ) @@ -91,6 +96,20 @@ Runtime.getRuntime().addShutdownHook( m_hook ); } + if( blocking ) + { + run(); + } + else + { + final Thread thread = new Thread( this, "Phoenix-Monitor" ); + thread.setDaemon( false ); + thread.start(); + } + } + + public void run() + { try { m_embeddor.execute(); -- To unsubscribe, e-mail: For additional commands, e-mail: