Example usage for java.rmi.server UnicastRemoteObject unexportObject

List of usage examples for java.rmi.server UnicastRemoteObject unexportObject

Introduction

In this page you can find the example usage for java.rmi.server UnicastRemoteObject unexportObject.

Prototype

public static boolean unexportObject(Remote obj, boolean force) throws java.rmi.NoSuchObjectException 

Source Link

Document

Removes the remote object, obj, from the RMI runtime.

Usage

From source file:org.apache.ode.jca.server.rmi.RmiTransportServerImpl.java

void unexport(Remote remote) {
    try {/*from   w w w  .j  a  v  a 2s. c  o  m*/
        UnicastRemoteObject.unexportObject(remote, false);
    } catch (Exception e) {
        // ignore
    }
}

From source file:com.healthmarketscience.rmiio.RemoteIteratorTest.java

public static List<List<TestObject>> mainTest(final boolean sendEmptyList, final boolean doAbort,
        final boolean noDelayAbort, final List<Throwable> clientExceptions,
        final List<AccumulateRemoteStreamMonitor<?>> monitors) throws Exception {

    ObjectServer server = new ObjectServer();
    final RemoteObjectServer stub = (RemoteObjectServer) RemoteStreamServerTest
            .simulateRemote(UnicastRemoteObject.exportObject(server, 0));
    LOG.debug("Server ready");

    LOG.debug("Sleeping 3000 ms...");
    Thread.sleep(3000);/* w ww .j  a v a 2  s .  co m*/

    LOG.debug("Running tests");
    Thread clientThread = new Thread(new Runnable() {
        public void run() {
            clientExceptions.addAll(ObjectClient.main(stub, sendEmptyList, doAbort, noDelayAbort, monitors));
        }
    });
    clientThread.start();
    clientThread.join();

    LOG.debug("Unexporting server");
    UnicastRemoteObject.unexportObject(server, true);

    return server._recvdObjectLists;
}

From source file:org.apache.synapse.commons.util.RMIRegistryController.java

/**
 * Helper method to remove a RMI registry instance
 *
 * @param key      The port of the RMI registry to be removed
 * @param registry Registry instance/*from  ww w  . j a  v  a 2s .  c  om*/
 */
private void removeRegistry(String key, Registry registry) {

    if (registry != null) {
        synchronized (registriesCache) {
            try {
                log.info("Removing the RMI registry bound to port : " + key);
                UnicastRemoteObject.unexportObject(registry, true);
                registriesCache.remove(key);
            } catch (NoSuchObjectException e) {
                String msg = "Error when stopping local registry(RMI)";
                handleException(msg, e);
            }
        }

    }

}

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

public void shutdown(boolean forceExit) throws RemoteException {
    try {//from w  ww  . ja v  a2  s .  c o  m
        UnicastRemoteObject.unexportObject(this, true);
    } catch (NoSuchObjectException e) {
        LOG.warn("object is not registered: " + ObjectUtils.identityToString(this), e);
    }
    unbind();
    if (forceExit) {
        System.exit(0);
    }
}

From source file:net.sqs2.omr.app.MarkReaderControllerImpl.java

private void unexportSessionService() {
    try {/*from  ww w  .ja va 2  s .  c om*/
        SessionServiceImpl sessionService = SessionServiceImpl.getInstance();
        if (sessionService != null) {
            sessionService.close();
            UnicastRemoteObject.unexportObject(sessionService, false);
        }
    } catch (RemoteException ignore) {
    }
}

From source file:de.tudarmstadt.lt.lm.app.StartRMI.java

void exit() {
    LOG.info("Exiting.");

    String[] rmi_bounded_apps = new String[0];
    try {/*from w  w w . j a  v a  2 s  .  co  m*/
        rmi_bounded_apps = _registry.list();
        if (rmi_bounded_apps.length == 0) {
            UnicastRemoteObject.unexportObject(_registry, true);
            LOG.info("Stopped RMI server.");
            System.exit(0);
        }
    } catch (Exception e) {
        /* */}

    String input_line = null;
    while ((input_line = readInput(String.format(
            "App serves as RMI server for the following apps: %s.%nType 'y' if you really want to quit serving RMI, else type 'n': %n$> ",
            Arrays.toString(rmi_bounded_apps)))) == null)
        ;
    if ("y".equals(input_line.toLowerCase())) {
        try {
            UnicastRemoteObject.unexportObject(_registry, true);
        } catch (NoSuchObjectException e) {
            /* handle silently */ }
        LOG.info("Stopped RMI server.");
        System.exit(0);
    } else
        return;

    System.exit(0);
}

