本文整理汇总了Java中com.sun.jdi.connect.Connector.IntegerArgument方法的典型用法代码示例。如果您正苦于以下问题:Java Connector.IntegerArgument方法的具体用法?Java Connector.IntegerArgument怎么用?Java Connector.IntegerArgument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.connect.Connector
的用法示例。
在下文中一共展示了Connector.IntegerArgument方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
示例2: 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);
}
示例3: getDefaultArguments
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
@Override
public Map<String, Connector.Argument> getDefaultArguments() throws CoreException {
Map<String, Connector.Argument> def = getListeningConnector().defaultArguments();
Connector.IntegerArgument arg = (Connector.IntegerArgument) def.get("port"); //$NON-NLS-1$
arg.setValue(8000);
return def;
}
示例4: specifyArguments
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
private void specifyArguments( Map map, int portNumber )
{
// XXX: Revisit - allows us to put a quote (") around the classpath
Connector.IntegerArgument port = (Connector.IntegerArgument) map.get( "port" ); //$NON-NLS-1$
port.setValue( portNumber );
Connector.IntegerArgument timeoutArg = (Connector.IntegerArgument) map.get( "timeout" ); //$NON-NLS-1$
if ( timeoutArg != null )
{
int timeout = JavaRuntime.getPreferences( )
.getInt( JavaRuntime.PREF_CONNECT_TIMEOUT );
timeoutArg.setValue( timeout );
}
}
示例5: main
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
// find a free port
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
ss.close();
String address = String.valueOf(port);
// launch the first debuggee
Process process1 = launch(address, true, "HelloWorld");
// give first debuggee time to suspend
Thread.currentThread().sleep(5000);
// launch a second debuggee with the same address
Process process2 = launch(address, false, "HelloWorld");
// get exit status from second debuggee
int exitCode = process2.waitFor();
// clean-up - attach to first debuggee and resume it
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);
vm.resume();
// if the second debuggee ran to completion then we've got a problem
if (exitCode == 0) {
throw new RuntimeException("Test failed - second debuggee didn't fail to bind");
} else {
System.out.println("Test passed - second debuggee correctly failed to bind");
}
}
示例6: specifyArguments
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
protected void specifyArguments(Map map, int portNumber) {
Connector.IntegerArgument port = (Connector.IntegerArgument) map
.get("port"); //$NON-NLS-1$
port.setValue(portNumber);
Connector.IntegerArgument timeoutArg = (Connector.IntegerArgument) map
.get("timeout"); //$NON-NLS-1$
if (timeoutArg != null) {
int timeout = JavaRuntime.getPreferences().getInt(
JavaRuntime.PREF_CONNECT_TIMEOUT);
timeoutArg.setValue(timeout);
}
}
示例7: main
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
// find a free port
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
ss.close();
String address = String.valueOf(port);
// launch the server debuggee
Process process = launch(address, "Exit0");
// wait for the debugge to be ready
while (!ready) {
try {
Thread.sleep(1000);
} catch(Exception ee) {
throw ee;
}
}
// attach to server debuggee and resume it so it can exit
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);
// The first event is always a VMStartEvent, and it is always in
// an EventSet by itself. Wait for it.
EventSet evtSet = vm.eventQueue().remove();
for (Event event: evtSet) {
if (event instanceof VMStartEvent) {
break;
}
throw new RuntimeException("Test failed - debuggee did not start properly");
}
vm.eventRequestManager().deleteAllBreakpoints();
vm.resume();
int exitCode = process.waitFor();
// if the server debuggee ran cleanly, we assume we were clean
if (exitCode == 0 && error_seen == 0) {
System.out.println("Test passed - server debuggee cleanly terminated");
} else {
throw new RuntimeException("Test failed - server debuggee generated an error when it terminated");
}
}
示例8: main
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
// find a free port
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
ss.close();
String address = String.valueOf(port);
// launch the first debuggee
ProcessBuilder process1 = prepareLauncher(address, true, "HelloWorld");
// start the debuggee and wait for the "ready" message
Process p = ProcessTools.startProcess(
"process1",
process1,
line -> line.equals("Listening for transport dt_socket at address: " + address),
Math.round(5000 * Utils.TIMEOUT_FACTOR),
TimeUnit.MILLISECONDS
);
// launch a second debuggee with the same address
ProcessBuilder process2 = prepareLauncher(address, false, "HelloWorld");
// get exit status from second debuggee
int exitCode = ProcessTools.startProcess("process2", process2).waitFor();
// clean-up - attach to first debuggee and resume it
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);
vm.resume();
// if the second debuggee ran to completion then we've got a problem
if (exitCode == 0) {
throw new RuntimeException("Test failed - second debuggee didn't fail to bind");
} else {
System.out.println("Test passed - second debuggee correctly failed to bind");
}
}
示例9: main
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
// find a free port
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
ss.close();
String address = String.valueOf(port);
// launch the server debuggee
Process process = launch(address, "Exit0");
// attach to server debuggee and resume it so it can exit
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
System.out.println("Connection arguments: " + conn_args);
VirtualMachine vm = null;
while (vm == null) {
try {
vm = conn.attach(conn_args);
} catch (ConnectException e) {
e.printStackTrace(System.out);
System.out.println("--- Debugee not ready. Retrying in 500ms. ---");
Thread.sleep(500);
}
}
// The first event is always a VMStartEvent, and it is always in
// an EventSet by itself. Wait for it.
EventSet evtSet = vm.eventQueue().remove();
for (Event event: evtSet) {
if (event instanceof VMStartEvent) {
break;
}
throw new RuntimeException("Test failed - debuggee did not start properly");
}
vm.eventRequestManager().deleteAllBreakpoints();
vm.resume();
int exitCode = process.waitFor();
// if the server debuggee ran cleanly, we assume we were clean
if (exitCode == 0 && error_seen == 0) {
System.out.println("Test passed - server debuggee cleanly terminated");
} else {
throw new RuntimeException("Test failed - server debuggee generated an error when it terminated, " +
"exit code was " + exitCode + ", " + error_seen + " error(s) seen in debugee output.");
}
}
示例10: main
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
// find a free port
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
ss.close();
String address = String.valueOf(port);
// launch the first debuggee
ProcessBuilder process1 = prepareLauncher(address, true, "HelloWorld");
// start the debuggee and wait for the "ready" message
Process p = ProcessTools.startProcess(
"process1",
process1,
line -> line.equals("Listening for transport dt_socket at address: " + address),
Utils.adjustTimeout(5000),
TimeUnit.MILLISECONDS
);
// launch a second debuggee with the same address
ProcessBuilder process2 = prepareLauncher(address, false, "HelloWorld");
// get exit status from second debuggee
int exitCode = ProcessTools.startProcess("process2", process2).waitFor();
// clean-up - attach to first debuggee and resume it
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);
vm.resume();
// if the second debuggee ran to completion then we've got a problem
if (exitCode == 0) {
throw new RuntimeException("Test failed - second debuggee didn't fail to bind");
} else {
System.out.println("Test passed - second debuggee correctly failed to bind");
}
}
示例11: main
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
// Launch the server debuggee
int port = 0;
Process process = null;
while (process == null) {
port = Utils.getFreePort();
String address = String.valueOf(port);
LaunchResult launchResult = launch(address, "Exit0");
process = launchResult.getProcess();
if (launchResult.isBindFailed()) {
System.out.println("Port " + port + " already in use. Trying to restart debuggee with a new one...");
Thread.sleep(100);
} else if (process == null ) {
throw new RuntimeException("Unable to start debugee");
}
}
// Connect to the debuggee and handshake with garbage
Socket s = new Socket("localhost", port);
s.getOutputStream().write("Here's a poke in the eye".getBytes("UTF-8"));
s.close();
// Re-connect and to a partial handshake - don't disconnect
s = new Socket("localhost", port);
s.getOutputStream().write("JDWP-".getBytes("UTF-8"));
// Attach to server debuggee and resume it so it can exit
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map<String, Argument> conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);
// The first event is always a VMStartEvent, and it is always in
// an EventSet by itself. Wait for it.
EventSet evtSet = vm.eventQueue().remove();
for (Event event: evtSet) {
if (event instanceof VMStartEvent) {
break;
}
throw new RuntimeException("Test failed - debuggee did not start properly");
}
vm.eventRequestManager().deleteAllBreakpoints();
vm.resume();
process.waitFor();
}
示例12: main
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
int port = Utils.getFreePort();
String address = String.valueOf(port);
// launch the server debuggee
Process process = launch(address, "Exit0");
if (process == null) {
throw new RuntimeException("Unable to start debugee");
}
// Connect to the debuggee and handshake with garbage
Socket s = new Socket(InetAddress.getLocalHost(), port);
s.getOutputStream().write("Here's a poke in the eye".getBytes("UTF-8"));
s.close();
// Re-connect and to a partial handshake - don't disconnect
s = new Socket(InetAddress.getLocalHost(), port);
s.getOutputStream().write("JDWP-".getBytes("UTF-8"));
// attach to server debuggee and resume it so it can exit
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);
// The first event is always a VMStartEvent, and it is always in
// an EventSet by itself. Wait for it.
EventSet evtSet = vm.eventQueue().remove();
for (Event event: evtSet) {
if (event instanceof VMStartEvent) {
break;
}
throw new RuntimeException("Test failed - debuggee did not start properly");
}
vm.eventRequestManager().deleteAllBreakpoints();
vm.resume();
process.waitFor();
}
示例13: main
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
// find a free port
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
ss.close();
String address = String.valueOf(port);
// launch the server debuggee
Process process = launch(address, "Exit0");
// wait for the debugge to be ready
while (!ready) {
try {
Thread.sleep(1000);
} catch(Exception ee) {
throw ee;
}
}
// Connect to the debuggee and handshake with garbage
Socket s = new Socket(InetAddress.getLocalHost(), port);
s.getOutputStream().write("Here's a poke in the eye".getBytes("UTF-8"));
s.close();
// Re-connect and to a partial handshake - don't disconnect
s = new Socket(InetAddress.getLocalHost(), port);
s.getOutputStream().write("JDWP-".getBytes("UTF-8"));
// attach to server debuggee and resume it so it can exit
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);
// The first event is always a VMStartEvent, and it is always in
// an EventSet by itself. Wait for it.
EventSet evtSet = vm.eventQueue().remove();
for (Event event: evtSet) {
if (event instanceof VMStartEvent) {
break;
}
throw new RuntimeException("Test failed - debuggee did not start properly");
}
vm.eventRequestManager().deleteAllBreakpoints();
vm.resume();
process.waitFor();
}