Package org.jrd.backend.communication
Class InstallDecompilerAgentImpl
- java.lang.Object
-
- org.jrd.backend.communication.InstallDecompilerAgentImpl
-
public class InstallDecompilerAgentImpl extends java.lang.Object
This 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 boolean
addToBoot
private static java.lang.String
AGENT_HOME_SYSTEM_PROP
private static java.lang.String
AGENT_PORT_PROPERTY
private java.lang.String
agentJar
private Config
config
private java.lang.String
DECOMPILER_AGENT_BASE_DIR
private java.lang.String
DECOMPILER_AGENT_NAME
private static java.lang.String
DECOMPILER_HOME_ENV_VARIABLE
private java.lang.String
DECOMPILER_HOME_SYSTEM_PROP
private static java.lang.String
DECOMPILER_JAR_ENV_VARIABLE
private static java.lang.String
DECOMPILER_PREFIX
private java.lang.String
host
private java.lang.String
id
private java.lang.String
modulePluginJar
private int
port
private java.lang.String
props
private boolean
setPolicy
private boolean
useModuleLoader
private com.sun.tools.attach.VirtualMachine
vm
-
Constructor Summary
Constructors Modifier Constructor Description private
InstallDecompilerAgentImpl(java.lang.String pid, boolean addToBoot, boolean setPolicy, boolean useModuleLoader, java.lang.String host, int port, java.lang.String[] properties)
private
InstallDecompilerAgentImpl(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 void
attach()
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.String
getProperty(java.lang.String id, java.lang.String property)
static java.lang.String
getSystemProperty(java.lang.String id, java.lang.String property)
private void
injectAgent()
get the attached process to upload and install the agent jar using whatever agent options were configured on the command linestatic void
install(java.lang.String pid, boolean addToBoot, boolean setPolicy, boolean useModuleLoader, java.lang.String host, int port, java.lang.String[] properties)
static void
install(java.lang.String pid, boolean addToBoot, boolean setPolicy, java.lang.String host, int port, java.lang.String[] properties)
static void
install(java.lang.String pid, boolean addToBoot, java.lang.String host, int port, java.lang.String[] properties)
private void
locateAgent()
java.lang.String
locateJarFromClasspath(java.lang.String libName)
java.lang.String
locateJarFromHomeDir(java.lang.String bmHome, java.lang.String baseDir, java.lang.String libName)
private void
parseArgs(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.IllegalArgumentException
java.io.FileNotFoundException
java.io.IOException
com.sun.tools.attach.AttachNotSupportedException
com.sun.tools.attach.AgentLoadException
com.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.IllegalArgumentException
java.io.FileNotFoundException
java.io.IOException
com.sun.tools.attach.AttachNotSupportedException
com.sun.tools.attach.AgentLoadException
com.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.IllegalArgumentException
java.io.FileNotFoundException
java.io.IOException
com.sun.tools.attach.AttachNotSupportedException
com.sun.tools.attach.AgentLoadException
com.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.IllegalArgumentException
attach to the Java process identified by the process id supplied on the command line- Throws:
com.sun.tools.attach.AttachNotSupportedException
java.io.IOException
java.lang.IllegalArgumentException
-
injectAgent
private void injectAgent() throws com.sun.tools.attach.AgentLoadException, com.sun.tools.attach.AgentInitializationException, java.io.IOException
get 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.AgentLoadException
com.sun.tools.attach.AgentInitializationException
java.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
-
-