本文整理汇总了Java中com.sun.jdi.Bootstrap.virtualMachineManager方法的典型用法代码示例。如果您正苦于以下问题:Java Bootstrap.virtualMachineManager方法的具体用法?Java Bootstrap.virtualMachineManager怎么用?Java Bootstrap.virtualMachineManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.Bootstrap
的用法示例。
在下文中一共展示了Bootstrap.virtualMachineManager方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import com.sun.jdi.Bootstrap; //导入方法依赖的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: attach
import com.sun.jdi.Bootstrap; //导入方法依赖的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;
}
示例3: launch
import com.sun.jdi.Bootstrap; //导入方法依赖的package包/类
protected VirtualMachine launch(String[] commandArray, String address,
TransportService.ListenKey listenKey,
TransportService ts)
throws IOException, VMStartException {
Helper helper = new Helper(commandArray, address, listenKey, ts);
helper.launchAndAccept();
VirtualMachineManager manager =
Bootstrap.virtualMachineManager();
return manager.createVirtualMachine(helper.connection(),
helper.process());
}
示例4: test
import com.sun.jdi.Bootstrap; //导入方法依赖的package包/类
@Test
public void test() {
VirtualMachineManager virtualMachineManager = Bootstrap.virtualMachineManager();
List<Connector> allConnectors = virtualMachineManager.allConnectors();
List<VirtualMachine> connectedVirtualMachines = virtualMachineManager.connectedVirtualMachines();
System.out.println(allConnectors);
System.out.println(connectedVirtualMachines);
}
示例5: getConnector
import com.sun.jdi.Bootstrap; //导入方法依赖的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();
}
示例6: connect
import com.sun.jdi.Bootstrap; //导入方法依赖的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);
}
}
示例7: getConnector
import com.sun.jdi.Bootstrap; //导入方法依赖的package包/类
private AttachingConnector getConnector() {
VirtualMachineManager vmManager = Bootstrap
.virtualMachineManager();
for (AttachingConnector connector : vmManager
.attachingConnectors()) {
if ("com.sun.jdi.SocketAttach".equals(connector
.name())) {
return (AttachingConnector) connector;
}
}
throw new IllegalStateException();
}
示例8: attach
import com.sun.jdi.Bootstrap; //导入方法依赖的package包/类
public static JPDASupport attach (String mainClass, String[] args, File[] classPath) throws IOException,
DebuggerStartException {
Process process = launchVM (mainClass, args, classPath, "", true);
String line = readLine (process.getInputStream ());
int port = Integer.parseInt (line.substring (line.lastIndexOf (':') + 1).trim ());
ProcessIO pio = new ProcessIO (process);
pio.go ();
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
List aconnectors = vmm.attachingConnectors();
AttachingConnector connector = null;
for (Iterator i = aconnectors.iterator(); i.hasNext();) {
AttachingConnector ac = (AttachingConnector) i.next();
Transport t = ac.transport ();
if (t != null && t.name().equals("dt_socket")) {
connector = ac;
break;
}
}
if (connector == null)
throw new RuntimeException
("No attaching socket connector available");
JPDADebugger jpdaDebugger = JPDADebugger.attach (
"localhost",
port,
createServices ()
);
return new JPDASupport (jpdaDebugger);
}
示例9: connectedVirtualMachines
import com.sun.jdi.Bootstrap; //导入方法依赖的package包/类
public List<VirtualMachine> connectedVirtualMachines() {
VirtualMachineManager pvmm = Bootstrap.virtualMachineManager();
return F3Wrapper.wrapVirtualMachines(pvmm.connectedVirtualMachines());
}
示例10: createVirtualMachine
import com.sun.jdi.Bootstrap; //导入方法依赖的package包/类
public VirtualMachine createVirtualMachine(Connection connection,
Process process) throws IOException {
VirtualMachineManager pvmm = Bootstrap.virtualMachineManager();
return F3Wrapper.wrap(pvmm.createVirtualMachine(connection, process));
}