public REMProxyFactoryRegistry(REMRegistryController registryController, String name) { super(REMOTE_REGISTRY_TYPE_ID); fRegistryController = registryController; fRegistryKey = fRegistryController.registerRegistry(this); // Register the registry with the plugin. fName = name; // Get the waitRegistrationThread started before we actually launch remote vm so // that it is waiting when the callback comes in. synchronized (this) { waitRegistrationThread = new WaitForRegistrationThread(); waitRegistrationThread.start(); // Now we will wait until the registration callback has been done. The thread will // signal us when that is done. This is so that we don't continue on and let // a work connection be requested before we even got a chance to start waiting // for the registration. while (true) { try { wait(); break; } catch (InterruptedException e) { } } ; } }
protected void registryTerminated(boolean wait) { if (processListener != null) { // Remove listener cause we are now going to terminate process and don't want premature // terminate notice. // Sometimes in shutdown we are called and the debug plugin may of already been shutdown. In // that case the db // will be null and there is nothing remove listener from. DebugPlugin db = DebugPlugin.getDefault(); if (db != null) db.removeDebugEventListener(processListener); processListener = null; } Job tjob = null; if (waitRegistrationThread != null) { synchronized (waitRegistrationThread) { // Still waiting. close it out. WaitForRegistrationThread wThread = waitRegistrationThread; waitRegistrationThread = null; wThread.notifyAll(); } } if (fServerPort != 0) { IREMConnection closeCon = null; // The connection we will use to close the remote vm. synchronized (fConnectionPool) { // Now we walk through all of the free connections and close them properly. Iterator itr = fConnectionPool.iterator(); if (itr.hasNext()) closeCon = (IREMConnection) itr.next(); while (itr.hasNext()) { IREMConnection con = (IREMConnection) itr.next(); con.close(); } } // Now we terminate the server. if (closeCon == null) try { closeCon = getFreeConnection(); // There weren't any free connections, so get a new one so that // we can close it. } catch (IllegalStateException e) { // Do nothing, don't want to stop termination just because we can't get a connection. } if (closeCon != null) { closeCon .terminateServer(); // We got a connection to terminate (process may of terminated // early, so we would not have a conn then). } fConnectionPool.clear(); fServerPort = 0; if (fProcess != null && !fRegistryController.inShutDown()) { tjob = new TerminateProcess(fProcess); tjob.setSystem(true); tjob.schedule(); fProcess = null; } } if (fCallbackServer != null) { fCallbackServer.requestShutdown(); fCallbackServer = null; } fConnectionPool.clear(); fRegistryController.deregisterRegistry(fRegistryKey); // De-register this registry. if (wait && tjob != null) { try { tjob.join(); } catch (InterruptedException e) { // It timed out, so we'll just go on. } } }