com.bea.jvm
Class DiagnosticCommand

java.lang.Object
  extended by com.bea.jvm.DiagnosticCommand
All Implemented Interfaces:
Describable

public abstract class DiagnosticCommand
extends java.lang.Object
implements Describable

Support for running internal diagnostic commands in a running JVM. These are typically same commands as found in the attach service.

Author:
calle

Nested Class Summary
 class DiagnosticCommand.Command
          This class wraps a named Command in the JVM Use this Object for repeated invocations of a command, or reflective operations, such as DiagnosticCommand.Parameter introspection
static class DiagnosticCommand.Parameter
          Describes a parameter to a Diagnostic Command
 
Constructor Summary
protected DiagnosticCommand()
           
 
Method Summary
 java.lang.String execute(java.lang.String command)
          Finds and run a command by name, parameterized as "<command> <param1>=<value1> <param2>=<value2>".
 java.lang.String execute(java.lang.String command, java.util.Collection args)
          Finds and run a command by name.
 void execute(java.lang.String command, java.util.Collection args, java.io.OutputStream resultstream)
          Executes a named command with parameters
 java.lang.String execute(java.lang.String command, java.util.Map args)
          Finds and run a command by name.
 void execute(java.lang.String command, java.util.Map args, java.io.OutputStream resultstream)
          Executes a named command with parameters
abstract  void execute(java.lang.String command, java.io.OutputStream resultstream)
          Finds and run a command by name, parameterized as "<command> <param1>=<value1> <param2>=<value2>".
 java.lang.String execute(java.lang.String command, java.lang.String args)
          Finds and run a command by name.
 void execute(java.lang.String command, java.lang.String args, java.io.OutputStream resultstream)
          Executes a named command with parameters
abstract  void executeDefault(java.lang.String command)
          Finds and run a command by name, parameterized as "<command> <param1>=<value1> <param2>=<value2>".
 void executeDefault(java.lang.String command, java.util.Collection args)
          Finds and run a command by name.
 void executeDefault(java.lang.String command, java.util.Map args)
          Finds and run a command by name.
 void executeDefault(java.lang.String command, java.lang.String args)
          Finds and run a command by name.
abstract  java.lang.String[] getAvailableCommandNames()
          Get the names of the available commands in the JVM
 DiagnosticCommand.Command getCommand(java.lang.String name)
          Find a named command
 java.util.Collection getCommands()
          return a Collection of DiagnosticCommand.Command entries representing available commands in the JVM.
protected  java.lang.String getDefaultEncoding()
           
 java.lang.String getDescription()
          Returns a description of the object.
abstract  java.lang.String getDescription(java.lang.String command)
          The description of named Command
static DiagnosticCommand getDiagnosticCommand()
           
abstract  java.util.Collection getParameters(java.lang.String command)
          The named parameters for named Command
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiagnosticCommand

protected DiagnosticCommand()
Method Detail

getDiagnosticCommand

public static DiagnosticCommand getDiagnosticCommand()
Returns:
A Diagnostic provider.

getCommands

public java.util.Collection getCommands()
return a Collection of DiagnosticCommand.Command entries representing available commands in the JVM.

Returns:
Collection of String

getCommand

public DiagnosticCommand.Command getCommand(java.lang.String name)
                                     throws NotAvailableException
Find a named command

Throws:
NotAvailableException

getAvailableCommandNames

public abstract java.lang.String[] getAvailableCommandNames()
Get the names of the available commands in the JVM


execute

public abstract void execute(java.lang.String command,
                             java.io.OutputStream resultstream)
                      throws java.lang.IllegalArgumentException,
                             java.lang.RuntimeException,
                             java.io.IOException
Finds and run a command by name, parameterized as "<command> <param1>=<value1> <param2>=<value2>". The output will be sent to resultStream

Throws:
java.lang.IllegalArgumentException - - on bad options
java.lang.RuntimeException - - if command fails
java.io.IOException

execute

public void execute(java.lang.String command,
                    java.lang.String args,
                    java.io.OutputStream resultstream)
             throws java.lang.IllegalArgumentException,
                    java.lang.RuntimeException,
                    java.io.IOException
Executes a named command with parameters

Parameters:
command - Name of command to run
args - parameters as "<param1>=<value1> <param2>=<value2>" tuples.
resultstream - Where to send output
Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException
java.io.IOException

