Return-Path: Delivered-To: apmail-jakarta-avalon-cvs-archive@apache.org Received: (qmail 27937 invoked from network); 5 Nov 2002 02:59:18 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 5 Nov 2002 02:59:18 -0000 Received: (qmail 11888 invoked by uid 97); 5 Nov 2002 03:00:18 -0000 Delivered-To: qmlist-jakarta-archive-avalon-cvs@jakarta.apache.org Received: (qmail 11820 invoked by uid 97); 5 Nov 2002 03:00:17 -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 11767 invoked by uid 97); 5 Nov 2002 03:00:15 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 5 Nov 2002 02:59:05 -0000 Message-ID: <20021105025905.87411.qmail@icarus.apache.org> From: leif@apache.org To: jakarta-avalon-excalibur-cvs@apache.org Subject: cvs commit: jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client InstrumentManagerConnection.java Main.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 leif 2002/11/04 18:59:04 Modified: instrument-client/src/java/org/apache/excalibur/instrument/client InstrumentManagerConnection.java Main.java Log: Improve the output in debug mode. Also make it possible to enable debugging from the command line. Revision Changes Path 1.9 +25 -3 jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client/InstrumentManagerConnection.java Index: InstrumentManagerConnection.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client/InstrumentManagerConnection.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- InstrumentManagerConnection.java 26 Oct 2002 08:52:25 -0000 1.8 +++ InstrumentManagerConnection.java 5 Nov 2002 02:59:04 -0000 1.9 @@ -40,6 +40,7 @@ import org.apache.excalibur.altrmi.client.impl.DefaultConnectionListener; import org.apache.excalibur.altrmi.common.AltrmiConnectionException; import org.apache.excalibur.altrmi.common.AltrmiInvocationException; +import org.apache.excalibur.altrmi.common.ConnectionRefusedException; import org.apache.excalibur.instrument.manager.interfaces.InstrumentableDescriptor; import org.apache.excalibur.instrument.manager.interfaces.InstrumentDescriptor; @@ -356,7 +357,10 @@ void open() throws AltrmiConnectionException, IOException { - getLogger().debug( "open()" ); + if ( getLogger().isDebugEnabled() ) + { + getLogger().debug( "Attempt to open a new connection to " + m_host + ":" + m_port ); + } SocketCustomStreamHostContext altrmiHostContext = new SocketCustomStreamHostContext( m_host, m_port ); @@ -366,7 +370,11 @@ m_altrmiFactory = new ClientClassAltrmiFactory( false ); m_altrmiFactory.setHostContext( altrmiHostContext ); - getLogger().debug("Listing Published Altrmi Objects At Server..."); + if ( getLogger().isDebugEnabled() ) + { + getLogger().debug("Connected. Listing Published Altrmi Objects At Server..."); + } + String[] listOfPublishedObjectsOnServer = m_altrmiFactory.list(); for ( int i = 0; i < listOfPublishedObjectsOnServer.length; i++ ) { @@ -395,11 +403,25 @@ { open(); } + catch ( ConnectionRefusedException e ) + { + getLogger().debug( "Connection refused. Server not running?" ); + } catch ( AltrmiConnectionException e ) { + if ( getLogger().isDebugEnabled() ) + { + getLogger().debug( + "Unable to open connection. Got an unexpected Altrmi exception.", e ); + } } catch ( IOException e ) { + if ( getLogger().isDebugEnabled() ) + { + getLogger().debug( + "Unable to open connection. Got an unexpected IO exception.", e ); + } } } 1.4 +47 -8 jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client/Main.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Main.java 23 Aug 2002 09:47:43 -0000 1.3 +++ Main.java 5 Nov 2002 02:59:04 -0000 1.4 @@ -22,6 +22,16 @@ /*--------------------------------------------------------------- * Methods *-------------------------------------------------------------*/ + private static void showUsage() + { + System.out.println( "Usage:"); + System.out.println( "java -classpath {classpath} org.apache.excalibur.instrument.client.Main [-debug] [state file]" ); + System.out.println(); + System.out.println( " -debug - Enables debug output." ); + System.out.println( " state file - Name of a state file to read at startup. Defaults to: ../conf/default.desktop" ); + System.out.println(); + } + /*--------------------------------------------------------------- * Main Method @@ -31,19 +41,48 @@ */ public static void main( String args[] ) { - String defaultStateFileName; - if ( args.length > 0 ) + // Parse the command line. Want to replace this with something more powerful later. + boolean debug = false; + String defaultStateFileName = "../conf/default.desktop"; + switch( args.length ) { + case 0: + break; + + case 1: + if ( args[0].equalsIgnoreCase( "-debug" ) ) + { + debug = true; + } + else + { + defaultStateFileName = args[0]; + } + break; + + case 2: + if ( args[0].equalsIgnoreCase( "-debug" ) ) + { + debug = true; + } + else + { + showUsage(); + System.exit( 1 ); + } defaultStateFileName = args[0]; + break; + + default: + showUsage(); + System.exit( 1 ); } - else - { - defaultStateFileName = "../conf/default.desktop"; - } + File defaultStateFile = new File( defaultStateFileName ); InstrumentClientFrame client = new InstrumentClientFrame( "Instrument Client" ); - client.enableLogging( new ConsoleLogger( ConsoleLogger.LEVEL_INFO ) ); + int logLevel = ( debug ? ConsoleLogger.LEVEL_DEBUG : ConsoleLogger.LEVEL_INFO ); + client.enableLogging( new ConsoleLogger( logLevel ) ); client.setDefaultStateFile( defaultStateFile ); client.show(); } -- To unsubscribe, e-mail: For additional commands, e-mail: