本文整理汇总了Java中com.sun.jdi.connect.AttachingConnector类的典型用法代码示例。如果您正苦于以下问题:Java AttachingConnector类的具体用法?Java AttachingConnector怎么用?Java AttachingConnector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AttachingConnector类属于com.sun.jdi.connect包,在下文中一共展示了AttachingConnector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private VirtualMachine connect(int port) throws IOException {
VirtualMachineManager manager = Bootstrap.virtualMachineManager();
// Find appropiate connector
List<AttachingConnector> connectors = manager.attachingConnectors();
AttachingConnector chosenConnector = null;
for (AttachingConnector c : connectors) {
if (c.transport().name().equals(TRANSPORT_NAME)) {
chosenConnector = c;
break;
}
}
if (chosenConnector == null) {
throw new IllegalStateException("Could not find socket connector");
}
// Set port argument
AttachingConnector connector = chosenConnector;
Map<String, Argument> defaults = connector.defaultArguments();
Argument arg = defaults.get(PORT_ARGUMENT_NAME);
if (arg == null) {
throw new IllegalStateException("Could not find port argument");
}
arg.setValue(Integer.toString(port));
// Attach
try {
System.out.println("Connector arguments: " + defaults);
return connector.attach(defaults);
} catch (IllegalConnectorArgumentsException e) {
throw new IllegalArgumentException("Illegal connector arguments", e);
}
}
示例2: tryDebug
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private static void tryDebug(long pid) throws IOException,
IllegalConnectorArgumentsException {
AttachingConnector ac = Bootstrap.virtualMachineManager().attachingConnectors()
.stream()
.filter(c -> c.name().equals("com.sun.jdi.ProcessAttach"))
.findFirst()
.orElseThrow(() -> new RuntimeException("Unable to locate ProcessAttachingConnector"));
Map<String, Connector.Argument> args = ac.defaultArguments();
Connector.StringArgument arg = (Connector.StringArgument) args
.get("pid");
arg.setValue("" + pid);
System.out.println("Debugger is attaching to: " + pid + " ...");
VirtualMachine vm = ac.attach(args);
// list all threads
System.out.println("Attached! Now listing threads ...");
vm.allThreads().stream().forEach(System.out::println);
System.out.println("Debugger done.");
vm.dispose();
}
示例3: attach
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
public PermissionDebugger attach() throws IOException, IllegalConnectorArgumentsException {
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
List<AttachingConnector> connectors = vmm.attachingConnectors();
AttachingConnector connector =
connectors
.stream()
.filter(c -> c.transport().name().equals(transport))
.findFirst()
.orElseThrow(
() -> new IOException(String.format("Failed to find transport %s", transport)));
Map<String, Argument> map = connector.defaultArguments();
Argument portArg = map.get(PORT_KEY);
portArg.setValue(port);
map.put(PORT_KEY, portArg);
vm = connector.attach(map);
return this;
}
示例4: HotSwapperJpda
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
/**
* Connects to the JVM.
*
* @param port the port number used for the connection to the JVM.
*/
public HotSwapperJpda(String port)
throws IOException, IllegalConnectorArgumentsException {
jvm = null;
request = null;
newClassFiles = null;
trigger = new Trigger();
AttachingConnector connector
= (AttachingConnector) findConnector("com.sun.jdi.SocketAttach");
Map arguments = connector.defaultArguments();
((Connector.Argument) arguments.get("hostname")).setValue(HOST_NAME);
((Connector.Argument) arguments.get("port")).setValue(port);
jvm = connector.attach(arguments);
EventRequestManager manager = jvm.eventRequestManager();
request = methodEntryRequests(manager, TRIGGER_NAME);
}
示例5: AttachingDICookie
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private AttachingDICookie (
AttachingConnector attachingConnector,
Map<String,? extends Argument> args
) {
this.attachingConnector = attachingConnector;
this.args = args;
}
示例6: create
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
/**
* Creates a new instance of AttachingDICookie for given parameters.
*
* @param attachingConnector a connector to be used
* @param args map of arguments
* @return a new instance of AttachingDICookie for given parameters
*/
public static AttachingDICookie create (
AttachingConnector attachingConnector,
Map<String,? extends Argument> args
) {
return new AttachingDICookie (
attachingConnector,
args
);
}
示例7: getArgs
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private static Map<String,? extends Argument> getArgs (
AttachingConnector attachingConnector,
String hostName,
int portNumber
) {
Map<String,? extends Argument> args = attachingConnector.defaultArguments ();
args.get ("hostname").setValue (hostName);
args.get ("port").setValue ("" + portNumber);
return args;
}
示例8: main
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
public static void main(String main_args[]) throws Exception {
String pid = main_args[0];
// find ProcessAttachingConnector
List<AttachingConnector> l =
Bootstrap.virtualMachineManager().attachingConnectors();
AttachingConnector ac = null;
for (AttachingConnector c: l) {
if (c.name().equals("com.sun.jdi.ProcessAttach")) {
ac = c;
break;
}
}
if (ac == null) {
throw new RuntimeException("Unable to locate ProcessAttachingConnector");
}
Map<String,Connector.Argument> args = ac.defaultArguments();
Connector.StringArgument arg = (Connector.StringArgument)args.get("pid");
arg.setValue(pid);
System.out.println("Debugger is attaching to: " + pid + " ...");
VirtualMachine vm = ac.attach(args);
System.out.println("Attached! Now listing threads ...");
// list all threads
for (ThreadReference thr: vm.allThreads()) {
System.out.println(thr);
}
System.out.println("Debugger done.");
}
示例9: attachDebugger
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
public static VirtualMachine attachDebugger(String hostname, int port) {
VirtualMachineManager vmm = com.sun.jdi.Bootstrap.virtualMachineManager();
AttachingConnector atconn = null;
for(AttachingConnector c: vmm.attachingConnectors())
if("dt_socket".equalsIgnoreCase(c.transport().name())) {
atconn = c;
}
Map<String, Connector.Argument> prm = atconn.defaultArguments();
prm.get("hostname").setValue(hostname);
prm.get("port").setValue(Integer.toString(port));
VirtualMachine vm2 = null;
try {
vm2 = atconn.attach(prm);
///for(ThreadReference t: vm2.allThreads()) {
// log.info(t.name());
// if (t.name().equals("main"))
// t.suspend();
//}
vm2.resume();
} catch(Exception e) {
e.printStackTrace();
//throw new RuntimeException(e);
}
return vm2;
}
示例10: connect
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
/**
* Call this with the localhost port to connect to.
*/
public VirtualMachine connect(int port)
throws IOException {
String strPort = Integer.toString(port);
AttachingConnector connector = getConnector();
try {
return connect(connector, strPort);
} catch (IllegalConnectorArgumentsException e) {
throw new IllegalStateException(e);
}
}
示例11: getConnector
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private AttachingConnector getConnector() {
VirtualMachineManager vmManager = Bootstrap.virtualMachineManager();
for (Connector connector : vmManager.attachingConnectors()) {
if ("com.sun.jdi.SocketAttach".equals(connector.name())) {
return (AttachingConnector) connector;
}
}
throw new IllegalStateException();
}
示例12: connector
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private AttachingConnector connector(String connectorName) {
for (AttachingConnector c : Bootstrap.virtualMachineManager().attachingConnectors()) {
if (connectorName.equals(c.name())) {
return c;
}
}
return null;
}
示例13: makePlatformConnector
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private static AttachingConnector makePlatformConnector() {
Class connectorClass = null;
try {
connectorClass = Class.forName(SHAREDMEM_ATTACHING_CONN);
} catch (ClassNotFoundException cnfe) {
}
if (connectorClass == null) {
throw new RuntimeException("can not load class: " + SHAREDMEM_ATTACHING_CONN);
}
try {
return (AttachingConnector) connectorClass.newInstance();
} catch (Exception exp) {
throw new RuntimeException(exp);
}
}
示例14: makePlatformConnector
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private static AttachingConnector makePlatformConnector() {
Class connectorClass = null;
try {
connectorClass = Class.forName(SOCKET_ATTACHING_CONN);
} catch (ClassNotFoundException cnfe) {}
if (connectorClass == null) {
throw new RuntimeException("can not load class: " + SOCKET_ATTACHING_CONN);
}
try {
return (AttachingConnector) connectorClass.newInstance();
} catch (Exception exp) {
throw new RuntimeException(exp);
}
}
示例15: makePlatformConnector
import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private static AttachingConnector makePlatformConnector() {
Class connectorClass = null;
try {
connectorClass = Class.forName(PROCESS_ATTACHING_CONN);
} catch (ClassNotFoundException cnfe) {
}
if (connectorClass == null) {
throw new RuntimeException("can not load class: " + PROCESS_ATTACHING_CONN);
}
try {
return (AttachingConnector) connectorClass.newInstance();
} catch (Exception exp) {
throw new RuntimeException(exp);
}
}