KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > instrument > client > Main


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package org.apache.excalibur.instrument.client;
21
22 import java.io.File JavaDoc;
23
24 import org.apache.avalon.framework.logger.ConsoleLogger;
25
26 /**
27  *
28  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
29  * @version CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:23 $
30  * @since 4.1
31  */

32 public class Main
33 {
34     /*---------------------------------------------------------------
35      * Methods
36      *-------------------------------------------------------------*/

37     private static void showUsage()
38     {
39         System.out.println( "Usage:");
40         System.out.println( "java -classpath {classpath} org.apache.excalibur.instrument.client.Main [-debug] [state file]" );
41         System.out.println();
42         System.out.println( " -debug - Enables debug output." );
43         System.out.println( " state file - Name of a state file to read at startup. Defaults to: ../conf/default.desktop" );
44         System.out.println();
45     }
46     
47     
48     /*---------------------------------------------------------------
49      * Main Method
50      *-------------------------------------------------------------*/

51     /**
52      * Main method used to lauch an InstrumentClient application.
53      */

54     public static void main( String JavaDoc args[] )
55     {
56         // Parse the command line. Want to replace this with something more powerful later.
57
boolean debug = false;
58         String JavaDoc defaultStateFileName = "../conf/default.desktop";
59         switch( args.length )
60         {
61         case 0:
62             break;
63             
64         case 1:
65             if ( args[0].equalsIgnoreCase( "-debug" ) )
66             {
67                 debug = true;
68             }
69             else
70             {
71                 defaultStateFileName = args[0];
72             }
73             break;
74             
75         case 2:
76             if ( args[0].equalsIgnoreCase( "-debug" ) )
77             {
78                 debug = true;
79             }
80             else
81             {
82                 showUsage();
83                 System.exit( 1 );
84             }
85             defaultStateFileName = args[1];
86             break;
87             
88         default:
89             showUsage();
90             System.exit( 1 );
91         }
92         
93         File JavaDoc defaultStateFile = new File JavaDoc( defaultStateFileName );
94         
95         InstrumentClientFrame client = new InstrumentClientFrame( "Instrument Client" );
96         int logLevel = ( debug ? ConsoleLogger.LEVEL_DEBUG : ConsoleLogger.LEVEL_INFO );
97         client.enableLogging( new ConsoleLogger( logLevel ) );
98         client.initialize();
99         client.setDefaultStateFile( defaultStateFile );
100         client.show();
101     }
102 }
103
104
Popular Tags