1 23 24 29 30 package com.sun.cli.jmx.cmd; 31 32 33 import com.sun.cli.jmx.support.InspectRequest; 34 import com.sun.cli.jmx.support.InspectResult; 35 import com.sun.cli.jmx.support.CLISupportMBeanProxy; 36 import com.sun.cli.util.stringifier.*; 37 38 public class InspectCmd extends JMXCmd 39 { 40 public 41 InspectCmd( final CmdEnv env ) 42 { 43 super( env ); 44 45 mStringifier = new SmartStringifier( "\n\n", false ); 46 } 47 48 public String 49 getUsage() 50 { 51 return( CmdStrings.INSPECT_HELP.toString() ); 52 } 53 54 int 55 getNumRequiredOperands() 56 { 57 return( 0 ); 59 } 60 61 62 static private final String OPTIONS_INFO = 63 "all summary constructors attributes,1 operations,1 notifications,1 nodescription"; 64 65 66 ArgHelper.OptionsInfo 67 getOptionInfo() 68 throws ArgHelper.IllegalOptionException 69 { 70 return( new ArgHelperOptionsInfo( OPTIONS_INFO ) ); 71 } 72 73 74 void 75 handle_inspect( String [] targets, final InspectRequest request) 76 throws Exception 77 { 78 final InspectResult [] results = getProxy().mbeanInspect( request, targets ); 79 80 if ( results.length == 0 ) 81 { 82 println( "<nothing inspected>" ); 83 } 84 else 85 { 86 final String msg = ArrayStringifier.stringify( results, "\n\n"); 87 println( msg ); 88 } 89 } 90 91 void 92 handle_inspect( final String [] targets ) 93 throws Exception 94 { 95 final InspectRequest request = new InspectRequest( true ); 96 97 request.includeDescription = ! getBoolean( "noDescription", Boolean.TRUE ).booleanValue(); 98 99 if ( getBoolean( "all", Boolean.FALSE ).booleanValue() ) 100 { 101 } 103 else 104 { 105 request.includeSummary = getBoolean( "summary", Boolean.TRUE ).booleanValue(); 106 request.constructors = getBoolean( "constructors", Boolean.FALSE ).booleanValue(); 107 108 request.attrs = getString( "attributes", null ); 109 request.operations = getString( "operations", null ); 110 request.notifications = getString( "notifications", null ); 111 } 112 113 handle_inspect( targets, request ); 114 } 115 116 void 117 handle_ops( final String [] targets ) 118 throws Exception 119 { 120 final InspectRequest request = new InspectRequest( false ); 121 request.operations = "*"; 122 123 handle_inspect( targets, request ); 124 } 125 126 void 127 handle_attrs( final String [] targets ) 128 throws Exception 129 { 130 final InspectRequest request = new InspectRequest( false ); 131 request.attrs = "*"; 132 133 handle_inspect( targets, request ); 134 } 135 136 137 public static String [] 138 getNames( ) 139 { 140 return( new String [] { "inspect", "i", "ops", "attrs" } ); 141 } 142 143 void 144 executeInternal() 145 throws Exception 146 { 147 final String cmd = getCmdNameAsInvoked(); 148 final String [] targets = getTargets(); 149 150 if ( targets == null ) 151 { 152 printError( "No targets have been specified" ); 153 return; 154 } 155 156 establishProxy(); 157 if ( cmd.equalsIgnoreCase( "inspect" ) ) 158 { 159 handle_inspect( targets ); 160 } 161 else if ( cmd.equalsIgnoreCase( "ops" ) ) 162 { 163 handle_ops( targets ); 164 } 165 else if ( cmd.equalsIgnoreCase( "attrs" ) ) 166 { 167 handle_attrs( targets ); 168 } 169 } 170 } 171 172 | Popular Tags |