List of usage examples for java.rmi.server UnicastRemoteObject unexportObject
public static boolean unexportObject(Remote obj, boolean force) throws java.rmi.NoSuchObjectException
From source file:com.rk.grid.cluster.master.Broker.java
/** * @throws RemoteException /*w ww .j a v a 2 s .com*/ * @throws InterruptedException * @throws NoSuchObjectException * */ @SuppressWarnings("unchecked") public void shutDown() throws RemoteException, InterruptedException { for (int ii = 0; ii <= this.processList.size(); ii++) { this.dispatch((IExecutable<V>) IExecutable.POISON); } for (Process process : this.processList) { if (process != null) { int exitValue = process.waitFor(); Broker.log("Exit value for Process " + process + " = " + exitValue); } } try { UnicastRemoteObject.unexportObject(workQueue, true); } catch (NoSuchObjectException e) { e.printStackTrace(); } try { UnicastRemoteObject.unexportObject(resultsHandler, true); } catch (NoSuchObjectException e) { e.printStackTrace(); } try { UnicastRemoteObject.unexportObject(progressMonitor, true); } catch (NoSuchObjectException e) { e.printStackTrace(); } this.rmiServiceExporter.destroy(); Broker.log("Shutting down"); }
From source file:net.sf.mpaxs.spi.computeHost.Host.java
/** * Meldet das RemoteObject ab und schliet danach das Programm. * * @param obj RemoteObject//from ww w .jav a2s. co m */ @Override public void shutdown(Remote obj) { try { Naming.unbind("//" + settings.getLocalIp() + "/" + settings.getName()); UnicastRemoteObject.unexportObject(obj, true); } catch (RemoteException ex) { Logger.getLogger(Host.class.getName()).log(Level.FINE, null, ex); //System.out.println("one"); } catch (NotBoundException ex) { Logger.getLogger(Host.class.getName()).log(Level.FINE, null, ex); //System.out.println("two"); } catch (MalformedURLException ex) { Logger.getLogger(Host.class.getName()).log(Level.FINE, null, ex); //System.out.println("three"); } new Thread() { @Override public void run() { try { sleep(settings.getTimeoutBeforeShutdown()); } catch (InterruptedException ex) { Logger.getLogger(Host.class.getName()).log(Level.SEVERE, null, ex); } System.exit(0); } }.start(); }
From source file:org.ops4j.pax.exam.container.def.internal.PaxRunnerTestContainer.java
/** * {@inheritDoc}/* w w w . ja va 2 s . co m*/ */ public void stop() { LOG.info("Shutting down the test container (Pax Runner)"); try { if (m_started) { if (m_remoteBundleContextClient != null) { m_remoteBundleContextClient.stop(); } if (m_javaRunner != null) { m_javaRunner.waitForExit(); } if (m_registry != null) { try { UnicastRemoteObject.unexportObject(m_registry, true); } catch (NoSuchObjectException e) { LOG.error("Problem in shutting down RMI registry. ", e); } // this is necessary, unfortunately.. RMI wouldn' stop otherwise System.gc(); LOG.info("RMI registry stopped"); m_registry = null; } } } finally { m_semaphore.release(); m_started = false; } }
From source file:org.jgentleframework.integration.remoting.rmi.support.RmiExecutor.java
/** * Unexport object bean service./* w ww .j a v a2s . co m*/ * * @param rmiExporter * the rmi exporter */ public static void unexportObjectBeanService(RmiExporter rmiExporter) { try { UnicastRemoteObject.unexportObject(rmiExporter.getExportedObject(), true); } catch (NoSuchObjectException ex) { if (log.isWarnEnabled()) { log.warn("RMI object for service [" + rmiExporter.getServiceName() + "] isn't exported anymore", ex); } } }
From source file:org.hippoecm.repository.RepositoryServlet.java
@Override public void destroy() { // close repository log.info("Closing repository."); if (repository != null) { repository.close();/*from w w w. j a v a2 s.c o m*/ repository = null; } // done log.info("Repository closed."); if (startRemoteServer) { // unbinding from registry String name = null; try { name = new RepositoryUrl(bindingAddress).getName(); log.info("Unbinding '" + name + "' from registry."); registry.unbind(name); } catch (RemoteException | NotBoundException e) { log.error("Error during unbinding '" + name + "': " + e.getMessage()); } catch (MalformedURLException e) { log.error("MalformedURLException while parsing '" + bindingAddress + "': " + e.getMessage()); } // unexporting from registry try { log.info("Unexporting rmi repository: " + bindingAddress); UnicastRemoteObject.unexportObject(rmiRepository, true); } catch (NoSuchObjectException e) { log.error("Error during rmi shutdown for address: " + bindingAddress, e); } // shutdown registry if (registryIsEmbedded) { try { log.info("Closing rmiregistry: " + bindingAddress); UnicastRemoteObject.unexportObject(registry, true); } catch (NoSuchObjectException e) { log.error("Error during rmi shutdown for address: " + bindingAddress, e); } } // force the distributed GC to fire, otherwise in tomcat with embedded // rmi registry the process won't end // this procedure is necessary specifically for Tomcat log.info("Repository terminated, waiting for garbage to clear"); Thread garbageClearThread = new Thread("garbage clearer") { public void run() { for (int i = 0; i < 5; i++) { try { Thread.sleep(3000); System.gc(); } catch (InterruptedException ignored) { } } } }; garbageClearThread.setDaemon(true); garbageClearThread.start(); } if (repositoryService != null) { HippoServiceRegistry.unregisterService(repositoryService, RepositoryService.class); } if (repositoryClusterService != null) { HippoServiceRegistry.unregisterService(repositoryClusterService, RepositoryClusterService.class); } HippoServiceRegistry.unregisterService(listener, HippoEventBus.class); HippoServiceRegistry.unregisterService(hippoEventBus, HippoEventBus.class); hippoEventBus.destroy(); }
From source file:org.springframework.remoting.rmi.RmiRegistryFactoryBean.java
/** * Unexport the RMI registry on bean factory shutdown, * provided that this bean actually created a registry. *//* w w w . ja v a2 s . c om*/ @Override public void destroy() throws RemoteException { if (this.created) { logger.info("Unexporting RMI registry"); UnicastRemoteObject.unexportObject(this.registry, true); } }
From source file:edu.umd.lib.servlets.permissions.PermissionsServlet.java
@Override public void destroy() { // close repository log.info("Closing repository."); if (repository != null) { repository.close();/* www . ja va 2s . c o m*/ repository = null; } // done log.info("Repository closed."); if (startRemoteServer) { // unbinding from registry String name = null; try { name = new RepositoryUrl(bindingAddress).getName(); log.info("Unbinding '" + name + "' from registry."); registry.unbind(name); } catch (RemoteException e) { log.error("Error during unbinding '" + name + "': " + e.getMessage()); } catch (NotBoundException e) { log.error("Error during unbinding '" + name + "': " + e.getMessage()); } catch (MalformedURLException e) { log.error("MalformedURLException while parsing '" + bindingAddress + "': " + e.getMessage()); } // unexporting from registry try { log.info("Unexporting rmi repository: " + bindingAddress); UnicastRemoteObject.unexportObject(rmiRepository, true); } catch (NoSuchObjectException e) { log.error("Error during rmi shutdown for address: " + bindingAddress, e); } // shutdown registry if (registryIsEmbedded) { try { log.info("Closing rmiregistry: " + bindingAddress); UnicastRemoteObject.unexportObject(registry, true); } catch (NoSuchObjectException e) { log.error("Error during rmi shutdown for address: " + bindingAddress, e); } } // force the distributed GC to fire, otherwise in tomcat with embedded // rmi registry the process won't end // this procedure is necessary specifically for Tomcat log.info("Repository terminated, waiting for garbage to clear"); Thread garbageClearThread = new Thread("garbage clearer") { @Override public void run() { for (int i = 0; i < 5; i++) { try { Thread.sleep(3000); System.gc(); } catch (InterruptedException ignored) { } } } }; garbageClearThread.setDaemon(true); garbageClearThread.start(); } if (repositoryService != null) { HippoServiceRegistry.unregisterService(repositoryService, RepositoryService.class); } if (repositoryClusterService != null) { HippoServiceRegistry.unregisterService(repositoryClusterService, RepositoryClusterService.class); } }
From source file:net.sf.ehcache.distribution.RMICacheManagerPeerListener.java
/** * Stop the rmiregistry if it was started by this class. * * @throws RemoteException// w ww . jav a2 s. c o m */ protected void stopRegistry() throws RemoteException { if (registryCreated) { // the unexportObject call must be done on the Registry object returned // by createRegistry not by getRegistry, a NoSuchObjectException is // thrown otherwise boolean success = UnicastRemoteObject.unexportObject(registry, true); if (success) { LOG.debug("rmiregistry unexported."); } else { LOG.warn("Could not unexport rmiregistry."); } } }
From source file:org.quartz.core.QuartzScheduler.java
/** * <p>//from w w w. j a v a 2 s . c om * Un-bind the scheduler from an RMI registry. * </p> */ private void unBind() throws RemoteException { String host = resources.getRMIRegistryHost(); // don't un-export if we're not configured to do so... if (host == null || host.length() == 0) { return; } Registry registry = LocateRegistry.getRegistry(resources.getRMIRegistryHost(), resources.getRMIRegistryPort()); String bindName = resources.getRMIBindName(); try { registry.unbind(bindName); UnicastRemoteObject.unexportObject(this, true); } catch (java.rmi.NotBoundException nbe) { } getLog().info("Scheduler un-bound from name '" + bindName + "' in RMI registry"); }
From source file:org.wso2.carbon.container.CarbonTestContainer.java
/** * Stops the regression container./*from w ww.j a va 2 s . c o m*/ * * @return this container object for api */ @Override public synchronized TestContainer stop() { logger.debug("Shutting down the test container."); try { if (started) { target.stop(); RemoteBundleContextClient remoteBundleContextClient = target.getClientRBC(); if (remoteBundleContextClient != null) { remoteBundleContextClient.stop(); } runner.shutdown(); try { UnicastRemoteObject.unexportObject(registry, true); } catch (NoSuchObjectException exc) { throw new TestContainerException(exc); } } else { throw new TestContainerException("Container never started."); } } finally { started = false; target = null; if (shouldDeleteRuntime()) { system.clear(); try { FileUtils.forceDelete(targetDirectory.toFile()); } catch (IOException e) { forceCleanup(); } } } return this; }