120 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));
121 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStatusDCmd>(jmx_agent_export_flags, true,false));
122
123 }
124
125 #ifndef HAVE_EXTRA_DCMD
126 void DCmdRegistrant::register_dcmds_ext(){
127 // Do nothing here
128 }
129 #endif
130
131
132 HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
133 _all("-all", "Show help for all commands", "BOOLEAN", false, "false"),
134 _cmd("command name", "The name of the command for which we want help",
135 "STRING", false) {
136 _dcmdparser.add_dcmd_option(&_all);
137 _dcmdparser.add_dcmd_argument(&_cmd);
138 };
139
140 void HelpDCmd::execute(DCmdSource source, TRAPS) {
141 if (_all.value()) {
142 GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list(source);
143 for (int i = 0; i < cmd_list->length(); i++) {
144 DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
145 strlen(cmd_list->at(i)));
146 output()->print_cr("%s%s", factory->name(),
147 factory->is_enabled() ? "" : " [disabled]");
148 output()->print_cr("\t%s", factory->description());
149 output()->cr();
150 factory = factory->next();
151 }
152 } else if (_cmd.has_value()) {
153 DCmd* cmd = NULL;
154 DCmdFactory* factory = DCmdFactory::factory(source, _cmd.value(),
155 strlen(_cmd.value()));
156 if (factory != NULL) {
157 output()->print_cr("%s%s", factory->name(),
158 factory->is_enabled() ? "" : " [disabled]");
159 output()->print_cr("%s", factory->description());
160 output()->print_cr("\nImpact: %s", factory->impact());
161 JavaPermission p = factory->permission();
162 if(p._class != NULL) {
163 if(p._action != NULL) {
164 output()->print_cr("\nPermission: %s(%s, %s)",
165 p._class, p._name == NULL ? "null" : p._name, p._action);
166 } else {
167 output()->print_cr("\nPermission: %s(%s)",
168 p._class, p._name == NULL ? "null" : p._name);
169 }
170 }
171 output()->cr();
172 cmd = factory->create_resource_instance(output());
173 if (cmd != NULL) {
174 DCmdMark mark(cmd);
175 cmd->print_help(factory->name());
176 }
177 } else {
178 output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value());
179 }
180 } else {
181 output()->print_cr("The following commands are available:");
182 GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list(source);
183 for (int i = 0; i < cmd_list->length(); i++) {
184 DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
185 strlen(cmd_list->at(i)));
186 output()->print_cr("%s%s", factory->name(),
187 factory->is_enabled() ? "" : " [disabled]");
188 factory = factory->_next;
189 }
190 output()->print_cr("\nFor more information about a specific command use 'help <command>'.");
191 }
192 }
193
194 int HelpDCmd::num_arguments() {
195 ResourceMark rm;
196 HelpDCmd* dcmd = new HelpDCmd(NULL, false);
197 if (dcmd != NULL) {
198 DCmdMark mark(dcmd);
199 return dcmd->_dcmdparser.num_arguments();
200 } else {
201 return 0;
202 }
|
120 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));
121 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStatusDCmd>(jmx_agent_export_flags, true,false));
122
123 }
124
125 #ifndef HAVE_EXTRA_DCMD
126 void DCmdRegistrant::register_dcmds_ext(){
127 // Do nothing here
128 }
129 #endif
130
131
132 HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
133 _all("-all", "Show help for all commands", "BOOLEAN", false, "false"),
134 _cmd("command name", "The name of the command for which we want help",
135 "STRING", false) {
136 _dcmdparser.add_dcmd_option(&_all);
137 _dcmdparser.add_dcmd_argument(&_cmd);
138 };
139
140
141 static int compare_strings(const char** s1, const char** s2) {
142 return ::strcmp(*s1, *s2);
143 }
144
145 void HelpDCmd::execute(DCmdSource source, TRAPS) {
146 if (_all.value()) {
147 GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list(source);
148 cmd_list->sort(compare_strings);
149 for (int i = 0; i < cmd_list->length(); i++) {
150 DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
151 strlen(cmd_list->at(i)));
152 output()->print_cr("%s%s", factory->name(),
153 factory->is_enabled() ? "" : " [disabled]");
154 output()->print_cr("\t%s", factory->description());
155 output()->cr();
156 factory = factory->next();
157 }
158 } else if (_cmd.has_value()) {
159 DCmd* cmd = NULL;
160 DCmdFactory* factory = DCmdFactory::factory(source, _cmd.value(),
161 strlen(_cmd.value()));
162 if (factory != NULL) {
163 output()->print_cr("%s%s", factory->name(),
164 factory->is_enabled() ? "" : " [disabled]");
165 output()->print_cr("%s", factory->description());
166 output()->print_cr("\nImpact: %s", factory->impact());
167 JavaPermission p = factory->permission();
168 if(p._class != NULL) {
169 if(p._action != NULL) {
170 output()->print_cr("\nPermission: %s(%s, %s)",
171 p._class, p._name == NULL ? "null" : p._name, p._action);
172 } else {
173 output()->print_cr("\nPermission: %s(%s)",
174 p._class, p._name == NULL ? "null" : p._name);
175 }
176 }
177 output()->cr();
178 cmd = factory->create_resource_instance(output());
179 if (cmd != NULL) {
180 DCmdMark mark(cmd);
181 cmd->print_help(factory->name());
182 }
183 } else {
184 output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value());
185 }
186 } else {
187 output()->print_cr("The following commands are available:");
188 GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list(source);
189 cmd_list->sort(compare_strings);
190 for (int i = 0; i < cmd_list->length(); i++) {
191 DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
192 strlen(cmd_list->at(i)));
193 output()->print_cr("%s%s", factory->name(),
194 factory->is_enabled() ? "" : " [disabled]");
195 factory = factory->_next;
196 }
197 output()->print_cr("\nFor more information about a specific command use 'help <command>'.");
198 }
199 }
200
201 int HelpDCmd::num_arguments() {
202 ResourceMark rm;
203 HelpDCmd* dcmd = new HelpDCmd(NULL, false);
204 if (dcmd != NULL) {
205 DCmdMark mark(dcmd);
206 return dcmd->_dcmdparser.num_arguments();
207 } else {
208 return 0;
209 }
|