當前位置: 首頁>>代碼示例>>Java>>正文


Java LocateRegistry類代碼示例

本文整理匯總了Java中java.rmi.registry.LocateRegistry的典型用法代碼示例。如果您正苦於以下問題:Java LocateRegistry類的具體用法?Java LocateRegistry怎麽用?Java LocateRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LocateRegistry類屬於java.rmi.registry包,在下文中一共展示了LocateRegistry類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: unBind

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
/**
 * <p>
 * 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");
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:QuartzScheduler.java

示例2: setUpClass

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
@BeforeClass
public static void setUpClass() throws RemoteException, MalformedURLException, IOException {
    Registry r = LocateRegistry.createRegistry(9999);
    mbs = MBeanServerFactory.createMBeanServer();

    person = new Test01_JavaIntrospection.Person("Alice Aho", 23);
    person.knows = new Test01_JavaIntrospection.Person("Bob", 30);
    
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/server");
    cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    if (cs == null) {
    	throw new RuntimeException("Could not setUpClass() for test! JMXConnectorServerFactory.newJMXConnectorServer FAILED (Returned null...)! Url: " + url + ", mbs: " + mbs);
    }
    cs.start();
    System.out.println("Registry created / JMX connector started.");
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:17,代碼來源:Test01_Jmx.java

示例3: getMBeanServer

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
/**
 * Returns MBeans server for the Pogamut Platform. All MBeans connected from
 * the platform should be registered in this server. There is also default
 * RMI connector for this server running on service:jmx:rmi:///jndi/rmi://localhost:9999/server
 * @return
 * @throws cz.cuni.amis.utils.exception.PogamutException
 */
