avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client InstrumentManagerConnection.java Main.java
Date Tue, 05 Nov 2002 02:59:05 GMT
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:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message