KickJava   Java API By Example, From Geeks To Geeks.

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


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/DomainsCmd.java,v 1.3 2005/12/25 03:45:35 tcfujii Exp $
26  * $Revision: 1.3 $
27  * $Date: 2005/12/25 03:45:35 $
28  */

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

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