Example usage for java.rmi Naming unbind

List of usage examples for java.rmi Naming unbind

Introduction

In this page you can find the example usage for java.rmi Naming unbind.

Prototype

public static void unbind(String name)
        throws RemoteException, NotBoundException, java.net.MalformedURLException 

Source Link

Document

Destroys the binding for the specified name that is associated with a remote object.

Usage

From source file:com.codeasylum.stress.api.OuroborosImpl.java

@Override
protected void finalize() throws RemoteException, MalformedURLException, NotBoundException {

    Naming.unbind(Ouroboros.class.getName());
}

From source file:gridool.util.remoting.RemoteBase.java

protected void unbind() {
    try {/*from   w  w  w .ja  va 2  s. c om*/
        Naming.unbind(endpointUrl);
    } catch (Exception e) {
        LOG.debug("unbind failed", e);
    }
}

From source file:com.xpn.xwiki.plugin.lucene.IndexSearchServer.java

/**
* Restart the search server, to use the updated index.
*///from   w  ww  . java  2  s.c om
public void resetServer() {
    try {

        closeSearcher(this.searchables);
        this.multiSearcher.close();
        this.multiImpl.close();

        this.searchables = createSearchers(this.indexDirs);

        this.multiSearcher = new MultiSearcher(this.searchables);

        this.multiImpl = new RemoteSearchable(this.multiSearcher);

        //Naming.unbind("//"+this.hostname+":"+this.port+"/XWiki_LuceneMultiSearch");
        Naming.unbind("//" + this.hostname + ":" + this.port + "/" + this.serviceName);
        Naming.rebind("//" + this.hostname + ":" + this.port + "/" + this.serviceName, multiImpl);

    } catch (Exception e) {
        System.out.println(e.toString());
    }

}

From source file:net.sf.mpaxs.spi.computeHost.Host.java

/**
 * Meldet das RemoteObject ab und schliet danach das Programm.
 *
 * @param obj RemoteObject//  w ww  .j  a va 2s.  com
 */
@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:net.sf.ehcache.distribution.RMICacheManagerPeerListener.java

/**
 * Unbinds an RMICachePeer and unexports it.
 * <p/>/*w w w  . j a  va 2  s  .  c om*/
 * We unbind from the registry first before unexporting.
 * Unbinding first removes the very small possibility of a client
 * getting the object from the registry while we are trying to unexport it.
 * <p/>
 * This method may take up to 4 seconds to complete, if we are having trouble
 * unexporting the peer.
 *
 * @param rmiCachePeer the bound and exported cache peer
 * @throws Exception
 */
protected void unbind(RMICachePeer rmiCachePeer) throws Exception {
    String url = rmiCachePeer.getUrl();
    try {
        Naming.unbind(url);
    } catch (NotBoundException e) {
        LOG.warn(url + " not bound therefore not unbinding.");
    }
    // Try to gracefully unexport before forcing it.
    boolean unexported = UnicastRemoteObject.unexportObject(rmiCachePeer, false);
    for (int count = 1; (count < NAMING_UNBIND_MAX_RETRIES) && !unexported; count++) {
        try {
            Thread.sleep(NAMING_UNBIND_RETRY_INTERVAL);
        } catch (InterruptedException ie) {
            // break out of the unexportObject loop
            break;
        }
        unexported = UnicastRemoteObject.unexportObject(rmiCachePeer, false);
    }

    // If we still haven't been able to unexport, force the unexport
    // as a last resort.
    if (!unexported) {
        if (!UnicastRemoteObject.unexportObject(rmiCachePeer, true)) {
            LOG.warn("Unable to unexport rmiCachePeer: " + rmiCachePeer.getUrl() + ".  Skipping.");
        }
    }
}

From source file:org.apache.jackrabbit.j2ee.RepositoryStartupServlet.java

/**
 * Unregisters the repository from the RMI registry, if it has previously
 * been registered./*  w w w.  ja  v  a2 s .com*/
 */
private void unregisterRMI() {
    if (rmiRepository != null) {
        // Forcibly unexport the repository;
        try {
            UnicastRemoteObject.unexportObject(rmiRepository, true);
        } catch (NoSuchObjectException e) {
            log.warn("Odd, the RMI repository was not exported", e);
        }
        // drop strong reference to remote repository
        rmiRepository = null;

        // unregister repository
        try {
            Naming.unbind(config.getRmiConfig().getRmiUri());
        } catch (Exception e) {
            log("Error while unbinding repository from JNDI: " + e);
        }
    }

    if (rmiRegistry != null) {
        try {
            UnicastRemoteObject.unexportObject(rmiRegistry, true);
        } catch (NoSuchObjectException e) {
            log.warn("Odd, the RMI registry was not exported", e);
        }
        rmiRegistry = null;
    }
}

From source file:org.apache.jcs.auxiliary.remote.server.RemoteCacheServerFactory.java

/**
 * Unbinds the remote server./*from   w  w w.java2  s  . co  m*/
 * <p>
 * @param host
 * @param port
 * @exception IOException
 */
static void shutdownImpl(String host, int port) throws IOException {
    if (remoteCacheServer == null) {
        return;
    }
    synchronized (RemoteCacheServer.class) {
        if (remoteCacheServer == null) {
            return;
        }
        log.info("Unbinding host=" + host + ", port=" + port + ", serviceName=" + serviceName);
        try {
            Naming.unbind("//" + host + ":" + port + "/" + serviceName);
        } catch (MalformedURLException ex) {
            // impossible case.
            throw new IllegalArgumentException(
                    ex.getMessage() + "; host=" + host + ", port=" + port + ", serviceName=" + serviceName);
        } catch (NotBoundException ex) {
            // ignore.
        }
        remoteCacheServer.release();
        remoteCacheServer = null;
        // TODO: safer exit ?
        try {
            Thread.sleep(2000);
        } catch (InterruptedException ex) {
            // swallow
        }
        System.exit(0);
    }
}

From source file:org.jahia.services.content.JCRStoreProvider.java

protected void rmiUnbind() {
    if (rmibind != null) {
        try {//from  ww w  .ja va  2 s . c  o  m
            Naming.unbind(rmibind);
        } catch (Exception e) {
            logger.warn("Unable to unbind the JCR repository in RMI");
        }
    }
}

From source file:se.trixon.jota.server.Server.java

@Override
public void shutdown() throws RemoteException {
    Xlog.timedOut("shutdown");

    notifyClientsShutdown();/*ww  w.j av a2  s.  com*/

    try {
        Naming.unbind(mRmiNameServer);
        Jota.exit(0);
    } catch (NotBoundException | MalformedURLException ex) {
        Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:xbird.server.ServerBase.java

protected void unbind() {
    try {//  ww w .j  av a2 s .  c om
        if (_boundedContext != null) {
            _boundedContext.unbind(_bindUrl);
        } else {
            Naming.unbind(_bindUrl);
        }
    } catch (Exception e) {
        LOG.debug("Unbind failed!", e);
    }
}