本文整理汇总了Java中com.sun.jdi.connect.Connector.Argument方法的典型用法代码示例。如果您正苦于以下问题:Java Connector.Argument方法的具体用法?Java Connector.Argument怎么用?Java Connector.Argument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.connect.Connector
的用法示例。
在下文中一共展示了Connector.Argument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例5: 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;
}
示例6: 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);
}
}
示例7: 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);
}
示例8: 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;
}
示例9: 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);
}
}
}
示例10: 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);
}
示例11: ChildSession
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public ChildSession(ExecutionManager runtime,
LaunchingConnector connector,
Map<String, Connector.Argument> arguments,
InputListener input,
OutputListener output,
OutputListener error,
OutputListener diagnostics) {
this(runtime, generalGetVM(diagnostics, connector, arguments),
input, output, error, diagnostics);
}
示例12: getVM
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
static private VirtualMachine getVM(OutputListener diagnostics,
String userVMArgs,
String cmdLine) {
VirtualMachineManager manager = Bootstrap.virtualMachineManager();
LaunchingConnector connector = manager.defaultConnector();
Map<String, Connector.Argument> arguments = connector.defaultArguments();
arguments.get("options").setValue(userVMArgs);
arguments.get("main").setValue(cmdLine);
return generalGetVM(diagnostics, connector, arguments);
}
示例13: commandConnectors
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
void commandConnectors(VirtualMachineManager vmm) {
Collection<Connector> ccs = vmm.allConnectors();
if (ccs.isEmpty()) {
MessageOutput.println("Connectors available");
}
for (Connector cc : ccs) {
String transportName =
cc.transport() == null ? "null" : cc.transport().name();
MessageOutput.println();
MessageOutput.println("Connector and Transport name",
new Object [] {cc.name(), transportName});
MessageOutput.println("Connector description", cc.description());
for (Connector.Argument aa : cc.defaultArguments().values()) {
MessageOutput.println();
boolean requiredArgument = aa.mustSpecify();
if (aa.value() == null || aa.value() == "") {
//no current value and no default.
MessageOutput.println(requiredArgument ?
"Connector required argument nodefault" :
"Connector argument nodefault", aa.name());
} else {
MessageOutput.println(requiredArgument ?
"Connector required argument default" :
"Connector argument default",
new Object [] {aa.name(), aa.value()});
}
MessageOutput.println("Connector description", aa.description());
}
}
}
示例14: launch
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
IOException,
IllegalConnectorArgumentsException,
VMStartException {
/*
* Get the class name that we are to execute
*/
String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
if (className.length() == 0) {
throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
}
/*
* Listen on an emperical port; launch the debuggee; wait for
* for the debuggee to connect; stop listening;
*/
TransportService.ListenKey key = ts.startListening();
String exe = System.getProperty("java.home") + File.separator + "bin" +
File.separator + "java";
String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
key.address() +
" -classpath " + System.getProperty("test.classes") +
" " + className;
Process process = Runtime.getRuntime().exec(cmd);
Connection conn = ts.accept(key, 30*1000, 9*1000);
ts.stopListening(key);
/*
* Debugee is connected - return the virtual machine mirror
*/
return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
示例15: equals
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public boolean equals(Object obj) {
if ((obj != null) && (obj instanceof Connector.Argument)) {
Connector.Argument other = (Connector.Argument)obj;
return (name().equals(other.name())) &&
(description().equals(other.description())) &&
(mustSpecify() == other.mustSpecify()) &&
(value().equals(other.value()));
} else {
return false;
}
}