execute

public void execute(java.lang.String command,
                    java.util.Collection args,
                    java.io.OutputStream resultstream)
             throws java.lang.IllegalArgumentException,
                    java.lang.RuntimeException,
                    java.io.IOException
Executes a named command with parameters

Parameters:
command - Name of command to run
args - parameters as Collection of DiagnosticCommand.Parameter
resultstream - Where to send output
Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException
java.io.IOException

execute

public void execute(java.lang.String command,
                    java.util.Map args,
                    java.io.OutputStream resultstream)
             throws java.lang.IllegalArgumentException,
                    java.lang.RuntimeException,
                    java.io.IOException
Executes a named command with parameters

Parameters:
command - Name of command to run
args - parameters as Map of String,Object tuples
resultstream - Where to send output
Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException
java.io.IOException

executeDefault

public abstract void executeDefault(java.lang.String command)
                             throws java.lang.IllegalArgumentException,
                                    java.lang.RuntimeException
Finds and run a command by name, parameterized as "<command> <param1>=<value1> <param2>=<value2>". The output will be sent to resultStream The output will be sent to whichever is the JVM's default output.

Parameters:
command -
Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException
See Also:
execute(String,String,OutputStream)

executeDefault

public void executeDefault(java.lang.String command,
                           java.lang.String args)
                    throws java.lang.IllegalArgumentException,
                           java.lang.RuntimeException
Finds and run a command by name. The output will be sent to whichever is the JVM's default output.

Parameters:
command - name
args - parameters as "<param1>=<value1> <param2>=<value2>" tuples.
Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException

executeDefault

public void executeDefault(java.lang.String command,
                           java.util.Collection args)
                    throws java.lang.IllegalArgumentException,
                           java.lang.RuntimeException
Finds and run a command by name. The output will be sent to whichever is the JVM's default output.

Parameters:
command - name
args - parameters as Collection of DiagnosticCommand.Parameter
Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException

executeDefault

public void executeDefault(java.lang.String command,
                           java.util.Map args)
                    throws java.lang.IllegalArgumentException,
                           java.lang.RuntimeException
Finds and run a command by name. The output will be sent to whichever is the JVM's default output.

Parameters:
command - name
args - parameters as Map of String,Object tuples
Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException

execute

public java.lang.String execute(java.lang.String command)
                         throws java.lang.IllegalArgumentException,
                                java.lang.RuntimeException
Finds and run a command by name, parameterized as "<command> <param1>=<value1> <param2>=<value2>". Returns the result output as a String

Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException
See Also:
execute(String,String)

execute

public java.lang.String execute(java.lang.String command,
                                java.lang.String args)
                         throws java.lang.IllegalArgumentException,
                                java.lang.RuntimeException
Finds and run a command by name. Returns the result output as a String

Parameters:
command -
args - parameters as "<param1>=<value1> <param2>=<value2>" tuples.
Returns:
Command result
Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException

execute

public java.lang.String execute(java.lang.String command,
                                java.util.Collection args)
                         throws java.lang.IllegalArgumentException,
                                java.lang.RuntimeException
Finds and run a command by name. Returns the result output as a String

Parameters:
command -
args - parameters as Collection of DiagnosticCommand.Parameter
Returns:
Command result as String
Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException

execute

public java.lang.String execute(java.lang.String command,
                                java.util.Map args)
                         throws java.lang.IllegalArgumentException,
                                java.lang.RuntimeException
Finds and run a command by name. Returns the result output as a String

Parameters:
command -
args - parameters as Map of String,Object tuples
Returns:
Command result as String
Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException

getDefaultEncoding

protected java.lang.String getDefaultEncoding()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getDescription

public java.lang.String getDescription()
Returns a description of the object. This description can be more specific than Object.toString().

Specified by:
getDescription in interface Describable
Returns:
the description as a String.

getParameters

public abstract java.util.Collection getParameters(java.lang.String command)
The named parameters for named Command

Returns:
Collections of DiagnosticCommand.Parameter

getDescription

public abstract java.lang.String getDescription(java.lang.String command)
The description of named Command

Returns:
The help text, if available.


Copyright © 1999, 2008, Oracle and/or its affiliates. All rights reserved.