Example usage for java.rmi Naming rebind

List of usage examples for java.rmi Naming rebind

Introduction

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

Prototype

public static void rebind(String name, Remote obj) throws RemoteException, java.net.MalformedURLException 

Source Link

Document

Rebinds the specified name to a new remote object.

Usage

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

protected void rmiBind() {
    if (rmibind != null && repo != null) {
        try {/*from  w ww .  j av  a2s.co m*/
            Naming.rebind(rmibind, new ServerAdapterFactory().getRemoteRepository(repo));
        } catch (Exception e) {
            logger.warn("Unable to bind remote JCR repository to RMI using " + rmibind, e);
        }
    }
}

From source file:org.mule.transport.rmi.RmiMessageReceiverTestCase.java

private void registerRmi() throws Exception {
    if (null == rmiRegistry) {
        rmiRegistry = LocateRegistry.createRegistry(11099);
        Naming.rebind("//localhost:11099/TestMatchingMethodsComponent",
                new SerializedMatchingMethodsComponent());

        Hashtable<String, String> env = new Hashtable<String, String>();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");

        Context context = new InitialContext(env);
        SerializedMatchingMethodsComponent obj = (SerializedMatchingMethodsComponent) context
                .lookup("rmi://localhost:11099/TestMatchingMethodsComponent");

        if (obj == null) {
            throw new RuntimeException("Could not start RMI properly");
        }//from  w w  w . j  a  va 2 s.  c  o  m
    }
}

From source file:se.trixon.jota.client.Client.java

private void initCallbackServer()
        throws RemoteException, MalformedURLException, java.rmi.server.ExportException {
    mRmiNameClient = JotaHelper.getRmiName(SystemHelper.getHostname(), mPortClient, JotaClient.class);
    LocateRegistry.createRegistry(mPortClient);
    Naming.rebind(mRmiNameClient, this);
}

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

private void startServer() {
    mRmiNameServer = JotaHelper.getRmiName(SystemHelper.getHostname(), mPort, JotaServer.class);

    try {/*from w w  w.  j a  va 2  s  . c  o  m*/
        LocateRegistry.createRegistry(mPort);
        mServerVmid = new VMID();
        //mServerOptions = new ServerOptions();
        Naming.rebind(mRmiNameServer, this);
        String message = String.format("started: %s (%s)", mRmiNameServer, mServerVmid.toString());
        Xlog.timedOut(message);
        listJobs();
        listTasks();
        getStatus();
        if (mOptions.isCronActive()) {
            cronOn();
        }
    } catch (IllegalArgumentException e) {
        Xlog.timedErr(e.getLocalizedMessage());
        Jota.exit();
    } catch (RemoteException e) {
        //nvm - server was running
        Xlog.timedErr(e.getLocalizedMessage());
        Jota.exit();
    } catch (MalformedURLException ex) {
        Xlog.timedErr(ex.getLocalizedMessage());
        Jota.exit();
    }
}

From source file:xbird.server.RemoteServerBase.java

protected void bind() throws RemoteException, NamingException {
    final Remote stub;
    if (RMI_PROTOCOL.equals(ServerConstants.RMI_PROTOCOL_JRMP_SSL)) {
        stub = (Remote) UnicastRemoteObject.exportObject(this, _exportPort, new SslRMIClientSocketFactory(),
                new SslRMIServerSocketFactory());
    } else {//from   ww w.j  a  v a2 s  . co  m
        assert (RMI_PROTOCOL.equals("jrmp"));
        stub = (Remote) UnicastRemoteObject.exportObject(this, _exportPort);
    }
    // Bind the remote object's stub in the registry
    try {
        Naming.rebind(_bindUrl, stub);
    } catch (MalformedURLException e) {
        throw new IllegalStateException("Illegal regist url:" + _bindUrl, e);
    }
    LOG.info("Remote object is bounded at " + _bindUrl);
}