KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > cli > jmx > cmd > CountCmd


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /*
25  * $Header: /cvs/glassfish/admin-cli/cli-api/src/java/com/sun/cli/jmx/cmd/CountCmd.java,v 1.3 2005/12/25 03:45:33 tcfujii Exp $
26  * $Revision: 1.3 $
27  * $Date: 2005/12/25 03:45:33 $
28  */

29  
30 package com.sun.cli.jmx.cmd;
31
32 import com.sun.cli.jmx.support.CLISupportMBeanProxy;
33
34 /*
35     Invokes the 'list' commmand on all specified targets
36  */

37 public class CountCmd extends JMXCmd
38 {
39         public
40     CountCmd( final CmdEnv env )
41     {
42         super( env );
43     }
44
45         int
46     getNumRequiredOperands()
47     {
48         return( 0 );
49     }
50     
51         public String JavaDoc
52     getUsage()
53     {
54         return( CmdStrings.COUNT_HELP.toString() );
55     }
56     
57     static private final String JavaDoc OPTIONS_INFO ="";
58     
59         ArgHelper.OptionsInfo
60     getOptionInfo()
61         throws ArgHelper.IllegalOptionException
62     {
63         return( new ArgHelperOptionsInfo( OPTIONS_INFO ) );
64     }
65     
66     final static String JavaDoc NAME = "count";
67     
68         public static String JavaDoc []
69     getNames( )
70     {
71         return( new String JavaDoc [] { NAME } );
72     }
73     
74         void
75     executeInternal()
76         throws Exception JavaDoc
77     {
78         final String JavaDoc [] operands = getOperands();
79         
80         if ( operands.length != 0 )
81         {
82             final String JavaDoc msg = "No arguments required";
83             printError( msg );
84             throw new IllegalArgumentException JavaDoc( msg );
85         }
86         
87         try
88         {
89             establishProxy();
90             final int numMBeans = getProxy().mbeanCount();
91             println( "" + numMBeans );
92         }
93         catch( Exception JavaDoc e )
94         {
95             dm( e.getMessage() );
96             e.printStackTrace();
97         }
98     }
99 }
100
101
102
103
104
105
106
Popular Tags