270 }
271
272 }
273
274 public HotSpot24DiagnosticCommandService(MBeanServerConnection server) throws ServiceNotAvailableException {
275 m_mbeanServer = server;
276 try {
277 refreshOperations();
278 } catch (Exception e) {
279 throw new ServiceNotAvailableException("Unable to retrieve diagnostic commands!"); //$NON-NLS-1$
280 }
281 }
282
283 @Override
284 public synchronized Collection<DiagnosticCommand> getOperations() throws Exception {
285 refreshOperations();
286 return operations;
287 }
288
289 private void refreshOperations() throws Exception {
290 RJMXPlugin.getDefault().getLogger().finer("Refreshing diagnostic operations");
291 MBeanInfo info = m_mbeanServer.getMBeanInfo(DIAGNOSTIC_BEAN);
292 operations = new ArrayList<>(info.getOperations().length);
293 commandNameToOperation.clear();
294 for (MBeanOperationInfo oper : info.getOperations()) {
295 if (!oper.getName().equals(OPERATION_UPDATE)) {
296 Descriptor descriptor = oper.getDescriptor();
297 DiagnosticCommand c = new DiagnosticCommand(descriptor, oper.getReturnType());
298 operations.add(c);
299 commandNameToOperation.put(c.getName(), oper.getName());
300 }
301 }
302 }
303
304 @Override
305 public String runCtrlBreakHandlerWithResult(String command) throws Exception {
306 int index = command.indexOf(' ');
307 if (index > 0) {
308 String operationName = command.substring(0, index);
309 return findDiagnosticCommand(operationName).execute(splitArguments(command.substring(index + 1).trim()));
310 } else {
|
270 }
271
272 }
273
274 public HotSpot24DiagnosticCommandService(MBeanServerConnection server) throws ServiceNotAvailableException {
275 m_mbeanServer = server;
276 try {
277 refreshOperations();
278 } catch (Exception e) {
279 throw new ServiceNotAvailableException("Unable to retrieve diagnostic commands!"); //$NON-NLS-1$
280 }
281 }
282
283 @Override
284 public synchronized Collection<DiagnosticCommand> getOperations() throws Exception {
285 refreshOperations();
286 return operations;
287 }
288
289 private void refreshOperations() throws Exception {
290 RJMXPlugin.getDefault().getLogger().finer("Refreshing diagnostic operations"); //$NON-NLS-1$
291 MBeanInfo info = m_mbeanServer.getMBeanInfo(DIAGNOSTIC_BEAN);
292 operations = new ArrayList<>(info.getOperations().length);
293 commandNameToOperation.clear();
294 for (MBeanOperationInfo oper : info.getOperations()) {
295 if (!oper.getName().equals(OPERATION_UPDATE)) {
296 Descriptor descriptor = oper.getDescriptor();
297 DiagnosticCommand c = new DiagnosticCommand(descriptor, oper.getReturnType());
298 operations.add(c);
299 commandNameToOperation.put(c.getName(), oper.getName());
300 }
301 }
302 }
303
304 @Override
305 public String runCtrlBreakHandlerWithResult(String command) throws Exception {
306 int index = command.indexOf(' ');
307 if (index > 0) {
308 String operationName = command.substring(0, index);
309 return findDiagnosticCommand(operationName).execute(splitArguments(command.substring(index + 1).trim()));
310 } else {
|