/** * This utility method helps to start a new JPDA debugger session. * Its implementation use {@link ListeningDICookie} and * {@link org.netbeans.api.debugger.DebuggerManager#getDebuggerManager}. * It's identical to {@link #startListening(com.sun.jdi.connect.ListeningConnector, java.util.Map, java.lang.Object[])}, * but returns the started engines. * * @param connector The listening connector * @param args The arguments * @param services The additional services, which are added to the debugger session lookup.<br/> * See {@link #listen(com.sun.jdi.connect.ListeningConnector, java.util.Map, java.lang.Object[])} for a more detailed description of this argument. * @return A non-empty array of started engines (since 2.26) * @throws DebuggerStartException when {@link org.netbeans.api.debugger.DebuggerManager#startDebugging} * returns an empty array * @since 2.26 */ public static DebuggerEngine[] startListeningAndGetEngines ( ListeningConnector connector, Map<String, ? extends Argument> args, Object[] services ) throws DebuggerStartException { Object[] s = new Object [services.length + 1]; System.arraycopy (services, 0, s, 1, services.length); s [0] = ListeningDICookie.create ( connector, args ); DebuggerEngine[] es = DebuggerManager.getDebuggerManager (). startDebugging ( DebuggerInfo.create ( ListeningDICookie.ID, s ) ); if (es.length == 0) { throw new DebuggerStartException( NbBundle.getMessage(JPDADebugger.class, "MSG_NO_DEBUGGER")); } return es; }
private static ListeningConnector findListeningConnector (String s) { Iterator iter = Bootstrap.virtualMachineManager (). listeningConnectors ().iterator (); while (iter.hasNext ()) { ListeningConnector ac = (ListeningConnector) iter.next (); if (ac.transport() != null && ac.transport ().name ().toLowerCase ().indexOf (s) > -1) return ac; } return null; }
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); } } }
/** * This utility method helps to start a new JPDA debugger session. * Its implementation use {@link ListeningDICookie} and * {@link org.netbeans.api.debugger.DebuggerManager#getDebuggerManager}. * * @param connector The listening connector * @param args The arguments * @param services The additional services, which are added to the debugger session lookup.<br/> * It is expected, that one element in the services array is a {@link Map} with following setup properties:<br/> * <lu> * <li><code>name</code> with the value being the session name as String,</li> * <li><code>sourcepath</code> with the {@link ClassPath} value containing class path of sources used by debugger,</li> * <li><code>jdksources</code> with the {@link ClassPath} value containing class path of platform sources,</li> * <li><code>listeningCP</code> optional String representation of source class path which is in compile-on-save mode, which we listen on for artifacts changes,</li> * <li><code>baseDir</code> with the debugging project's base directory as {@link File}.</li> * </lu> */ public static JPDADebugger listen ( ListeningConnector connector, Map<String, ? extends Argument> args, Object[] services ) throws DebuggerStartException { Object[] s = new Object [services.length + 1]; System.arraycopy (services, 0, s, 1, services.length); s [0] = ListeningDICookie.create ( connector, args ); DebuggerEngine[] es = DebuggerManager.getDebuggerManager (). startDebugging ( DebuggerInfo.create ( ListeningDICookie.ID, s ) ); int i, k = es.length; for (i = 0; i < k; i++) { JPDADebugger d = es[i].lookupFirst(null, JPDADebugger.class); if (d == null) { continue; } d.waitRunning (); return d; } throw new DebuggerStartException( NbBundle.getMessage(JPDADebugger.class, "MSG_NO_DEBUGGER")); }
private ListeningDICookie ( ListeningConnector listeningConnector, Map<String, ? extends Argument> args ) { this.listeningConnector = listeningConnector; this.args = args; }
/** * Creates a new instance of ListeningDICookie for given parameters. * * @param listeningConnector a instance of ListeningConnector * @param args arguments to be used * @return a new instance of ListeningDICookie for given parameters */ public static ListeningDICookie create ( ListeningConnector listeningConnector, Map<String, ? extends Argument> args ) { return new ListeningDICookie ( listeningConnector, args ); }
private static Map<String, ? extends Argument> getArgs ( ListeningConnector listeningConnector, int portNumber ) { Map<String, ? extends Argument> args = listeningConnector.defaultArguments (); args.get ("port").setValue ("" + portNumber); return args; }
private static Map<String, ? extends Argument> getArgs ( ListeningConnector listeningConnector, String name ) { Map<String, ? extends Argument> args = listeningConnector.defaultArguments (); args.get ("name").setValue (name); return args; }
/** Searching for a connector in given collection. * @param name - name of the connector * @param connectors * @return the connector or null */ private static ListeningConnector findConnector(String name, final Collection<ListeningConnector> connectors) { assert name != null; for (ListeningConnector c : connectors) { if (name.equals(c.name())) { return c; } } return null; }
private static ListeningConnector makePlatformConnector() { Class connectorClass = null; try { connectorClass = Class.forName(SHAREDMEM_LISTENING_CONN); } catch (ClassNotFoundException cnfe) { } if (connectorClass == null) { throw new RuntimeException("can not load class: " + SHAREDMEM_LISTENING_CONN); } try { return (ListeningConnector) connectorClass.newInstance(); } catch (Exception exp) { throw new RuntimeException(exp); } }
private static ListeningConnector makePlatformConnector() { Class connectorClass = null; try { connectorClass = Class.forName(SOCKET_LISTENING_CONN); } catch (ClassNotFoundException cnfe) {} if (connectorClass == null) { throw new RuntimeException("can not load class: " + SOCKET_LISTENING_CONN); } try { return (ListeningConnector) connectorClass.newInstance(); } catch (Exception exp) { throw new RuntimeException(exp); } }
@Test public void testF3Connectors() { LaunchingConnector conn = F3Bootstrap.virtualMachineManager().defaultConnector(); Assert.assertEquals("org.f3.jdi.connect.F3LaunchingConnector", conn.name()); F3LaunchingConnector conn1 = new F3LaunchingConnector(); Assert.assertEquals("org.f3.jdi.connect.F3LaunchingConnector", conn1.name()); Assert.assertEquals(true, conn1 instanceof LaunchingConnector); F3ProcessAttachingConnector conn2 = new F3ProcessAttachingConnector(); Assert.assertEquals("org.f3.jdi.connect.F3ProcessAttachingConnector", conn2.name()); Assert.assertEquals(true, conn2 instanceof AttachingConnector); F3RawLaunchingConnector conn3 = new F3RawLaunchingConnector(); Assert.assertEquals("org.f3.jdi.connect.F3RawLaunchingConnector", conn3.name()); Assert.assertEquals(true, conn3 instanceof LaunchingConnector); F3SocketAttachingConnector conn4 = new F3SocketAttachingConnector(); Assert.assertEquals("org.f3.jdi.connect.F3SocketAttachingConnector", conn4.name()); Assert.assertEquals(true, conn4 instanceof AttachingConnector); F3SocketListeningConnector conn5 = new F3SocketListeningConnector(); Assert.assertEquals("org.f3.jdi.connect.F3SocketListeningConnector", conn5.name()); Assert.assertEquals(true, conn5 instanceof ListeningConnector); // Conditionally adding F3 shared mem connectors - because underlying platform shared // memory connectors are not available on all platforms if (F3SharedMemoryAttachingConnector.isAvailable()) { F3SharedMemoryAttachingConnector conn6 = new F3SharedMemoryAttachingConnector(); Assert.assertEquals("org.f3.jdi.connect.F3SharedMemoryAttachingConnector", conn6.name()); Assert.assertEquals(true, conn6 instanceof AttachingConnector); } if (F3SharedMemoryListeningConnector.isAvailable()) { F3SharedMemoryListeningConnector conn7 = new F3SharedMemoryListeningConnector(); Assert.assertEquals("org.f3.jdi.connect.F3SharedMemoryListeningConnector", conn7.name()); Assert.assertEquals(true, conn7 instanceof ListeningConnector); } }
private ListeningConnector getConnector( ) { List connectors = Bootstrap.virtualMachineManager( ) .listeningConnectors( ); for ( int i = 0; i < connectors.size( ); i++ ) { ListeningConnector c = (ListeningConnector) connectors.get( i ); if ( "com.sun.jdi.SocketListen".equals( c.name( ) ) ) //$NON-NLS-1$ return c; } return null; }
protected ListeningConnector getConnector() { List connectors = Bootstrap.virtualMachineManager() .listeningConnectors(); for (int i = 0; i < connectors.size(); i++) { ListeningConnector c = (ListeningConnector) connectors.get(i); if ("com.sun.jdi.SocketListen".equals(c.name())) //$NON-NLS-1$ return c; } return null; }
public WaitForConnectionJob(ListeningConnector connector, Map<String, Connector.Argument> arguments) { super(getLabel()); fConnector = connector; fArguments = arguments; }
public F3SharedMemoryListeningConnector(ListeningConnector underlying) { super(underlying); }
@Override protected ListeningConnector underlying() { return (ListeningConnector) super.underlying(); }
public F3SocketListeningConnector(ListeningConnector underlying) { super(underlying); }
/** * This utility method helps to start a new JPDA debugger session. * Its implementation use {@link ListeningDICookie} and * {@link org.netbeans.api.debugger.DebuggerManager#getDebuggerManager}. * * @param connector The listening connector * @param args The arguments * @param services The additional services, which are added to the debugger session lookup.<br/> * See {@link #listen(com.sun.jdi.connect.ListeningConnector, java.util.Map, java.lang.Object[])} for a more detailed description of this argument. * @throws DebuggerStartException when {@link org.netbeans.api.debugger.DebuggerManager#startDebugging} * returns an empty array */ public static void startListening ( ListeningConnector connector, Map<String, ? extends Argument> args, Object[] services ) throws DebuggerStartException { startListeningAndGetEngines(connector, args, services); }
/** * Returns instance of ListeningConnector. * * @return instance of ListeningConnector */ public ListeningConnector getListeningConnector () { return listeningConnector; }
/** * Returns the list of known {@link ListeningConnector} objects. * Any of the returned objects can be used to listen for a * connection initiated by a target VM * and create a {@link VirtualMachine} mirror for it. * * @return a list of {@link ListeningConnector} objects. */ List<ListeningConnector> listeningConnectors();
/** * Return the socket transport listening connector * * @return the new {@link ListeningConnector} * @exception CoreException * if unable to locate the connector */ private static ListeningConnector getListeningConnector() { return new SocketListeningMultiConnectorImpl((VirtualMachineManagerImpl) Bootstrap.virtualMachineManager()); }
/** * Constructs a runnable to connect to a VM via the given connector with * the given connection arguments. * * @param connector * @param map */ public ConnectRunnable( ListeningConnector connector, Map map ) { fConnector = connector; fConnectionMap = map; }
/** * Constructs a runnable to connect to a VM via the given connector with the * given connection arguments. * * @param connector * the VM connector. * @param map * the map of arguments */ public ConnectRunnable(ListeningConnector connector, Map map) { this.connector = connector; this.connectionMap = map; }