From source file:net.sf.ehcache.distribution.JNDIRMICacheManagerPeerListener.java

/**
 * Disposes an individual RMICachePeer. This consists of:
 * <ol>/*w w w  .j a  va2  s  .co m*/
 * <li>Unbinding the peer from the naming service
 * <li>Unexporting the peer
 * </ol>
 *
 * @param rmiCachePeer  the cache peer to dispose of
 * @throws Exception thrown if something goes wrong
 */
protected void disposeRMICachePeer(RMICachePeer rmiCachePeer) throws Exception {
    getInitialContext().unbind(rmiCachePeer.getName());
    UnicastRemoteObject.unexportObject(rmiCachePeer, false);
}

From source file:org.apache.jcs.auxiliary.remote.RemoteCacheListener.java

/**
 * Deregisters itself.//from   w  w  w  .j  a  v a 2 s  .  c  om
 * <p>
 * @throws IOException
 */
public synchronized void dispose() throws IOException {
    if (!disposed) {
        if (log.isInfoEnabled()) {
            log.info("Unexporting listener.");
        }
        try {
            UnicastRemoteObject.unexportObject(this, true);
        } catch (RemoteException ex) {
            log.error("Problem unexporting the listener.", ex);
            throw new IllegalStateException(ex.getMessage());
        }
        disposed = true;
    }
}

From source file:org.sybila.parasim.computation.lifecycle.impl.distributed.DistributedMemoryExecutorImpl.java

@Override
public <M extends Mergeable<M>> Future<M> submit(Computation<M> computation) {
    // init context
    Context context = getContext().context(ComputationScope.class);
    UUID computationId = UUID.randomUUID();

    // prepare status
    MutableStatus status = new SimpleStatus();
    RemoteMutableStatus remoteStatus = new RemoteMutableStatusWrapper(status);
    RemoteMutableStatus exportedRemoteStatus = null;
    Map<UUID, RemoteDescriptor> remoteDescriptors = new HashMap<>(remoteExecutors.size());

    try {/*  w  w w  .  ja  va  2 s  .co  m*/
        exportedRemoteStatus = (RemoteMutableStatus) UnicastRemoteObject.exportObject(remoteStatus);
        // start the computation on slave nodes
        for (RemoteExecutor executor : remoteExecutors) {
            executor.startComputation(computation.getClass(), exportedRemoteStatus, computationId);
            remoteDescriptors.put(executor.getId(), new RemoteDescriptor(executor.getHost(),
                    executor.getQueue(computationId), executor.getId()));
        }
        // prepare services
        ComputationFuture<M> future = new ComputationFuture<>(computationId, context, status);
        DistributedMemoryMucker mucker = new DistributedMemoryMucker(
                context.resolve(ComputationLifecycleConfiguration.class, Default.class), remoteDescriptors);
        // register progress listeners
        status.addProgressListerner(mucker);
        status.addProgressListerner(new RemoteComputationDestroyer(remoteStatus, computationId));
        status.addProgressListerner(future);
        // start the computation
        remoteExecutors.iterator().next().getQueue(computationId).emit(computation);
        // return future
        return future;
    } catch (RemoteException e) {
        try {
            if (exportedRemoteStatus != null) {
                UnicastRemoteObject.unexportObject(remoteStatus, true);
            }
        } catch (NoSuchObjectException ee) {
            LOGGER.error(ee.getMessage(), ee);
        } finally {
            for (RemoteExecutor executor : remoteExecutors) {
                try {
                    if (remoteDescriptors.containsKey(executor.getId())) {
                        executor.destroyComputation(computationId);
                    }
                } catch (RemoteException ee) {
                    LOGGER.error(ee.getMessage(), ee);
                }
            }
            try {
                context.destroy();
            } catch (Exception ee) {
                LOGGER.error("Can't destroy the computation context.");
            }
            throw new IllegalStateException("Can't submit the computation.", e);
        }
    }

}

From source file:org.kchine.r.server.impl.RGraphicsPanelRemote.java

public void dispose() throws RemoteException {
    _graphicNotifier.executeDevOff(_devNr);
    if (_gdcServer != null) {
        UnicastRemoteObject.unexportObject((Remote) _gdcServer, true);
    }/*  w  w w  . j  ava2  s.  co m*/
}