本文整理汇总了Java中com.sun.jdi.connect.Connector类的典型用法代码示例。如果您正苦于以下问题:Java Connector类的具体用法?Java Connector怎么用?Java Connector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Connector类属于com.sun.jdi.connect包,在下文中一共展示了Connector类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectorArguments
import com.sun.jdi.connect.Connector; //导入依赖的package包/类
/**
* Return the launching connector's arguments.
*/
static Map <String,Connector.Argument> connectorArguments(LaunchingConnector connector, String mainArgs) {
Map<String,Connector.Argument> arguments = connector.defaultArguments();
for (String key : arguments.keySet()) {
System.out.println(key);
}
Connector.Argument mainArg = (Connector.Argument)arguments.get("main");
if (mainArg == null) {
throw new Error("Bad launching connector");
}
mainArg.setValue(mainArgs);
Connector.Argument optionsArg = (Connector.Argument)arguments.get("options");
if (optionsArg == null) {
throw new Error("Bad launching connector");
}
optionsArg.setValue(ARGUMENTS);
return arguments;
}
示例2: putConnectionProperties
import com.sun.jdi.connect.Connector; //导入依赖的package包/类
private static void putConnectionProperties(Session session, Map properties) {
ListeningDICookie lc = session.lookupFirst(null, ListeningDICookie.class);
Map<String, ? extends Connector.Argument> args = null;
if (lc != null) {
args = lc.getArgs();
properties.put("conn_port", lc.getPortNumber());
properties.put("conn_shmem", lc.getSharedMemoryName());
} else {
AttachingDICookie ac = session.lookupFirst(null, AttachingDICookie.class);
if (ac != null) {
args = ac.getArgs();
properties.put("conn_host", ac.getHostName());
properties.put("conn_port", ac.getPortNumber());
properties.put("conn_shmem", ac.getSharedMemoryName());
properties.put("conn_pid", ac.getProcessID());
}
}
}
示例3: generalGetVM
import com.sun.jdi.connect.Connector; //导入依赖的package包/类
static private VirtualMachine generalGetVM(OutputListener diagnostics,
LaunchingConnector connector,
Map<String, Connector.Argument> arguments) {
VirtualMachine vm = null;
try {
diagnostics.putString("Starting child.");
vm = connector.launch(arguments);
} catch (IOException ioe) {
diagnostics.putString("Unable to start child: " + ioe.getMessage());
} catch (IllegalConnectorArgumentsException icae) {
diagnostics.putString("Unable to start child: " + icae.getMessage());
} catch (VMStartException vmse) {
diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
dumpFailedLaunchInfo(diagnostics, vmse.process());
}
return vm;
}
示例4: main
import com.sun.jdi.connect.Connector; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
for (ListeningConnector lc: connectors) {
Map<String,Connector.Argument> cargs = lc.defaultArguments();
Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");
/*
* If the Connector has a argument named "timeout" then we set the timeout to 1 second
* and start it listening on its default address. It should throw TranpsortTimeoutException.
*/
if (timeout != null) {
System.out.println("Testing " + lc.name());
timeout.setValue(1000);
System.out.println("Listening on: " + lc.startListening(cargs));
try {
lc.accept(cargs);
throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
} catch (TransportTimeoutException e) {
System.out.println("Timed out as expected.\n");
}
lc.stopListening(cargs);
}
}
}
示例5: connectorArguments
import com.sun.jdi.connect.Connector; //导入依赖的package包/类
/**
* Return the launching connector's arguments.
*/
static Map <String,Connector.Argument> connectorArguments(LaunchingConnector connector, String mainArgs) {
Map<String,Connector.Argument> arguments = connector.defaultArguments();
Connector.Argument mainArg = (Connector.Argument)arguments.get("main");
if (mainArg == null) {
throw new Error("Bad launching connector");
}
mainArg.setValue(mainArgs);
Connector.Argument optionsArg = (Connector.Argument)arguments.get("options");
if (optionsArg == null) {
throw new Error("Bad launching connector");
}
optionsArg.setValue(ARGUMENTS);
return arguments;
}
示例6: mergeConnectorArgs
import com.sun.jdi.connect.Connector; //导入依赖的package包/类
private Map<String, Connector.Argument> mergeConnectorArgs(Connector connector, Map<String, String> argumentName2Value) {
Map<String, Connector.Argument> arguments = connector.defaultArguments();
for (Entry<String, String> argumentEntry : argumentName2Value.entrySet()) {
String name = argumentEntry.getKey();
String value = argumentEntry.getValue();
Connector.Argument argument = arguments.get(name);
if (argument == null) {
throw new IllegalArgumentException("Argument is not defined for connector:" +
name + " -- " + connector.name());
}
argument.setValue(value);
}
return arguments;
}
示例7: launch
import com.sun.jdi.connect.Connector; //导入依赖的package包/类
public VirtualMachine
launch(Map<String, ? extends Connector.Argument> arguments)
throws IOException, IllegalConnectorArgumentsException,
VMStartException
{
String command = argument(ARG_COMMAND, arguments).value();
String address = argument(ARG_ADDRESS, arguments).value();
String quote = argument(ARG_QUOTE, arguments).value();
if (quote.length() > 1) {
throw new IllegalConnectorArgumentsException("Invalid length",
ARG_QUOTE);
}
TransportService.ListenKey listener = transportService.startListening(address);
try {
return launch(tokenizeCommand(command, quote.charAt(0)),
address, listener, transportService);
} finally {
transportService.stopListening(listener);
}
}
示例8: startListening
import com.sun.jdi.connect.Connector; //导入依赖的package包/类
public String
startListening(Map<String,? extends Connector.Argument> args)
throws IOException, IllegalConnectorArgumentsException
{
String port = argument(ARG_PORT, args).value();
String localaddr = argument(ARG_LOCALADDR, args).value();
// default to system chosen port
if (port.length() == 0) {
port = "0";
}
if (localaddr.length() > 0) {
localaddr = localaddr + ":" + port;
} else {
localaddr = port;
}
return super.startListening(localaddr, args);
}
示例9: tryDebug
import com.sun.jdi.connect.Connector; //导入依赖的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();
}
示例10: HotSwapperJpda
import com.sun.jdi.connect.Connector; //导入依赖的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);
}
示例11: connect
import com.sun.jdi.connect.Connector; //导入依赖的package包/类
@BeforeClass
public static void connect() throws Exception {
SocketAttachingConnector socketConnector = null;
for (Connector connector : Bootstrap.virtualMachineManager().allConnectors()) {
if (connector instanceof SocketAttachingConnector) {
socketConnector = (SocketAttachingConnector) connector;
}
}
if (socketConnector == null) {
throw new RuntimeException("Failed to find SocketAttachingConnector");
}
Map<String, ? extends Connector.Argument> args = socketConnector.defaultArguments();
Connector.IntegerArgument port = (Connector.IntegerArgument) args.get("port");
port.setValue(PORT);
Connector.StringArgument hostname = (Connector.StringArgument) args.get("hostname");
hostname.setValue("localhost");
virtualMachine = socketConnector.attach(args);
}