Package com.sun.tools.attach

Examples of com.sun.tools.attach.VirtualMachine.detach()


            }

            String jmxConnectorAddress = getJmxConnectorAddress(vm);

            try {
                vm.detach();
            } catch (Exception e) {
                // We already succeeded in obtaining the connector address, so just log this, rather than throwing an exception.
                LOG.error("Failed to detach from JVM [" + vm + "].", e);
            }
View Full Code Here


                String s = new String(b, 0, n, "UTF-8");
                System.out.print(s);
            }
        } while (n > 0);
        in.close();
        vm.detach();
    }

    // return a new string array with arg as the first element
    private static String[] prepend(String arg, String args[])
    {
View Full Code Here

            GenerateScriptUtil.copy(bytemanInputJar, new FileOutputStream(bytemanJar));

            VirtualMachine vm = VirtualMachine.attach(pid);
            String agentProperties = config.agentProperties();
            vm.loadAgent(bytemanJar.getAbsolutePath(), "listener:true,port:" + config.clientAgentPort() + (agentProperties != null ? ",prop:" + agentProperties : ""));
            vm.detach();
        } catch (IOException e) {
            throw new RuntimeException("Could not write byteman.jar to disk", e);
        } catch (Exception e) {
            throw new RuntimeException("Could not install byteman agent", e);
        }
View Full Code Here

                final String agent = Paths.get(vm.getSystemProperties().getProperty(PROP_JAVA_HOME)).resolve(MANAGEMENT_AGENT).toString();
                vm.loadAgent(agent);
                connectorAddr = vm.getAgentProperties().getProperty(PROP_LOCAL_CONNECTOR_ADDRESS);
            }
            final JMXServiceURL url = connectorAddr != null ? new JMXServiceURL(connectorAddr) : null;
            vm.detach();
            return url;
        } catch (AttachNotSupportedException e) {
            throw new UnsupportedOperationException(e);
        } catch (Exception e) {
            try {
View Full Code Here

        } catch (AttachNotSupportedException e) {
            throw new UnsupportedOperationException(e);
        } catch (Exception e) {
            try {
                if (vm != null)
                    vm.detach();
            } catch (IOException ex) {
                e.addSuppressed(ex);
            }
            throw e instanceof RuntimeException ? (RuntimeException)e : new RuntimeException(e);
        }
View Full Code Here

            GenerateScriptUtil.copy(bytemanInputJar, new FileOutputStream(bytemanJar));

            VirtualMachine vm = VirtualMachine.attach(pid);
            String agentProperties = config.agentProperties();
            vm.loadAgent(bytemanJar.getAbsolutePath(), "listener:true,port:" + config.containerAgentPort() + (agentProperties != null ? ",prop:" + agentProperties : ""));
            vm.detach();
        } catch (IOException e) {
            throw new RuntimeException("Could not write byteman.jar to disk", e);
        } catch (Exception e) {
            throw new RuntimeException("Could not install byteman agent", e);
        }
View Full Code Here

                    try {
                        VirtualMachine virtualmachine = VirtualMachine.attach(virtualmachinedescriptor);
                        flag = true;
                        Properties properties = virtualmachine.getAgentProperties();
                        s = (String) properties.get("com.sun.management.jmxremote.localConnectorAddress");
                        virtualmachine.detach();
                    }
                    catch (AttachNotSupportedException attachnotsupportedexception) {
                    }
                    catch (IOException ioexception) {
                    }
View Full Code Here

            ioexception2.initCause(agentinitializationexception);
            throw ioexception2;
        }
        Properties properties = virtualmachine.getAgentProperties();
        lvm.setConnectorAddress((String) properties.get("com.sun.management.jmxremote.localConnectorAddress"));
        virtualmachine.detach();
    }
}
View Full Code Here

                    try {
                        VirtualMachine vm = VirtualMachine.attach(vmd);
                        attachable = true;
                        Properties agentProps = vm.getAgentProperties();
                        address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP);
                        vm.detach();
                    } catch (AttachNotSupportedException x) {
                        // not attachable
                    } catch (IOException x) {
                        // ignore
                    }
View Full Code Here

            try {
                VirtualMachine vm = VirtualMachine.attach(name);
                attachable = true;
                Properties agentProps = vm.getAgentProperties();
                address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP);
                vm.detach();
                lvm = new LocalVirtualMachine(vmid, name, attachable, address);
            } catch (AttachNotSupportedException x) {
                // not attachable
                x.printStackTrace();
            } catch (IOException x) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.