Class AbstractBaseCommand

java.lang.Object
org.jolokia.jvmagent.client.command.AbstractBaseCommand
Direct Known Subclasses:
EncryptCommand, HelpCommand, ListCommand, StartCommand, StatusCommand, StopCommand, ToggleCommand, VersionCommand

public abstract class AbstractBaseCommand extends Object
Stateless Base command providing helper functions
Since:
06.10.11
Author:
roland
  • Constructor Details

    • AbstractBaseCommand

      public AbstractBaseCommand()
  • Method Details

    • loadAgent

      protected void loadAgent(Object pVm, VirtualMachineHandlerOperations pHandler, OptionsAndArgs pOpts, String... pAdditionalOpts)
      Execute com.sun.tools.attach.VirtualMachine#loadAgent(String, String)
      Parameters:
      pVm - the VirtualMachine object, typeless
      pHandler - platform-specific way to invoke operations on VM
      pOpts - options from where to extract the agent path and options
      pAdditionalOpts - optional additional options to be appended to the agent options. Must be a CSV string.
    • checkAgentUrl

      protected String checkAgentUrl(Object pVm, VirtualMachineHandlerOperations pHandler)
      Check whether an agent is registered by checking the existance of the system property JvmAgent.JOLOKIA_AGENT_URL. This can be used to check, whether a Jolokia agent has been already attached and started. ("start" will set this property, "stop" will remove it).
      Parameters:
      pVm - the VirtualMachine, but typeless
      pHandler - platform-specific way to invoke operations on VM
      Returns:
      the agent URL if it was set by a previous 'start' command.
    • checkAgentUrl

      protected String checkAgentUrl(Object pVm, VirtualMachineHandlerOperations pHandler, int delayInMs)
      Check whether an agent is registered by checking the existance of the system property JvmAgent.JOLOKIA_AGENT_URL. This can be used to check, whether a Jolokia agent has been already attached and started. ("start" will set this property, "stop" will remove it).
      Parameters:
      pVm - the VirtualMachine, but typeless
      pHandler - platform-specific way to invoke operations on VM
      delayInMs - wait that many ms before fetching the properties
      Returns:
      the agent URL if it was set by a previous 'start' command.
    • getAgentSystemProperties

      protected Properties getAgentSystemProperties(Object pVm, VirtualMachineHandlerOperations pHandler)
      Parameters:
      pVm - the VirtualMachine object, typeless
      pHandler - platform-specific way to invoke operations on VM
      Returns:
      the system properties
    • getProcessDescription

      protected String getProcessDescription(VirtualMachineHandlerOperations pHandler, OptionsAndArgs pOpts)
      Get a description of the process attached, either the numeric id only or, if a pattern is given, the pattern and the associated PID
      Parameters:
      pHandler - handler for looking up the process in case of a pattern lookup
      pOpts - options from where to take the PID or pattern
      Returns:
      a description of the process