Interface VirtualMachineHandlerOperations


public interface VirtualMachineHandlerOperations

A contract for dealing with VirtualMachine on any JDK where Attach API is supported.

The virtual machine is passed as Object and dealt with differently in chosen implementation of the contract.

Since:
24.06.2021
Author:
ggrzybek
  • Method Details

    • attachVirtualMachine

      Object attachVirtualMachine() throws ProcessingException
      Lookup and create a com.sun.tools.attach.VirtualMachine
      Returns:
      the virtual machine of null if none could be created
      Throws:
      ProcessingException - for any problem related to VM attaching. Specific to particular implementation.
    • detachAgent

      void detachAgent(Object pVm) throws ProcessingException
      Detach from the virtual machine
      Parameters:
      pVm - the virtual machine to detach from
      Throws:
      ProcessingException - for any problem related to VM detaching. Specific to particular implementation.
    • listProcesses

      List<ProcessDescription> listProcesses()
      Return a list of all Java processes
      Returns:
      list of java processes
    • findProcess

      ProcessDescription findProcess(Pattern pPattern)
      Filter the process list for a regular expression and returns the description. The process this JVM is running in is ignored. If more than one process or no process is found, an exception is raised.
      Parameters:
      pPattern - regular expression to match
      Returns:
      a process description of the one process found but never null
      Throws:
      IllegalArgumentException - if more than one or no process has been found.
    • loadAgent

      void loadAgent(Object pVm, String jarFilePath, String args)
      Loads Jolokia agent into the attached VM.
      Parameters:
      pVm - VirtualMachine access object
      jarFilePath - path to Java agent JAR file
      args - arguments to VirtualMachine.loadAgent(String, String) method
    • getSystemProperties

      Properties getSystemProperties(Object pVm)
      Returns system properties from attached VM.
      Parameters:
      pVm - VirtualMachine access object
      Returns:
      system properties of the remote VM