@Override
public synchronized MBeanServer getMBeanServer() throws PogamutException {
    try {
        if (!registryCreated) {
            if (log.isLoggable(Level.WARNING)) log.warning("Creating registry at " + getRMIPort() + " ...");
            LocateRegistry.createRegistry(getRMIPort());
            registryCreated = true;
        }
        if (mBeanServer == null) {
            if (log.isLoggable(Level.WARNING)) log.warning("Starting MBean server.");
            //start a RMI registry                
            mBeanServer = new PogamutMBeanServer();

            // also create connector for this server, server without connector
            // would be unreachable outside this JVM
            cs = JMXConnectorServerFactory.newJMXConnectorServer(getMBeanServerURL(), null, mBeanServer);
            cs.start();

        }
        return mBeanServer;
    } catch (Exception ex) {
        throw new PogamutException("Error during JMX initialization.", ex);
    }
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:32,代碼來源:DefaultPogamutPlatform.java

示例4: run

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
@Override
public void run() {
    //напишите тут ваш код
    try {
        //создание объекта для удаленного доступа
        final Animal cat = new Cat("Barsik");
        final Animal dog = new Dog("Palkan");

        //создание реестра расшареных объетов
        registry = LocateRegistry.createRegistry(2099);

        //создание "заглушки" – приемника удаленных вызовов
        Remote stubCat = UnicastRemoteObject.exportObject(cat, 0);
        Remote stubDog = UnicastRemoteObject.exportObject(dog, 0);

        //регистрация "заглушки" в реесте
        registry.bind(BINDING_NAME1, stubCat);
        registry.bind(BINDING_NAME2, stubDog);

    } catch (RemoteException | AlreadyBoundException e) {
        e.printStackTrace();
    }
}
 
開發者ID:avedensky,項目名稱:JavaRushTasks,代碼行數:24,代碼來源:Solution.java

示例5: start

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
@Override
public void start() {

    try {
        JavaSecurityUtils.unlockJavaSecurity();

        if( System.getSecurityManager() == null ) {
            System.setSecurityManager( new SecurityManager() );
        }

        log.info( "Connecting to " + connectionDescription );
        this.registry = LocateRegistry.getRegistry( this.ip, this.rmiPort );
        log.info( "Successfully connected to " + connectionDescription );
    } catch( Exception e ) {
        throw new RmiException( "Error connecting to " + connectionDescription, e );
    }
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:18,代碼來源:AbstractRMIDriver.java

示例6: getRegistry

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
/**
 * Locate or create the RMI registry for this exporter.
 * @param registryHost the registry host to use (if this is specified,
 * no implicit creation of a RMI registry will happen)
 * @param registryPort the registry port to use
 * @param clientSocketFactory the RMI client socket factory for the registry (if any)
 * @param serverSocketFactory the RMI server socket factory for the registry (if any)
 * @return the RMI registry
 * @throws RemoteException if the registry couldn't be located or created
 */
protected Registry getRegistry(String registryHost, int registryPort,
		RMIClientSocketFactory clientSocketFactory, RMIServerSocketFactory serverSocketFactory)
		throws RemoteException {

	if (registryHost != null) {
		// Host explicitly specified: only lookup possible.
		if (logger.isInfoEnabled()) {
			logger.info("Looking for RMI registry at port '" + registryPort + "' of host [" + registryHost + "]");
		}
		Registry reg = LocateRegistry.getRegistry(registryHost, registryPort, clientSocketFactory);
		testRegistry(reg);
		return reg;
	}

	else {
		return getRegistry(registryPort, clientSocketFactory, serverSocketFactory);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:RmiServiceExporter.java

示例7: getRegistry

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
/**
 * Locate or create the RMI registry.
 * @param registryHost the registry host to use (if this is specified,
 * no implicit creation of a RMI registry will happen)
 * @param registryPort the registry port to use
 * @param clientSocketFactory the RMI client socket factory for the registry (if any)
 * @param serverSocketFactory the RMI server socket factory for the registry (if any)
 * @return the RMI registry
 * @throws java.rmi.RemoteException if the registry couldn't be located or created
 */
protected Registry getRegistry(String registryHost, int registryPort,
		RMIClientSocketFactory clientSocketFactory, RMIServerSocketFactory serverSocketFactory)
		throws RemoteException {

	if (registryHost != null) {
		// Host explicitly specified: only lookup possible.
		if (logger.isInfoEnabled()) {
			logger.info("Looking for RMI registry at port '" + registryPort + "' of host [" + registryHost + "]");
		}
		Registry reg = LocateRegistry.getRegistry(registryHost, registryPort, clientSocketFactory);
		testRegistry(reg);
		return reg;
	}

	else {
		return getRegistry(registryPort, clientSocketFactory, serverSocketFactory);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:RmiRegistryFactoryBean.java

示例8: getRemoteScheduler

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
protected RemotableQuartzScheduler getRemoteScheduler()
    throws SchedulerException {
    if (rsched != null) {
        return rsched;
    }

    try {
        Registry registry = LocateRegistry.getRegistry(rmiHost, rmiPort);

        rsched = (RemotableQuartzScheduler) registry.lookup(schedId);

    } catch (Exception e) {
        SchedulerException initException = new SchedulerException(
                "Could not get handle to remote scheduler: "
                        + e.getMessage(), e);
        throw initException;
    }

    return rsched;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:RemoteScheduler.java

示例9: getRegistry

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
private Registry getRegistry(int registryPort) throws RemoteException {
    if (this.alwaysCreateRegistry) {
        logger.info("Creating new RMI registry");
        return LocateRegistry.createRegistry(registryPort);
    }
    if (logger.isInfoEnabled()) {
        logger.info("Looking for RMI registry at port '" + registryPort + "'");
    }
    try {
        // Retrieve existing registry.
        Registry reg = LocateRegistry.getRegistry(registryPort);
        testRegistry(reg);
        return reg;
    } catch (RemoteException ex) {
        logger.debug("RMI registry access threw exception", ex);
        logger.info("Could not detect RMI registry - creating new one");
        // Assume no registry found -> create new one.
        return LocateRegistry.createRegistry(registryPort);
    }
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:21,代碼來源:JmxConnectorServerFactoryBean.java

示例10: startServer

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:RMIConnectorLogAttributesTest.java

示例11: getRegistroRMInodoRemoto

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
public static Registry getRegistroRMInodoRemoto (String identHost){

   // Si no existe se crea el registro en el nodo local y en el puerto por defecto
//       if (registroRMILocalCreado ) return registroRMILocal ;

         try {
//             hostRMI =  getIPLocal();
//             hostRMI = InetAddress.getLocalHost().getHostName();
////             hostRMI = InetAddress.getByName("SERTORIUS").toString();
//             puertoRMIOrganizacionconfigurado = configuracionOrganizacion.getPropiedadesGlobales().getProperty("PuertoRMI");
//             if (puertoRMIOrganizacionconfigurado != null)puertoRMI = Integer.parseInt (puertoRMIOrganizacionconfigurado);
//             registroRMILocal = LocateRegistry.createRegistry(puertoRMI);
//             registroRMILocalCreado = true;
            return LocateRegistry.getRegistry(identHost);

            } catch (Exception e) {

                logger.error("Error al localizar el registro de la organizacion  en el nodo--: "+ hostRMI + " Es posible que no se haya creado: Revisar la descripcion de la organizacion" );
                trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI",
						"La direccion IP del registro RMI es NULA  "+ hostRMI + "-- Es posible que no se haya creado: Revisar la descripcion de la organizacion" ,
						InfoTraza.NivelTraza.error));
//
                return null;
            }

    }
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:27,代碼來源:AdaptadorRegRMI.java

示例12: getRemoteEntityFromHost

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
public static Remote getRemoteEntityFromHost(String host, int puerto, String identEntity) throws java.rmi.RemoteException {
        Registry regCliente = LocateRegistry.getRegistry(host, puerto);
        Object remoteEntity = null;
//        ItfUsoRecursoTrazas trazas = Directorio.getRecursoTrazas();
        try {
            if (regCliente == null) {
//                System.err.println("buscarAgenteRemoto regCliente == null");
//                if (trazas != null)
                trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", " No se puede obtener la entidad : "+
                        identEntity + " No se consigue encontrar el  registro RMI del Host :" + host + " puerto:" + puerto, NivelTraza.debug));
            }
            return  regCliente.lookup(identEntity);

        } catch (Exception ex) {
            System.err.println("Fallo buscaAgenteRemoto\n"+ ex.getMessage());
            trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", " No se puede obtener la entidad : "+
                      identEntity + " No se consigue encontrar el  registro RMI del Host :" + host + " puerto:"+ puerto , NivelTraza.debug));
//            Logger.getLogger(ComunicacionAgentes.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:22,代碼來源:AdaptadorRegRMI.java

示例13: startRMI

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
public static boolean startRMI() {
    try {
        registroRMI = LocateRegistry.createRegistry(puertoRMI);
        System.err.println("Registro listo en " + puertoRMI);
  
        return true;
    } catch (Exception e) {
        System.err.println("No se ha podido crear el registro RMI");
        try {
            registroRMI = LocateRegistry.getRegistry(puertoRMI);
            System.err.println ("El registro ya existia (RMI listo)");
 
            return true;
        }
        catch (Exception ex) {
            System.err.println ("RMI no disponible!!\n" + ex.getMessage());
            return false;
        }
    }
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:21,代碼來源:ControlRMI.java

示例14: buscarAgenteRemoto

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
public static ItfUsoAgenteReactivo buscarAgenteRemoto(String ip, int puerto, String nombreAgente) throws java.rmi.RemoteException {
        Registry regCliente = LocateRegistry.getRegistry(ip, puerto);
        ItfUsoAgenteReactivo agenteRemoto = null;
//        ItfUsoRecursoTrazas trazas = Directorio.getRecursoTrazas();
        try {            
            if (regCliente == null) {
                System.err.println("buscarAgenteRemoto regCliente == null");
                if (trazas != null)
                trazas.aceptaNuevaTraza(new InfoTraza("ControlRMI (null)", "No consigo encontrar al agente: "+
                        nombreAgente + " en ip:" + ip + " puerto:" + puerto, NivelTraza.error));
            }
            agenteRemoto = (ItfUsoAgenteReactivo) regCliente.lookup(nombreAgente);
            return agenteRemoto;
        } catch (Exception ex) {
            System.err.println("Fallo buscaAgenteRemoto\n"+ ex.getMessage());
            if (trazas != null)
            trazas.aceptaNuevaTraza(new InfoTraza("ControlRMI (Excepcion)", "No consigo encontrar al agente: "+
                        nombreAgente + " en ip:" + ip + " puerto:" + puerto, NivelTraza.error));
//            Logger.getLogger(ComunicacionAgentes.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:23,代碼來源:ControlRMI.java

示例15: getRemoteScheduler

import java.rmi.registry.LocateRegistry; //導入依賴的package包/類
protected RemotableQuartzScheduler getRemoteScheduler()
    throws SchedulerException {
    if (rsched != null) {
        return rsched;
    }

    try {
        Registry registry = LocateRegistry.getRegistry(rmiHost, rmiPort);

        rsched = (RemotableQuartzScheduler) registry.lookup(schedId);

    } catch (Exception e) {
        SchedulerException initException = new SchedulerException(
                "Could not get handle to remote scheduler: "
                        + e.getMessage(), e);
        initException
                .setErrorCode(SchedulerException.ERR_COMMUNICATION_FAILURE);
        throw initException;
    }

    return rsched;
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:23,代碼來源:RemoteScheduler.java


注:本文中的java.rmi.registry.LocateRegistry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。