/** * Return the capabilities of this transport service */ public Capabilities capabilities() { return new TransportService.Capabilities() { public boolean supportsMultipleConnections() { return true; } public boolean supportsAttachTimeout() { return true; } public boolean supportsAcceptTimeout() { return true; } public boolean supportsHandshakeTimeout() { return true; } }; }
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); } }
public static TransportServiceWrapper getTransportService(boolean forceSocketTransport) throws ExecutionException { TransportServiceWrapper transport; try { try { if (forceSocketTransport) { transport = new TransportServiceWrapper((Class<? extends TransportService>)Class.forName(SOCKET_TRANSPORT_CLASS)); } else { transport = new TransportServiceWrapper((Class<? extends TransportService>)Class.forName(SHMEM_TRANSPORT_CLASS)); } } catch (UnsatisfiedLinkError ignored) { transport = new TransportServiceWrapper((Class<? extends TransportService>)Class.forName(SOCKET_TRANSPORT_CLASS)); } } catch (Exception e) { throw new ExecutionException(e.getClass().getName() + " : " + e.getMessage()); } return transport; }
public SimpleLaunchingConnector() { try { Class c = Class.forName("com.sun.tools.jdi.SocketTransportService"); ts = (TransportService)c.newInstance(); } catch (Exception x) { throw new Error(x); } }
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); }
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()); }
Helper(String[] commandArray, String address, TransportService.ListenKey listenKey, TransportService ts) { this.commandArray = commandArray; this.address = address; this.listenKey = listenKey; this.ts = ts; }
/** * Initialize a new instance of this connector. The connector * encapsulates a transport service, has a "timeout" connector argument, * and optionally an "address" connector argument. */ private GenericListeningConnector(TransportService ts, boolean addAddressArgument) { transportService = ts; transport = new Transport() { public String name() { return transportService.name(); } }; if (addAddressArgument) { addStringArgument( ARG_ADDRESS, getString("generic_listening.address.label"), getString("generic_listening.address"), "", false); } addIntegerArgument( ARG_TIMEOUT, getString("generic_listening.timeout.label"), getString("generic_listening.timeout"), "", false, 0, Integer.MAX_VALUE); listenMap = new HashMap<Map<String, ? extends Connector.Argument>, TransportService.ListenKey>(10); }
public String startListening(String address, Map<String,? extends Connector.Argument> args) throws IOException, IllegalConnectorArgumentsException { TransportService.ListenKey listener = listenMap.get(args); if (listener != null) { throw new IllegalConnectorArgumentsException("Already listening", new ArrayList<>(args.keySet())); } listener = transportService.startListening(address); listenMap.put(args, listener); return listener.address(); }
public void stopListening(Map<String, ? extends Connector.Argument> args) throws IOException, IllegalConnectorArgumentsException { TransportService.ListenKey listener = listenMap.get(args); if (listener == null) { throw new IllegalConnectorArgumentsException("Not listening", new ArrayList<>(args.keySet())); } transportService.stopListening(listener); listenMap.remove(args); }
private GenericAttachingConnector(TransportService ts, boolean addAddressArgument) { transportService = ts; transport = new Transport() { public String name() { // delegate name to the transport service return transportService.name(); } }; if (addAddressArgument) { addStringArgument( ARG_ADDRESS, getString("generic_attaching.address.label"), getString("generic_attaching.address"), "", true); } addIntegerArgument( ARG_TIMEOUT, getString("generic_attaching.timeout.label"), getString("generic_attaching.timeout"), "", false, 0, Integer.MAX_VALUE); }
public SimpleLaunchingConnector() { try { Class<?> c = Class.forName("com.sun.tools.jdi.SocketTransportService"); ts = (TransportService)c.newInstance(); } catch (Exception x) { throw new Error(x); } }
private TransportServiceWrapper(Class<? extends TransportService> delegateClass) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { myDelegateClass = delegateClass; final Constructor constructor = delegateClass.getDeclaredConstructor(ArrayUtil.EMPTY_CLASS_ARRAY); constructor.setAccessible(true); myTransport = (TransportService)constructor.newInstance(ArrayUtil.EMPTY_OBJECT_ARRAY); }
public TransportService transportService() { return transportService; }
TransportService transportService() { return transportService; }
public static GenericAttachingConnector create(TransportService ts) { return new GenericAttachingConnector(ts, true); }
public TransportService.ListenKey startListening() throws IOException { return myTransport.startListening(); }
public TransportService.ListenKey startListening(String address) throws IOException { return myTransport.startListening(address); }
public void stopListening(final TransportService.ListenKey address) throws IOException { myTransport.stopListening(address); }
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; String arch = System.getProperty("os.arch"); String osname = System.getProperty("os.name"); if (osname.equals("SunOS") && arch.equals("sparcv9")) { exe += "sparcv9/java"; } else if (osname.equals("SunOS") && arch.equals("amd64")) { exe += "amd64/java"; } else { exe += "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); }