Class AbstractJmxCommand
- java.lang.Object
-
- org.apache.activemq.console.command.AbstractCommand
-
- org.apache.activemq.console.command.AbstractJmxCommand
-
- All Implemented Interfaces:
Command
- Direct Known Subclasses:
BrowseCommand
,DstatCommand
,ListCommand
,PurgeCommand
,QueryCommand
,ShutdownCommand
public abstract class AbstractJmxCommand extends AbstractCommand
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_JMX_URL
-
Fields inherited from class org.apache.activemq.console.command.AbstractCommand
COMMAND_OPTION_DELIMETER, context
-
-
Constructor Summary
Constructors Constructor Description AbstractJmxCommand()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeJmxConnection()
Close the current JMX connectorprotected MBeanServerConnection
createJmxConnection()
void
execute(List<String> tokens)
Execute a generic command, which includes parsing the options for the command and running the specific task.protected String
findJMXUrlByProcessId(int pid)
Finds the JMX Url for a VM by its process idString
getJmxPassword()
Get the password used when authenticatingprotected JMXServiceURL
getJmxServiceUrl()
Get the current specified JMX service url.String
getJmxUser()
Get the JMX user name to be used when authenticating.static String
getJVM()
protected void
handleOption(String token, List<String> tokens)
Handle the --jmxurl option.boolean
isJmxUseLocal()
Get whether the default mbean server for this JVM should be used instead of the jmx urlstatic boolean
isSunJVM()
void
setJmxPassword(String jmxPassword)
Sets the password to use when authenticatingprotected void
setJmxServiceUrl(String jmxServiceUrl)
Sets the JMX service url to use.protected void
setJmxServiceUrl(JMXServiceURL jmxServiceUrl)
Sets the JMX service url to use.void
setJmxUseLocal(boolean jmxUseLocal)
Sets whether the the default mbean server for this JVM should be used instead of the jmx urlvoid
setJmxUser(String jmxUser)
Sets the JMS user name to useprotected JMXServiceURL
useJmxServiceUrl()
Get the current JMX service url being used, or create a default one if no JMX service url has been specified.-
Methods inherited from class org.apache.activemq.console.command.AbstractCommand
handleException, parseOptions, printHelp, printHelpFromFile, runTask, setCommandContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.console.command.Command
getName, getOneLineDescription
-
-
-
-
Field Detail
-
DEFAULT_JMX_URL
public static String DEFAULT_JMX_URL
-
-
Method Detail
-
getJmxServiceUrl
protected JMXServiceURL getJmxServiceUrl()
Get the current specified JMX service url.- Returns:
- JMX service url
-
getJVM
public static String getJVM()
-
isSunJVM
public static boolean isSunJVM()
-
findJMXUrlByProcessId
protected String findJMXUrlByProcessId(int pid)
Finds the JMX Url for a VM by its process id- Parameters:
pid
- The process id value of the VM to search for.- Returns:
- the JMX Url of the VM with the given pid or null if not found.
-
useJmxServiceUrl
protected JMXServiceURL useJmxServiceUrl() throws MalformedURLException
Get the current JMX service url being used, or create a default one if no JMX service url has been specified.- Returns:
- JMX service url
- Throws:
MalformedURLException
-
setJmxServiceUrl
protected void setJmxServiceUrl(JMXServiceURL jmxServiceUrl)
Sets the JMX service url to use.- Parameters:
jmxServiceUrl
- - new JMX service url to use
-
setJmxServiceUrl
protected void setJmxServiceUrl(String jmxServiceUrl) throws MalformedURLException
Sets the JMX service url to use.- Parameters:
jmxServiceUrl
- - new JMX service url to use- Throws:
MalformedURLException
-
getJmxUser
public String getJmxUser()
Get the JMX user name to be used when authenticating.- Returns:
- the JMX user name
-
setJmxUser
public void setJmxUser(String jmxUser)
Sets the JMS user name to use- Parameters:
jmxUser
- - the jmx
-
getJmxPassword
public String getJmxPassword()
Get the password used when authenticating- Returns:
- the password used for JMX authentication
-
setJmxPassword
public void setJmxPassword(String jmxPassword)
Sets the password to use when authenticating- Parameters:
jmxPassword
- - the password used for JMX authentication
-
isJmxUseLocal
public boolean isJmxUseLocal()
Get whether the default mbean server for this JVM should be used instead of the jmx url- Returns:
true
if the mbean server from this JVM should be used,false
if the jmx url should be used
-
setJmxUseLocal
public void setJmxUseLocal(boolean jmxUseLocal)
Sets whether the the default mbean server for this JVM should be used instead of the jmx url- Parameters:
jmxUseLocal
- -true
if the mbean server from this JVM should be used,false
if the jmx url should be used
-
closeJmxConnection
protected void closeJmxConnection()
Close the current JMX connector
-
createJmxConnection
protected MBeanServerConnection createJmxConnection() throws IOException
- Throws:
IOException
-
handleOption
protected void handleOption(String token, List<String> tokens) throws Exception
Handle the --jmxurl option.- Overrides:
handleOption
in classAbstractCommand
- Parameters:
token
- - option token to handletokens
- - succeeding command arguments- Throws:
Exception
-
execute
public void execute(List<String> tokens) throws Exception
Description copied from class:AbstractCommand
Execute a generic command, which includes parsing the options for the command and running the specific task.- Specified by:
execute
in interfaceCommand
- Overrides:
execute
in classAbstractCommand
- Parameters:
tokens
- - command arguments- Throws:
Exception
-
-