Package org.jrd.backend.communication
Class InstallDecompilerAgentImpl
- java.lang.Object
-
- org.jrd.backend.communication.InstallDecompilerAgentImpl
-
public class InstallDecompilerAgentImpl extends java.lang.ObjectThis is byteman's install library copied, with small modifications. This is done with permission of Andrew Dinn, author of Byteman. For the original source of this code, please follow links below: http://byteman.jboss.org/ -- official page https://github.com/bytemanproject/byteman -- git repository This is a provisional solution for the attach, while I am trying to create an abstract library to share some functionality.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanaddToBootprivate static java.lang.StringAGENT_HOME_SYSTEM_PROPprivate static java.lang.StringAGENT_PORT_PROPERTYprivate java.lang.StringagentJarprivate Configconfigprivate java.lang.StringDECOMPILER_AGENT_BASE_DIRprivate java.lang.StringDECOMPILER_AGENT_NAMEprivate static java.lang.StringDECOMPILER_HOME_ENV_VARIABLEprivate java.lang.StringDECOMPILER_HOME_SYSTEM_PROPprivate static java.lang.StringDECOMPILER_JAR_ENV_VARIABLEprivate static java.lang.StringDECOMPILER_PREFIXprivate java.lang.Stringhostprivate java.lang.Stringidprivate java.lang.StringmodulePluginJarprivate intportprivate java.lang.Stringpropsprivate booleansetPolicyprivate booleanuseModuleLoaderprivate com.sun.tools.attach.VirtualMachinevm
-
Constructor Summary
Constructors Modifier Constructor Description privateInstallDecompilerAgentImpl(java.lang.String pid, boolean addToBoot, boolean setPolicy, boolean useModuleLoader, java.lang.String host, int port, java.lang.String[] properties)privateInstallDecompilerAgentImpl(java.lang.String pid, boolean addToBoot, java.lang.String host, int port, java.lang.String[] properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidattach()attach to the Java process identified by the process id supplied on the command linestatic org.jboss.byteman.agent.install.VMInfo[]availableVMs()private static java.lang.StringgetProperty(java.lang.String id, java.lang.String property)static java.lang.StringgetSystemProperty(java.lang.String id, java.lang.String property)private voidinjectAgent()get the attached process to upload and install the agent jar using whatever agent options were configured on the command linestatic voidinstall(java.lang.String pid, boolean addToBoot, boolean setPolicy, boolean useModuleLoader, java.lang.String host, int port, java.lang.String[] properties)static voidinstall(java.lang.String pid, boolean addToBoot, boolean setPolicy, java.lang.String host, int port, java.lang.String[] properties)static voidinstall(java.lang.String pid, boolean addToBoot, java.lang.String host, int port, java.lang.String[] properties)private voidlocateAgent()java.lang.StringlocateJarFromClasspath(java.lang.String libName)java.lang.StringlocateJarFromHomeDir(java.lang.String bmHome, java.lang.String baseDir, java.lang.String libName)private voidparseArgs(java.lang.String[] args)check the supplied arguments and stash away the relevant data
-
-
-
Field Detail
-
AGENT_PORT_PROPERTY
private static final java.lang.String AGENT_PORT_PROPERTY
- See Also:
- Constant Field Values
-
AGENT_HOME_SYSTEM_PROP
private static final java.lang.String AGENT_HOME_SYSTEM_PROP
- See Also:
- Constant Field Values
-
DECOMPILER_HOME_ENV_VARIABLE
private static final java.lang.String DECOMPILER_HOME_ENV_VARIABLE
- See Also:
- Constant Field Values
-
DECOMPILER_JAR_ENV_VARIABLE
private static final java.lang.String DECOMPILER_JAR_ENV_VARIABLE
- See Also:
- Constant Field Values
-
DECOMPILER_PREFIX
private static final java.lang.String DECOMPILER_PREFIX
- See Also:
- Constant Field Values
-
agentJar
private java.lang.String agentJar
-
modulePluginJar
private java.lang.String modulePluginJar
-
id
private java.lang.String id
-
port
private int port
-
host
private java.lang.String host
-
addToBoot
private boolean addToBoot
-
setPolicy
private boolean setPolicy
-
useModuleLoader
private boolean useModuleLoader
-
props
private java.lang.String props
-
vm
private com.sun.tools.attach.VirtualMachine vm
-
config
private Config config
-
DECOMPILER_HOME_SYSTEM_PROP
private java.lang.String DECOMPILER_HOME_SYSTEM_PROP
-
DECOMPILER_AGENT_NAME
private java.lang.String DECOMPILER_AGENT_NAME
-
DECOMPILER_AGENT_BASE_DIR
private java.lang.String DECOMPILER_AGENT_BASE_DIR
-
-
Constructor Detail
-
InstallDecompilerAgentImpl
private InstallDecompilerAgentImpl(java.lang.String pid, boolean addToBoot, boolean setPolicy, boolean useModuleLoader, java.lang.String host, int port, java.lang.String[] properties)
-
InstallDecompilerAgentImpl
private InstallDecompilerAgentImpl(java.lang.String pid, boolean addToBoot, java.lang.String host, int port, java.lang.String[] properties)
-
-
Method Detail
-
install
public static void install(java.lang.String pid, boolean addToBoot, java.lang.String host, int port, java.lang.String[] properties) throws java.lang.IllegalArgumentException, java.io.FileNotFoundException, java.io.IOException, com.sun.tools.attach.AttachNotSupportedException, com.sun.tools.attach.AgentLoadException, com.sun.tools.attach.AgentInitializationException- Throws:
java.lang.IllegalArgumentExceptionjava.io.FileNotFoundExceptionjava.io.IOExceptioncom.sun.tools.attach.AttachNotSupportedExceptioncom.sun.tools.attach.AgentLoadExceptioncom.sun.tools.attach.AgentInitializationException
-
install
public static void install(java.lang.String pid, boolean addToBoot, boolean setPolicy, java.lang.String host, int port, java.lang.String[] properties) throws java.lang.IllegalArgumentException, java.io.FileNotFoundException, java.io.IOException, com.sun.tools.attach.AttachNotSupportedException, com.sun.tools.attach.AgentLoadException, com.sun.tools.attach.AgentInitializationException- Throws:
java.lang.IllegalArgumentExceptionjava.io.FileNotFoundExceptionjava.io.IOExceptioncom.sun.tools.attach.AttachNotSupportedExceptioncom.sun.tools.attach.AgentLoadExceptioncom.sun.tools.attach.AgentInitializationException
-
install
public static void install(java.lang.String pid, boolean addToBoot, boolean setPolicy, boolean useModuleLoader, java.lang.String host, int port, java.lang.String[] properties) throws java.lang.IllegalArgumentException, java.io.FileNotFoundException, java.io.IOException, com.sun.tools.attach.AttachNotSupportedException, com.sun.tools.attach.AgentLoadException, com.sun.tools.attach.AgentInitializationException- Throws:
java.lang.IllegalArgumentExceptionjava.io.FileNotFoundExceptionjava.io.IOExceptioncom.sun.tools.attach.AttachNotSupportedExceptioncom.sun.tools.attach.AgentLoadExceptioncom.sun.tools.attach.AgentInitializationException
-
availableVMs
public static org.jboss.byteman.agent.install.VMInfo[] availableVMs()
-
getSystemProperty
public static java.lang.String getSystemProperty(java.lang.String id, java.lang.String property)
-
getProperty
private static java.lang.String getProperty(java.lang.String id, java.lang.String property)
-
attach
private void attach() throws com.sun.tools.attach.AttachNotSupportedException, java.io.IOException, java.lang.IllegalArgumentExceptionattach to the Java process identified by the process id supplied on the command line- Throws:
com.sun.tools.attach.AttachNotSupportedExceptionjava.io.IOExceptionjava.lang.IllegalArgumentException
-
injectAgent
private void injectAgent() throws com.sun.tools.attach.AgentLoadException, com.sun.tools.attach.AgentInitializationException, java.io.IOExceptionget the attached process to upload and install the agent jar using whatever agent options were configured on the command line- Throws:
com.sun.tools.attach.AgentLoadExceptioncom.sun.tools.attach.AgentInitializationExceptionjava.io.IOException
-
parseArgs
private void parseArgs(java.lang.String[] args)
check the supplied arguments and stash away the relevant data- Parameters:
args- the value supplied to main
-
locateAgent
private void locateAgent() throws java.io.IOException- Throws:
java.io.IOException
-
locateJarFromHomeDir
public java.lang.String locateJarFromHomeDir(java.lang.String bmHome, java.lang.String baseDir, java.lang.String libName) throws java.io.IOException- Parameters:
bmHome- homebaseDir- base directorylibName- library name- Returns:
- jar path
- Throws:
java.io.IOException- file not found
-
locateJarFromClasspath
public java.lang.String locateJarFromClasspath(java.lang.String libName) throws java.io.IOException- Parameters:
libName- name of library- Returns:
- jar name
- Throws:
java.io.IOException- file not found
-
-