当前位置: 首页>>代码示例>>Java>>正文


Java LocateRegistry.createRegistry方法代码示例

本文整理汇总了Java中java.rmi.registry.LocateRegistry.createRegistry方法的典型用法代码示例。如果您正苦于以下问题:Java LocateRegistry.createRegistry方法的具体用法?Java LocateRegistry.createRegistry怎么用?Java LocateRegistry.createRegistry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.rmi.registry.LocateRegistry的用法示例。


在下文中一共展示了LocateRegistry.createRegistry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public void run() {

        /*
         * Attempt to create (i.e. export) a registry on the port that
         * has already been bound, and record the result.
         */
        try {
            LocateRegistry.createRegistry(port);
            synchronized (this) {
                exportSucceeded = true;
                notifyAll();
            }
        } catch (Throwable t) {
            synchronized (this) {
                exportException = t;
                notifyAll();
            }
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:AddrInUse.java

示例2: 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

示例3: startRegistry

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
private Registry startRegistry()
        throws InterruptedException, RemoteException {
    Registry registry = null;
    try {
        System.out.println("Start rmiregistry on port " + port);
        registry = LocateRegistry
                .createRegistry(Integer.parseInt(port));
    } catch (RemoteException e) {
        if (e.getMessage().contains("Port already in use")) {
            System.out.println("Port already in use. Trying to restart with a new one...");
            Thread.sleep(100);
            return null;
        } else {
            throw e;
        }
    }
    return registry;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:JstatdTest.java

示例4: getRegistry

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
/**
 * Locate or create the RMI registry for this exporter.
 * @param registryPort the registry port to use
 * @return the RMI registry
 * @throws RemoteException if the registry couldn't be located or created
 */
protected 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 + "'");
	}
	synchronized (LocateRegistry.class) {
		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:lamsfoundation,项目名称:lams,代码行数:30,代码来源:RmiServiceExporter.java

示例5: 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

示例6: 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

示例7: main

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
/**
 * Start the Server and wait for user termination by keyboard.
 * 
 * @param args
 *            This program does not accept command line parameters.
 */
public static void main(String args[]) {

	// Override the default security manager
	System.setSecurityManager(new SecurityManager());
	
	try {
		LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
	} catch (RemoteException remoteException) {
		remoteException.printStackTrace();
	}

	Server server = new Server();

	System.out.println("Server started.");
	System.out.println("Enter <CR> to end.");

	try {
		System.in.read(); // Wait for Enter ...
	} catch (IOException ioException) {
		ioException.printStackTrace();
	}

	try {
		Naming.unbind("//" + server.hostname + "/meganalysis");
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		System.exit(0);
	}
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:37,代码来源:Server.java

示例8: init

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
private void init() {
    try {
        rmiRegistry = LocateRegistry.createRegistry(port);

        logger.info("mage server is running");

    } catch (RemoteException e) {

        logger.error("init mage server error");
        throw new RuntimeException(e);
    }
}
 
开发者ID:yuanwhy,项目名称:mage,代码行数:13,代码来源:MageServer.java

示例9: getRegistry

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
private Registry getRegistry() throws RemoteException {
    Registry registry = LocateRegistry.getRegistry(this.registryPort);
    try {
        registry.list();
    } catch (RemoteException e) {
        registry = null;
    }
    if (registry == null) {
        registry = LocateRegistry.createRegistry(this.registryPort);
    }
    return registry;
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:13,代码来源:RmiBinder.java

示例10: start

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:Server.java

示例11: getRegistroRMInodoLocal

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public static Registry getRegistroRMInodoLocal (){

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

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

            } catch (Exception e) {

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

    }
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:28,代码来源:AdaptadorRegRMI.java

示例12: main

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public static void main(String[] args) {
   /*
    MarioNOTE:
    creating a connection to the database
    */
   DatabaseConnection connection = new DatabaseConnection("java", "password");
   
   try{
       int port = 1099;
       /*
       MarioNOTE:
       creating a Registry that allows the server to
       publish a service and client to retrieve the proxy
       */
       Registry registry = LocateRegistry.createRegistry(port);
       DatabaseGestion DBGestor = new DatabaseGestion();
       registry.rebind("MyDatabase", DBGestor);
       
       System.out.println("\nServer is ready...");
       
   }catch(RemoteException ex){
       System.out.println("\nRMIDatabaseServer ERROR: " + ex);
   }
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-M,代码行数:25,代码来源:RMIDatabaseServer.java

示例13: start

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
/**
 * Starts this MBean: rmiregistry can now accept incoming calls
 * 
 * @see #stop
 * @see #isRunning
 */
public synchronized void start() throws RemoteException {
  if (!isRunning()) {
    if (ssf != null) {
      registry = LocateRegistry.createRegistry(port, null, // RMIClientSocketFactory
          ssf); // RMIServerSocketFactory
    } else {
      registry = LocateRegistry.createRegistry(port);
    }

    isRunning = true;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:RMIRegistryService.java

示例14: createConnector

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
private void createConnector(String accessFileName, String pwFile) throws IOException {
  registry = LocateRegistry.createRegistry(port);
  MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
  String serviceUrl = SERVICE_URLPREFIX + "//" + hostname + ":" + port + "/jmxconnector";
  System.out.println("Server service url " + serviceUrl);
  final JMXServiceURL jmxServiceUrl = new JMXServiceURL(serviceUrl);

  final HashMap<String, Object> env = new HashMap<String, Object>();
  env.put("jmx.remote.x.password.file", pwFile);

  ReadOpFileAccessController controller = new ReadOpFileAccessController(accessFileName);
  controller.setMBeanServer(mbs);
  rmiConnector = JMXConnectorServerFactory.newJMXConnectorServer(jmxServiceUrl, env, controller);
  rmiConnector.start();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:16,代码来源:ReadOpFileAccessControllerJUnitTest.java

示例15: main

import java.rmi.registry.LocateRegistry; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        int errorCount = 0;

        MapNullValuesTest test = new MapNullValuesTest();

        // Create an RMI registry
        //
        echo("");
        echo(dashedMessage("Start RMI registry"));
        Registry reg = null;
        port = 7500;
        while (port++ < 7550) {
            try {
                reg = LocateRegistry.createRegistry(port);
                echo("\nRMI registry running on port " + port);
                break;
            } catch (RemoteException e) {
                // Failed to create RMI registry...
                //
                echo("\nFailed to create RMI registry on port " + port);
                e.printStackTrace(System.out);
            }
        }
        if (reg == null) {
            System.exit(1);
        }

        // Run tests
        //
        errorCount += test.mapToHashtableTests();
        errorCount += test.jmxConnectorServerFactoryTests();
        errorCount += test.jmxConnectorFactoryTests();
        errorCount += test.nullKeyFactoryTests();

        if (errorCount == 0) {
            echo("\nNull values for key/value pairs in Map Tests PASSED!");
        } else {
            echo("\nNull values for key/value pairs in Map Tests FAILED!");
            System.exit(1);
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:MapNullValuesTest.java


注:本文中的java.rmi.registry.LocateRegistry.createRegistry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。