Example usage for java.rmi.server UnicastRemoteObject exportObject

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

Introduction

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

Prototype

@Deprecated
public static RemoteStub exportObject(Remote obj) throws RemoteException 

Source Link

Document

Exports the remote object to make it available to receive incoming calls using an anonymous port.

Usage

From source file:org.brixcms.rmiserver.AbstractRmiExporterBean.java

public void afterPropertiesSet() throws Exception {
    try {/*from  ww w . j  ava  2s . c  om*/
        registry = LocateRegistry.getRegistry(registryPort);
        registry.list();
    } catch (Exception e) {
        registry = LocateRegistry.createRegistry(registryPort);
        registry.list();
    }

    server = createServiceInstance();
    logger.info("Exporting " + server.getClass().getName() + " under: {}/{}", serviceName, registry);
    RemoteStub stub = UnicastRemoteObject.exportObject(server);
    registry.rebind(serviceName, stub);
    logger.info("Exported " + server.getClass().getName() + ": {}", stub);
}

From source file:org.brixcms.rmiserver.workspacemanager.WorkspaceManagerExporterBean.java

public void afterPropertiesSet() throws Exception {
    try {//from  w ww.  j a v a  2s .  c  om
        registry = LocateRegistry.getRegistry(registryPort);
        registry.list();
    } catch (Exception e) {
        registry = LocateRegistry.createRegistry(registryPort);
        registry.list();
    }

    logger.info("Exporting Workspace Manager under: {}/{}", serviceName, registry);
    server = new ServerWorkspaceManager(workspaceManager);
    RemoteStub stub = UnicastRemoteObject.exportObject(server);
    registry.rebind(serviceName, stub);
    logger.info("Exported Workspace Manager: {}", stub);
}

From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.DispatchServ.java

/** RMI: This method turns on an RMI server that waits for an RMIMonitor interfaces (specifically,
 *  RMIMonitorReceivers) to register themselves with the MonitorServ. Each receiver that registers
 *  is assigned a new RMIMonitorTransmitter which is used by the MonitorServ to communicate to the
 *  receiver, which in turn manipulates the monitor on the admin side.
 *//*from   w w  w.ja v  a2s .  c o m*/
private int activateRMIMonitorTunnel(int port) {
    try {
        tunnel = new GUITunnel(this);
        log.info("DispatchServ has created a GUITunnel object and linked it to the Dispatcher");

        UnicastRemoteObject.exportObject((GUILink) tunnel);
        log.info("DispatchServ has exported the GUITunnel in the form of a GUILink object");

        registry = new SimpleObjectRegistry(port, port + 20);

        registry.rebind("link", (GUILink) tunnel);
        log.info("DispatchServ has successfully bound the Monitor Registrar onto port " + registry.port());

        return registry.port();
    } catch (java.rmi.UnknownHostException uhe) {
        log.error("The host computer name you have specified for RMI monitor communication is invalid", uhe);
        return OPERATION_FAILED;
    } catch (Exception re) {
        log.error("Error exporting GUITunnel for use in RMI monitor communication", re);
        return OPERATION_FAILED;
    }
}

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 {//from w w  w  .j a  v a 2s.c  o 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.sybila.parasim.computation.lifecycle.impl.distributed.RemoteExecutorImpl.java

private void initServices(Class<? extends Computation> computationClass, Context context,
        RemoteMutableStatus remoteStatus) throws RemoteException {
    Binder binder = (Binder) context;
    // initialize services
    MutableStatus localStatus = new SlaveMutableStatus(remoteStatus);
    CallableFactory callableFactory = new CallableFactory(context, localStatus);
    Offerer offerer = new SimpleOfferer(getId(), localStatus,
            context.resolve(Enrichment.class, Default.class)
                    .enrich(ComputationUtils.getOffererSelector(computationClass), context),
            context.resolve(Enrichment.class, Default.class)
                    .enrich(ComputationUtils.getBalancerSelector(computationClass), context));
    ComputationLifecycleConfiguration configuration = context.resolve(ComputationLifecycleConfiguration.class,
            Default.class);
    RemoteQueue remoteQueue = new RemoteQueueWrapper(offerer, offerer);
    Mucker mucker = new Mucker(id, localStatus, context.resolve(ExecutorService.class, Default.class), offerer,
            configuration.getNodeThreshold(), callableFactory);

    // add progress listeners
    localStatus.addProgressListerner(offerer);
    localStatus.addProgressListerner(mucker);
    localStatus.addProgressListerner(new LogListener(offerer));

    // bind services
    binder.bind(MutableStatus.class, Default.class, localStatus);
    binder.bind(Offerer.class, Default.class, offerer);
    binder.bind(Emitter.class, Default.class, offerer);
    binder.bind(RemoteQueue.class, Original.class, remoteQueue);
    binder.bind(RemoteQueue.class, Default.class, (RemoteQueue) UnicastRemoteObject.exportObject(remoteQueue));
    binder.bind(UUID.class, Node.class, getId());
}