Java Examples for java.rmi.registry.LocateRegistry
The following java examples will help you to understand the usage of java.rmi.registry.LocateRegistry. These source code samples are taken from different open source projects.
Example 1
Project: GeDBIT-master File: LocalIndexRMIServer.java View source code |
public static void main(String[] args) {
try {
LocateRegistry.createRegistry(1099);
LocalIndex index = new LocalIndexImpl();
Naming.rebind("local", index);
System.out.println("Local RMI server is ready!!");
} catch (RemoteException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
Example 2
Project: AndroidProjectStroe-master File: TestService.java View source code |
@SuppressWarnings("unchecked")
public static void main(String[] args) throws RemoteException, AlreadyBoundException {
// ITest i=(ITest)UnicastRemoteObject.exportObject(new TestImpl(),0);
// Registry registry = LocateRegistry.createRegistry(9700);
// registry.bind("test", i);
// ManagerFactory mf =
// ManagerFactory.getInstance(TestManagerInvocationHandler.class);
// ITest test = mf.instance(ITest.class);
// User l = test.login("name", "password");
// System.out.println(l);
test3();
}
Example 3
Project: choreos_v-v-master File: RMIMultiClient.java View source code |
protected void createClients(Class<T> cls, long qtd, List<String> remotes) throws InstantiationException, IllegalAccessException, RemoteException, NotBoundException {
clients = new ArrayList<T>();
int n = remotes.size();
int r = 0;
String name = "Client";
for (int i = 0; i < qtd; i++) {
Registry registry = LocateRegistry.getRegistry(remotes.get(r));
r = (r + 1) % n;
T client = (T) registry.lookup(name);
clients.add(client);
}
}
Example 4
Project: dea-code-examples-master File: SortServer.java View source code |
private void init() {
try {
Registry registry = LocateRegistry.createRegistry(RMI_PORT);
registry.bind("factory", new DefaultSortFactory());
} catch (RemoteException e) {
logger.log(Level.SEVERE, e.getMessage());
} catch (AlreadyBoundException e) {
logger.log(Level.SEVERE, e.getMessage());
}
}
Example 5
Project: distributeme-master File: RMIRegistryUtil.java View source code |
/** * Finds or creates a new registry. * * @param port port to listen to. If port is below zero, it will be ignored. * @return Returns created registry instance. * @throws java.rmi.RemoteException if any. */ public static Registry findOrCreateRegistry(int port) throws RemoteException { if (reference.get() != null) { return reference.get(); } synchronized (reference) { log.info("Creating local registry"); Registry registry; if (port > 0 || SystemProperties.LOCAL_RMI_REGISTRY_PORT.isSet()) { //we are hardcore bound to a local port try { if (port <= 0) { port = SystemProperties.LOCAL_RMI_REGISTRY_PORT.getAsInt(); } log.info("Tying to bind to " + port); registry = LocateRegistry.createRegistry(port); log.info("Started local registry at port " + port); reference.set(registry); rmiRegistryPort = port; return registry; } catch (ExportException e) { log.error(fatal, "local rmi registry port specified but not useable", e); throw new AssertionError("Have to halt due to misconfiguration: local rmi registry port: " + SystemProperties.LOCAL_RMI_REGISTRY_PORT.get() + ", port is not free or not bind-able " + e.getMessage()); } catch (NumberFormatException e) { log.error(fatal, "local rmi registry port specified but not parseable", e); throw new AssertionError("Have to halt due to misconfiguration: local rmi registry port: " + SystemProperties.LOCAL_RMI_REGISTRY_PORT.get() + ", expected numeric value."); } } //... end SystemProperties.LOCAL_RMI_REGISTRY_PORT.isSet() RegistryLocation location = RegistryLocation.create(); int minPort = location.getRmiRegistryMinPort(); int maxPort = location.getRmiRegistryMaxPort(); int currentPort = minPort; while (currentPort <= maxPort) { try { registry = LocateRegistry.createRegistry(currentPort); log.info("Started local registry at port " + currentPort); reference.set(registry); rmiRegistryPort = currentPort; //System.out.println("Reference "+registry+", port "+rmiRegistryPort); return registry; } catch (ExportException e) { currentPort++; } //...while } throw new RemoteException("Couldn't obtain free port for a local rmi registry"); } }
Example 6
Project: JavaStory-master File: WorldServer.java View source code |
public static void startWorld_Main() {
try {
final Registry registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT, Sockets.getClientFactory(), Sockets.getServerFactory());
registry.bind("WorldRegistry", WorldRegistryImpl.getInstance());
} catch (final AccessException ex) {
System.err.println("Access denied: you do not have permissions to bind.");
} catch (final AlreadyBoundException ex) {
System.err.println("The RMI binding is already in place.");
} catch (final RemoteException ex) {
System.err.println("Could not initialize RMI system" + ex);
}
}
Example 7
Project: mtools-master File: RmiServer.java View source code |
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
System.setSecurityManager(new RMISecurityManager());
RmiService service = new RmiServiceImpl();
//注册通讯端�
LocateRegistry.createRegistry(6600);
//注册通讯路径
Naming.rebind("rmi://127.0.0.1:6600/PersonService", service);
System.out.println("Service Start!");
} catch (Exception e) {
e.printStackTrace();
}
}
Example 8
Project: PKU_distrystem-master File: Main.java View source code |
public static void main(String[] args) throws RemoteException, MalformedURLException, NotBoundException {
NamingService loadService = new NamingServiceImpl();
LocateRegistry.createRegistry(7779);
Naming.rebind("rmi://127.0.0.1:7779/LoadService", loadService);
System.out.println("shit");
NamingService loadService1 = (NamingService) Naming.lookup("rmi://127.0.0.1:7779/LoadService");
loadService1.updateMachine(null);
}
Example 9
Project: RMIT-Examples-master File: ChatServer.java View source code |
public static void main(String args[]) {
try {
LocateRegistry.createRegistry(RMIREGISTRY_PORT);
ChatServer srvr = new ChatServer();
Naming.rebind(REMOTE_OBJECT_URL, srvr);
System.out.println("ChatServer is running...");
} catch (Exception e) {
System.err.println("Error running ChatServer:");
System.err.println(e.getMessage());
}
}
Example 10
Project: tictactoermi-master File: Server.java View source code |
public static void main(String[] args) {
try {
java.rmi.registry.LocateRegistry.createRegistry(PORT);
System.out.println("RMI registry ready.");
} catch (RemoteException e) {
System.err.println("RMI registry already running.");
}
try {
Naming.rebind("Notas", new Game());
System.out.println("NotasServer is ready.");
} catch (Exception e) {
System.err.println("NotasServer failed:");
e.printStackTrace();
}
}
Example 11
Project: highway-to-urhell-master File: RmiService.java View source code |
@Override
protected void gatherData(List<EntryPathData> incoming) {
try {
Registry reg = LocateRegistry.getRegistry();
if (reg != null) {
for (String name : reg.list()) {
EntryPathData e = new EntryPathData();
e.setClassName(reg.lookup(name).getClass().getName());
e.setMethodName(name);
e.setUri(name);
e.setAudit(false);
addEntryPath(e);
}
}
} catch (Exception e) {
System.err.println(" No locate registry " + e);
}
}
Example 12
Project: ISODonosti-master File: ServidorRemoto.java View source code |
public static void main(String[] args) {
System.setSecurityManager(new RMISecurityManager());
try {
java.rmi.registry.LocateRegistry.createRegistry(ClaseFachada.numPuerto);
// Crear RMIREGISTRY
} catch (Exception e) {
System.out.println(e.toString() + "Rmiregistry estaba lanzado.");
}
try {
ClaseFachada servidor = new ClaseFachada();
String servicio = "CasaRural2011";
//String servicio = "//localhost:" + InterfazFachada.numPuerto
//+ "/CasaRural2011";
// Resgistrar el servicio remoto
Naming.rebind(servicio, servidor);
System.out.println("HOLA HOLA Servicio lanzado en:\n\t" + servicio);
Login.getInstance().identificarse("Gorka", "gorkita");
} catch (Exception e) {
System.out.println("Error En servidor REmoto" + e.toString());
}
}
Example 13
Project: javablog-master File: Helloimpl.java View source code |
public static void main(String[] args) {
try {
IHello hello = new Helloimpl();
LocateRegistry.createRegistry(1099);
Naming.rebind("rmi://localhost:1099/hello", hello);
System.out.println("Ready......");
} catch (RemoteException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
Example 14
Project: javacuriosities-master File: Server.java View source code |
public static void main(String args[]) { try { // En nuestro ejemplo, creamos el registry desde la app para que ya tome nuestro classpath LocateRegistry.createRegistry(1099); // Creamos el servicio a exportar HelloService serviceImpl = new HelloServiceImpl(); /* * Usamos UnicastRemoteObject para exportar el objeto que deseamos, esto se encargara de crear * las clases stub y skeleton que se encargan de la comunicación, hasta antes de Java 1.5 era necesario * ejecutar rmic sobre la implementación del servicio para generar estas clases. * * Stub: Es la representación del lado cliente * Skeleton: Es la representación del lado server */ HelloService skeleton = (HelloService) UnicastRemoteObject.exportObject(serviceImpl, 0); // Obtenemos el registry Registry registry = LocateRegistry.getRegistry(); // Hacemos el binding entre un nombre y el objeto del lado server registry.bind(HelloService.class.getName(), skeleton); System.out.println("Server is up and running"); } catch (RemoteExceptionAlreadyBoundException | e) { e.printStackTrace(); } }
Example 15
Project: jdk7u-jdk-master File: HelloImpl.java View source code |
public static void main(String[] args) {
/*
* The following line is required with the JDK 1.2 VM so that the
* VM can exit gracefully when this test completes. Otherwise, the
* conservative garbage collector will find a handle to the server
* object on the native stack and not clear the weak reference to
* it in the RMI runtime's object table.
*/
Object dummy = new Object();
Hello hello = null;
Registry registry = null;
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
try {
String protocol = "";
if (args.length >= 1)
protocol = args[0];
registry = java.rmi.registry.LocateRegistry.getRegistry("localhost", TestLibrary.REGISTRY_PORT, new Compress.CompressRMIClientSocketFactory());
UseCustomSocketFactory.checkStub(registry, "RMIClientSocket");
hello = (Hello) registry.lookup("/HelloServer");
/* lookup server */
System.err.println(hello.sayHello() + ", remote greeting.");
} catch (Exception e) {
System.err.println("EXCEPTION OCCURRED:");
e.printStackTrace();
} finally {
hello = null;
}
}
Example 16
Project: ManagedRuntimeInitiative-master File: HelloImpl.java View source code |
public static void main(String[] args) {
/*
* The following line is required with the JDK 1.2 VM so that the
* VM can exit gracefully when this test completes. Otherwise, the
* conservative garbage collector will find a handle to the server
* object on the native stack and not clear the weak reference to
* it in the RMI runtime's object table.
*/
Object dummy = new Object();
Hello hello = null;
Registry registry = null;
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
try {
String protocol = "";
if (args.length >= 1)
protocol = args[0];
registry = java.rmi.registry.LocateRegistry.getRegistry("localhost", TestLibrary.REGISTRY_PORT, new Compress.CompressRMIClientSocketFactory());
UseCustomSocketFactory.checkStub(registry, "RMIClientSocket");
hello = (Hello) registry.lookup("/HelloServer");
/* lookup server */
System.err.println(hello.sayHello() + ", remote greeting.");
} catch (Exception e) {
System.err.println("EXCEPTION OCCURRED:");
e.printStackTrace();
} finally {
hello = null;
}
}
Example 17
Project: AlarmInteraction-master File: ServerLauncher.java View source code |
/**
* @param args
*/
public static void main(String[] args) {
try {
try {
System.out.println("Trying to registry port 1099");
LocateRegistry.createRegistry(1099);
} catch (Exception e) {
System.out.println("-- Port already in use....");
}
Alarm alarm = new Alarm();
MainWindow frame = new MainWindow(alarm);
alarm.addObserver(frame);
String url = "//" + InetAddress.getLocalHost().getHostAddress() + "/ploppy";
System.out.println("Storing the server with url: " + url);
Naming.rebind(url, alarm);
System.out.println("Server is online");
} catch (Exception e) {
System.err.println("Unable to launch server...");
e.printStackTrace();
System.exit(0);
}
}
Example 18
Project: jpregel-aws-master File: RegistrationManager.java View source code |
public static Registry locateRegistry() { Registry registry = null; try { registry = LocateRegistry.createRegistry(PORT); } catch (RemoteException createException) { try { registry = LocateRegistry.getRegistry(PORT); } catch (RemoteException getRegistryException) { out.println("RegistrationManager.locateRegistry: Could not get reference to existing Registry."); getRegistryException.printStackTrace(); System.exit(1); } catch (Exception getRegistryException) { out.println(getRegistryException.getMessage()); getRegistryException.printStackTrace(); } } return registry; }
Example 19
Project: openjdk8-jdk-master File: readTest.java View source code |
public static void main(String args[]) throws Exception {
try {
testPkg.Server obj = new testPkg.Server();
testPkg.Hello stub = (testPkg.Hello) UnicastRemoteObject.exportObject(obj, 0);
// Bind the remote object's stub in the registry
Registry registry = LocateRegistry.getRegistry(TestLibrary.READTEST_REGISTRY_PORT);
registry.bind("Hello", stub);
System.err.println("Server ready");
// now, let's test client
testPkg.Client client = new testPkg.Client(TestLibrary.READTEST_REGISTRY_PORT);
String testStubReturn = client.testStub();
if (!testStubReturn.equals(obj.hello)) {
throw new RuntimeException("Test Fails : unexpected string from stub call");
} else {
System.out.println("Test passed");
}
registry.unbind("Hello");
} catch (Exception e) {
System.err.println("Server exception: " + e.toString());
e.printStackTrace();
}
}
Example 20
Project: scribble-java-master File: RMIMathS.java View source code |
public static void main(String[] args) throws Exception { //System.setProperty("java.security.policy","file:/C:/cygwin/home/Raymond/code/scribble/github-rhu1/scribble-java/modules/demos/scrib/bettybook/src/bettybook/math/rmi/server.policy"); //if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } /*-Djava.rmi.server.codebase=file:/C:\cygwin\home\Raymond\code\scribble\github-rhu1\scribble-java\modules\demos\bettybook\target\classes/ Registry registry = LocateRegistry.getRegistry(8888);*/ Registry registry = LocateRegistry.createRegistry(8888); RMIMath stub = (RMIMath) UnicastRemoteObject.exportObject(new RMIMathS(), 0); registry.rebind("MathService", stub); System.out.println("RMI Math Server running."); }
Example 21
Project: sweetsnake-master File: RmiClient.java View source code |
/**
* @param args
*/
public static void main(String args[]) {
ReceiveMessageInterface rmiServer;
Registry registry;
String serverAddress = args[0];
String serverPort = args[1];
String text = args[2];
System.out.println("sending " + text + " to " + serverAddress + ":" + serverPort);
try {
// Get the server's stub
registry = LocateRegistry.getRegistry(serverAddress, (new Integer(serverPort)).intValue());
rmiServer = (ReceiveMessageInterface) (registry.lookup("rmiServer"));
// RMI client will give a stub of itself to the server
Remote aRemoteObj = UnicastRemoteObject.exportObject(new RmiClient(), 0);
rmiServer.addObserver(aRemoteObj);
// call the remote method
rmiServer.receiveMessage(text);
// update method will be notified
} catch (RemoteException e) {
e.printStackTrace();
} catch (NotBoundException e) {
System.err.println(e);
}
}
Example 22
Project: upnplib-master File: HelloWorldServer.java View source code |
public static void main(String[] args) {
try {
Registry reg = LocateRegistry.createRegistry(1099);
System.out.println("Registry created");
HelloWorld hello = new HelloWorld();
System.out.println("Object created");
reg.bind("HelloWorld", hello);
System.out.println("Object bound HelloWorld server is ready.");
} catch (Exception e) {
System.out.println("Hello Server failed: " + e);
}
}
Example 23
Project: btpka3.github.com-master File: MyServer.java View source code |
public static void main(String[] args) throws Exception {
// start RMI server
// or CMD/> rmiregistry 9999
LocateRegistry.createRegistry(9999);
// setup MBeanServer
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
MyServer s = new MyServer();
ObjectName objName = new ObjectName("MyServer:type=Hello");
mbs.registerMBean(s, objName);
// start JMXConnectorServer
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi");
JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
cs.start();
System.out.println("MBeanServer start");
}
Example 24
Project: camel-master File: RmiRouteTest.java View source code |
@Test
public void testPojoRoutes() throws Exception {
if (classPathHasSpaces()) {
return;
}
// Boot up a local RMI registry
LocateRegistry.createRegistry(getPort());
// START SNIPPET: register
JndiContext context = new JndiContext();
context.bind("bye", new SayService("Good Bye!"));
CamelContext camelContext = new DefaultCamelContext(context);
// END SNIPPET: register
camelContext.addRoutes(getRouteBuilder(camelContext));
camelContext.start();
// START SNIPPET: invoke
Endpoint endpoint = camelContext.getEndpoint("direct:hello");
ISay proxy = ProxyHelper.createProxy(endpoint, false, ISay.class);
String rc = proxy.say();
assertEquals("Good Bye!", rc);
// END SNIPPET: invoke
camelContext.stop();
}
Example 25
Project: cashBob-master File: Main.java View source code |
public static void main(String[] args) { ServerLogger log = ServerLogger.getInstance(); //inicializace Java RMI try { log.writeLogMessage(Level.INFO, "Server spusten"); ServiceFacadeAll facadeAll = ServiceFacadeAll.getInstance(); ServiceFacadeManager facadeManager = ServiceFacadeManager.getInstance(); ServiceFacadeStorage facadeStorage = ServiceFacadeStorage.getInstance(); ServiceFacadeCash facadeCash = ServiceFacadeCash.getInstance(); ServiceFacadePDA facadePDA = ServiceFacadePDA.getInstance(); ServiceFacadeSmeny facadeSmeny = ServiceFacadeSmeny.getInstance(); //Vsechny fasady jsou registrovany a pristupny pres port 1099 (jmenna sluzba) ConfigParser config = new ConfigParser(); InetAddress inetAddress = InetAddress.getByName(config.getServerIP()); Registry reg = LocateRegistry.createRegistry(1099, null, new AnchorSocketFactory(inetAddress)); //Registry reg = LocateRegistry.createRegistry(1099); facadeAll.initServiceFacadeRMI(reg); facadeManager.initServiceFacadeRMI(reg); facadeStorage.initServiceFacadeRMI(reg); facadeCash.initServiceFacadeRMI(reg); facadePDA.initServiceFacadeRMI(reg); facadeSmeny.initServiceFacadeRMI(reg); } catch (RemoteException re) { log.writeThrowingException("ServiceFacadeAll", "getInstance", re); log.writeThrowingException("ServiceFacadeManager", "getInstance", re); log.writeThrowingException("ServiceFacadeStorage", "getInstance", re); log.writeThrowingException("ServiceFacadeCash", "getInstance", re); log.writeThrowingException("ServiceFacadePDA", "getInstance", re); log.writeThrowingException("ServiceFacadeAll", "initServiceFacadeRMI", re); log.writeThrowingException("ServiceFacadeManager", "initServiceFacadeRMI", re); log.writeThrowingException("ServiceFacadeStorage", "initServiceFacadeRMI", re); log.writeThrowingException("ServiceFacadeCash", "initServiceFacadeRMI", re); log.writeThrowingException("ServiceFacadePDA", "initServiceFacadeRMI", re); log.writeThrowingException("ServiceFacadeSmeny", "initServiceFacadeSmeny", re); System.exit(-1); } catch (UnknownHostException uhe) { log.writeThrowingException("ServiceFacadeAll", "getInstance", uhe); log.writeThrowingException("ServiceFacadeManager", "getInstance", uhe); log.writeThrowingException("ServiceFacadeStorage", "getInstance", uhe); log.writeThrowingException("ServiceFacadeCash", "getInstance", uhe); log.writeThrowingException("ServiceFacadePDA", "getInstance", uhe); log.writeThrowingException("ServiceFacadeAll", "initServiceFacadeRMI", uhe); log.writeThrowingException("ServiceFacadeManager", "initServiceFacadeRMI", uhe); log.writeThrowingException("ServiceFacadeStorage", "initServiceFacadeRMI", uhe); log.writeThrowingException("ServiceFacadeCash", "initServiceFacadeRMI", uhe); log.writeThrowingException("ServiceFacadePDA", "initServiceFacadeRMI", uhe); log.writeThrowingException("ServiceFacadeSmeny", "initServiceFacadeSmeny", uhe); System.exit(-1); } catch (Exception ex) { log.writeThrowingException("ServiceFacadeAll", "getInstance", ex); log.writeThrowingException("ServiceFacadeManager", "getInstance", ex); log.writeThrowingException("ServiceFacadeStorage", "getInstance", ex); log.writeThrowingException("ServiceFacadeCash", "getInstance", ex); log.writeThrowingException("ServiceFacadePDA", "getInstance", ex); log.writeThrowingException("ServiceFacadeAll", "initServiceFacadeRMI", ex); log.writeThrowingException("ServiceFacadeManager", "initServiceFacadeRMI", ex); log.writeThrowingException("ServiceFacadeStorage", "initServiceFacadeRMI", ex); log.writeThrowingException("ServiceFacadeCash", "initServiceFacadeRMI", ex); log.writeThrowingException("ServiceFacadePDA", "initServiceFacadeRMI", ex); log.writeThrowingException("ServiceFacadeSmeny", "initServiceFacadeSmeny", ex); ex.printStackTrace(); System.exit(-1); } }
Example 26
Project: che-master File: RmiServer.java View source code |
protected static void start(Remote remote) throws RemoteException {
System.setProperty("java.rmi.server.hostname", "localhost");
System.setProperty("java.rmi.server.disableHttp", "true");
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.eclipse.che.rmi.JNDI");
if (RmiServer.remote != null) {
throw new AssertionError("This server is already started!");
}
RmiServer.remote = remote;
int port = -1;
Random random = new Random();
Registry registry = null;
while (port == -1) {
int tmpPort = random.nextInt(65535);
if (tmpPort < 4000) {
continue;
}
try {
registry = LocateRegistry.createRegistry(tmpPort);
port = tmpPort;
} catch (ExportException ignored) {
}
}
Remote exportObject = UnicastRemoteObject.exportObject(remote, port);
String exportName = remote.getClass().getSimpleName() + Integer.toHexString(exportObject.hashCode());
try {
registry.bind(exportName, exportObject);
String portName = port + "/" + exportName;
System.out.println("Port/Name:" + portName);
int twoMinutes = 2 * 60 * 1000;
Object lock = new Object();
while (true) {
synchronized (lock) {
lock.wait(twoMinutes);
}
// TODO add ping
}
} catch (AlreadyBoundExceptionInterruptedException | e) {
e.printStackTrace();
System.exit(42);
}
}
Example 27
Project: colossus-titan-master File: GameManagerTest.java View source code |
public IGameManager getRemoteGm() {
IGameManager gotGm = null;
try {
registry = LocateRegistry.getRegistry();
gotGm = (IGameManager) registry.lookup(GameManager.OBJ_ID);
} catch (NotBoundException e) {
System.err.println("NotBound exception: " + e.toString());
} catch (RemoteException e) {
System.err.println("RemoteText exception: " + e.toString());
}
return gotGm;
}
Example 28
Project: cyrille-leclerc-master File: Main.java View source code |
/**
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// Get the Platform MBean Server
MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
{
// Construct the ObjectName for the MBean we will register
ObjectName name = new ObjectName("cyrille.jmx:type=Hello");
// Create the Hello World MBean
Hello mbean = new Hello();
// Register the Hello World MBean
mbeanServer.registerMBean(mbean, name);
}
System.out.println("Start the RMI registry");
LocateRegistry.createRegistry(9999);
{
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost:6666/jndi/rmi://localhost:9999/server");
int port = url.getPort();
System.out.println("rmi port " + port);
JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
System.out.println("Start the RMI connector server");
cs.start();
System.out.println("The RMI connector server successfully started");
}
// Wait forever
System.out.println("Waiting forever...");
Thread.sleep(Long.MAX_VALUE);
}
Example 29
Project: dbeaver-master File: InstanceClient.java View source code |
public static IInstanceController createClient(String location) {
try {
File rmiFile = new File(location, ".metadata/" + IInstanceController.RMI_PROP_FILE);
Properties props = new Properties();
try (InputStream is = new FileInputStream(rmiFile)) {
props.load(is);
}
String rmiPort = props.getProperty("port");
return (IInstanceController) LocateRegistry.getRegistry(Integer.parseInt(rmiPort)).lookup(IInstanceController.CONTROLLER_ID);
} catch (Exception e) {
log.error("Error reading RMI config", e);
}
return null;
}
Example 30
Project: DevTools-master File: RmiServer.java View source code |
protected static void start(Remote remote) throws RemoteException {
System.setProperty("java.rmi.server.hostname", "localhost");
System.setProperty("java.rmi.server.disableHttp", "true");
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.eclipse.che.rmi.JNDI");
if (RmiServer.remote != null) {
throw new AssertionError("This server is already started!");
}
RmiServer.remote = remote;
int port = -1;
Random random = new Random();
Registry registry = null;
while (port == -1) {
int tmpPort = random.nextInt(65535);
if (tmpPort < 4000) {
continue;
}
try {
registry = LocateRegistry.createRegistry(tmpPort);
port = tmpPort;
} catch (ExportException ignored) {
}
}
Remote exportObject = UnicastRemoteObject.exportObject(remote, port);
String exportName = remote.getClass().getSimpleName() + Integer.toHexString(exportObject.hashCode());
try {
registry.bind(exportName, exportObject);
String portName = port + "/" + exportName;
System.out.println("Port/Name:" + portName);
int twoMinutes = 2 * 60 * 1000;
Object lock = new Object();
while (true) {
synchronized (lock) {
lock.wait(twoMinutes);
}
// TODO add ping
}
} catch (AlreadyBoundExceptionInterruptedException | e) {
e.printStackTrace();
System.exit(42);
}
}
Example 31
Project: discobot-master File: JmxConnectorHelper.java View source code |
public static Map createRmiRegistry(int initPort) {
Map<String, Object> result = new HashMap<String, Object>(2);
int counter = 0;
int port = initPort;
Registry reg = null;
while (reg == null && counter <= 4) {
try {
reg = LocateRegistry.createRegistry(port);
result.put("registry", reg);
result.put("port", port);
break;
} catch (RemoteException ex) {
counter++;
port = port + 1;
System.out.println("JmxBuilder - *** FAILED *** to create RMI Registry - Will Retry on port [" + port + "].");
try {
Thread.currentThread().sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
return result;
}
Example 32
Project: eclipselink.runtime-master File: RMIServerManagerController.java View source code |
public static void start(Session session, String nameToBind, String controllerClassName) {
RMIServerManagerController manager = null;
// Set the security manager
try {
//System.setSecurityManager(new RMISecurityManager());
} catch (Exception exception) {
System.out.println("Security violation " + exception.toString());
}
// Make sure RMI registry is started.
try {
java.rmi.registry.LocateRegistry.createRegistry(1099);
} catch (Exception exception) {
System.out.println("Security violation " + exception.toString());
}
// Create local instance of the factory
try {
manager = new RMIServerManagerController(session, controllerClassName);
} catch (RemoteException exception) {
throw new TestProblemException(exception.toString());
}
// Put the local instance into the Registry
try {
Naming.unbind(nameToBind);
} catch (Exception exception) {
System.out.println("Security violation " + exception.toString());
}
// Put the local instance into the Registry
try {
Naming.rebind(nameToBind, manager);
} catch (Exception exception) {
throw new TestProblemException(exception.toString());
}
}
Example 33
Project: freehep-ncolor-pdf-master File: RmiTestServerImpl.java View source code |
private void connect() throws Exception {
int port = 1099;
int index = bindName.indexOf(":");
if (index > 0) {
String portString = bindName.substring(index + 1);
int index2 = portString.indexOf("/");
if (index2 > 0) {
portString = portString.substring(0, index2);
}
try {
int tmpPort = Integer.parseInt(portString);
port = tmpPort;
} catch (NumberFormatException nfe) {
nfe.printStackTrace();
System.exit(1);
}
}
try {
Naming.rebind(bindName, this);
} catch (ConnectException co) {
System.out.println("RmiServer: No RMI Registry is currently available for port=" + port + ". Starting new RMI Registry.");
LocateRegistry.createRegistry(port);
Naming.rebind(bindName, this);
}
System.out.println("RmiTestServer is ready on: " + bindName);
}
Example 34
Project: GeneDiseasePaper-master File: RMIMasterServer.java View source code |
public static Registry getRegistry(int serverport, int objectport, String servername) throws RemoteException { try { NamedSocketFactory.install(objectport); } catch (IOException e) { e.printStackTrace(); } try { System.setProperty("java.rmi.server.hostname", servername); return LocateRegistry.createRegistry(serverport); } catch (RemoteException exists) { System.setProperty("java.rmi.server.hostname", servername); return LocateRegistry.getRegistry(servername, serverport); } }
Example 35
Project: GraphDHT-master File: ListRMIRegistry.java View source code |
/** * @param args */ public static void main(String[] args) { // if (System.getSecurityManager() == null) { // System.setSecurityManager(new SecurityManager()); // } String host = args[0]; int port = 0; try { port = Integer.parseInt(args[1]); } catch (Exception e) { } Registry r = null; try { if (port != 0) { r = LocateRegistry.getRegistry(host, port); } else { r = LocateRegistry.getRegistry(host); } String[] names = r.list(); System.out.println("Registered services in RMIRegistry at " + host + ":" + port); for (String name : names) { System.out.print("- " + name + ", Stub: "); try { Remote stub = r.lookup(name); System.out.println(stub.toString()); } catch (Exception e) { System.out.println("UNKNOWN"); } } } catch (RemoteException e) { System.err.println("Could not connect to RMIRegistry at " + host + " on port " + port); System.err.println(e.getMessage()); e.printStackTrace(); System.exit(-1); } }
Example 36
Project: groovy-core-master File: JmxConnectorHelper.java View source code |
public static Map createRmiRegistry(int initPort) {
Map<String, Object> result = new HashMap<String, Object>(2);
int counter = 0;
int port = initPort;
Registry reg = null;
while (reg == null && counter <= 4) {
try {
reg = LocateRegistry.createRegistry(port);
result.put("registry", reg);
result.put("port", port);
break;
} catch (RemoteException ex) {
counter++;
port = port + 1;
System.out.println("JmxBuilder - *** FAILED *** to create RMI Registry - Will Retry on port [" + port + "].");
try {
Thread.currentThread().sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
return result;
}
Example 37
Project: groovy-master File: JmxConnectorHelper.java View source code |
public static Map createRmiRegistry(int initPort) {
Map<String, Object> result = new HashMap<String, Object>(2);
int counter = 0;
int port = initPort;
Registry reg = null;
while (reg == null && counter <= 4) {
try {
reg = LocateRegistry.createRegistry(port);
result.put("registry", reg);
result.put("port", port);
break;
} catch (RemoteException ex) {
counter++;
port = port + 1;
System.out.println("JmxBuilder - *** FAILED *** to create RMI Registry - Will Retry on port [" + port + "].");
try {
Thread.currentThread().sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
return result;
}
Example 38
Project: hudson_plugins-master File: PluginImpl.java View source code |
private static MBeanServer getJMXConnectorServer() {
MBeanServer server = getPlatformMBeanServer();
try {
LocateRegistry.createRegistry(JMX_PORT);
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + getHostName() + ":" + JMX_PORT + "/hudson");
JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
connectorServer.start();
return connectorServer.getMBeanServer();
} catch (MalformedURLException ex) {
LOGGER.log(Level.SEVERE, "Failed to start RMI connector for JMX", ex);
} catch (RemoteException ex) {
LOGGER.log(Level.SEVERE, "Failed to start RMI connector for JMX", ex);
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, "Failed to start RMI connector for JMX", ex);
}
// fall back
return server;
}
Example 39
Project: interface_sdk-master File: ModuleRMIHelper.java View source code |
@Override
protected ModuleManagerRemote getManager() throws ModuleManagerCommunicationException {
Registry registry;
try {
registry = LocateRegistry.getRegistry("localhost", ModuleManagerRunner.RMI_REGISTRY_PORT);
ModuleManagerRemote obj = (ModuleManagerRemote) registry.lookup(ModuleManagerRunner.RMI_SERVER_NAME);
log.debug("Got an instance of ModuleManager via RMI?");
return obj;
} catch (RemoteException e) {
throw new ModuleManagerCommunicationException();
} catch (NotBoundException e) {
throw new ModuleManagerCommunicationException();
}
}
Example 40
Project: java-core-test-master File: ComputerServer.java View source code |
public static void main(String[] args) throws Exception {
if (args.length < 1) {
throw new IllegalArgumentException("Argument length must be greater than 1");
}
Computer remoteObj = new ComputerImpl();
Computer stubObj = (Computer) UnicastRemoteObject.exportObject(remoteObj, 0);
Registry localReg = LocateRegistry.getRegistry();
localReg.rebind(args[0], stubObj);
}
Example 41
Project: jolie-dbus-master File: RMICommChannelFactory.java View source code |
public CommChannel createChannel(URI location, OutputPort port) throws IOException {
try {
Registry registry = LocateRegistry.getRegistry(location.getHost(), location.getPort());
JolieRemote remote = (JolieRemote) registry.lookup(location.getPath());
return new RMICommChannel(remote.createRemoteBasicChannel());
} catch (NotBoundException e) {
throw new IOException(e);
}
}
Example 42
Project: moonshine-master File: RmiRegistry.java View source code |
@Override
protected void configure() {
Registry registry;
try {
registry = LocateRegistry.createRegistry(rmiRegistryPort);
} catch (RemoteException e) {
throw new RuntimeException("Cannot create RMI registry on port: " + rmiRegistryPort, e);
}
UnicastRef ref = (UnicastRef) ((RegistryImpl) registry).getRef();
final int port = ref.getLiveRef().getPort();
RmiRegistryPort portProvider = () -> port;
if (getId() != null) {
bind(RmiRegistryPort.class).annotatedWith(Names.named(getId())).toInstance(portProvider);
} else {
bind(RmiRegistryPort.class).toInstance(portProvider);
}
}
Example 43
Project: myLib-master File: JMXServerFactory.java View source code |
/**
* open jmx remote server(with port number)
* @param port target port number.
*/
public static void openJMXRemoteServer(int port) throws Exception {
JMXServerFactory.port = port;
LocateRegistry.createRegistry(port);
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + port + "/jmxrmi");
JMXConnectorServer server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, JMXFactory.getMBeanServer());
server.start();
}
Example 44
Project: odo-master File: Server.java View source code |
private void startServer() {
try {
// create on port 1298
registry = LocateRegistry.createRegistry(port);
// create a new service named hostsService
registry.rebind(SERVICE_NAME, new MessageImpl());
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("system is ready on port " + port);
}
Example 45
Project: openchord-fork-master File: ListRMIRegistry.java View source code |
/** * @param args */ public static void main(String[] args) { // if (System.getSecurityManager() == null) { // System.setSecurityManager(new SecurityManager()); // } String host = args[0]; int port = 0; try { port = Integer.parseInt(args[1]); } catch (Exception e) { } Registry r = null; try { if (port != 0) { r = LocateRegistry.getRegistry(host, port); } else { r = LocateRegistry.getRegistry(host); } String[] names = r.list(); System.out.println("Registered services in RMIRegistry at " + host + ":" + port); for (String name : names) { System.out.print("- " + name + ", Stub: "); try { Remote stub = r.lookup(name); System.out.println(stub.toString()); } catch (Exception e) { System.out.println("UNKNOWN"); } } } catch (RemoteException e) { System.err.println("Could not connect to RMIRegistry at " + host + " on port " + port); System.err.println(e.getMessage()); e.printStackTrace(); System.exit(-1); } }
Example 46
Project: openjdk-master File: RegistryLookup.java View source code |
public static void main(String args[]) throws Exception {
Registry registry = null;
int exit = 0;
try {
int port = Integer.valueOf(args[0]);
testPkg.Server obj = new testPkg.Server();
testPkg.Hello stub = (testPkg.Hello) UnicastRemoteObject.exportObject(obj, 0);
// Bind the remote object's stub in the registry
registry = LocateRegistry.getRegistry(port);
registry.bind("Hello", stub);
System.err.println("Server ready");
testPkg.Client client = new testPkg.Client(port);
String testStubReturn = client.testStub();
if (!testStubReturn.equals(obj.hello)) {
throw new RuntimeException("Test Fails : " + "unexpected string from stub call");
}
registry.unbind("Hello");
System.out.println("Test passed");
} catch (Exception ex) {
exit = EXIT_FAIL;
ex.printStackTrace();
}
// need to exit explicitly, and parent process uses exit value
// to tell if the test passed.
System.exit(exit);
}
Example 47
Project: pieShareExp-master File: CmdServerService.java View source code |
private void registerService() {
try {
this.registry = LocateRegistry.createRegistry(this.pieService.getPieceptionRegistryPort());
this.registry.rebind(this.pieService.getPieceptionBindingName(), this);
} catch (RemoteException ex) {
logger.debug("Pieception failed! Err: " + ex.getMessage());
}
}
Example 48
Project: qi4j-sandbox-master File: RMIMixinTest.java View source code |
@Test
public void testRMIMixin() throws Exception {
// Instantiate, export, and bind server object
RemoteInterfaceImpl remoteObject = new RemoteInterfaceImpl();
RemoteInterface stub = (RemoteInterface) UnicastRemoteObject.exportObject(remoteObject, 0);
Registry registry = LocateRegistry.createRegistry(1099);
registry.rebind(RemoteInterface.class.getSimpleName(), stub);
RemoteInterface remote = transientBuilderFactory.newTransient(RemoteInterfaceComposite.class);
// MethodCallExpression remote interface
System.out.println(remote.foo("Bar"));
try {
System.out.println(remote.foo("Zyx"));
Assert.fail("Should have thrown IOException ");
} catch (IOException e) {
}
}
Example 49
Project: rSYBL-master File: RMIServer.java View source code |
public static void main(String args[]) {
try {
//System.setSecurityManager(new SecurityManager());
LocalProcessing obj = new LocalProcessing();
LocalProcessingInterface stub = (LocalProcessingInterface) UnicastRemoteObject.exportObject((Remote) obj, 0);
// Bind the remote object's stub in the registry
Registry registry = null;
registry = LocateRegistry.createRegistry(Configuration.getRMIPort());
registry.rebind(Configuration.getRMIName(), stub);
} catch (RemoteException e) {
e.printStackTrace();
}
}
Example 50
Project: SiteGraphThumbnailer-master File: Thumbnailer.java View source code |
public static void main(String args[]) {
QApplication.initialize(args);
System.setProperty("java.security.policy", "file:///D://t.policy");
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
try {
IImageThumbnailer engine = new ImageThumbnailerImpl();
IImageThumbnailer stub = (IImageThumbnailer) UnicastRemoteObject.exportObject(engine, 0);
IPdfThumbnailer pdfEngine = new PdfThumbnailerImpl();
IPdfThumbnailer pdfStub = (IPdfThumbnailer) UnicastRemoteObject.exportObject(pdfEngine, 0);
Registry registry = LocateRegistry.getRegistry();
registry.bind(IMAGE_SERVICE_END_POINT, stub);
System.out.println("Image Service bound");
registry.bind(PDF_SERVICE_END_POINT, pdfStub);
System.out.println("Pdf Service bound");
} catch (Exception e) {
System.err.println("Image Service exception:");
e.printStackTrace();
}
System.out.println("Initializing Qapplication engine ");
QApplication.exec();
}
Example 51
Project: TTV-master File: ListRMIRegistry.java View source code |
/** * @param args */ public static void main(String[] args) { // if (System.getSecurityManager() == null) { // System.setSecurityManager(new SecurityManager()); // } String host = args[0]; int port = 0; try { port = Integer.parseInt(args[1]); } catch (Exception e) { } Registry r = null; try { if (port != 0) { r = LocateRegistry.getRegistry(host, port); } else { r = LocateRegistry.getRegistry(host); } String[] names = r.list(); System.out.println("Registered services in RMIRegistry at " + host + ":" + port); for (String name : names) { System.out.print("- " + name + ", Stub: "); try { Remote stub = r.lookup(name); System.out.println(stub.toString()); } catch (Exception e) { System.out.println("UNKNOWN"); } } } catch (RemoteException e) { System.err.println("Could not connect to RMIRegistry at " + host + " on port " + port); System.err.println(e.getMessage()); e.printStackTrace(); System.exit(-1); } }
Example 52
Project: UBlog-Benchmark-master File: Server.java View source code |
public static void main(String args[]) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
String name = "Graph";
GraphImpl graphimpl = new GraphImpl();
GraphInterface stub = (GraphInterface) UnicastRemoteObject.exportObject(graphimpl);
Registry registry = LocateRegistry.createRegistry(1099);
registry.rebind(name, stub);
System.out.println("Graph exported");
} catch (Exception e) {
System.err.println("Graph exception:");
e.printStackTrace();
}
}
Example 53
Project: windup-master File: ToolingRMIServer.java View source code |
public void startServer(int port, String version) { LOG.info("Registering RMI Server..."); try { executionBuilder.setVersion(version); Registry registry = LocateRegistry.getRegistry(port); try { String[] registered = registry.list(); if (Arrays.asList(registered).contains(ExecutionBuilder.LOOKUP_NAME)) registry.unbind(ExecutionBuilder.LOOKUP_NAME); try { UnicastRemoteObject.unexportObject(executionBuilder, true); } catch (Throwable t) { LOG.warning("Could not unexport due to: " + t.getMessage()); } } catch (Throwable t) { t.printStackTrace(); LOG.warning("Registry not already there, starting..."); registry = LocateRegistry.createRegistry(port); } ExecutionBuilder proxy = (ExecutionBuilder) UnicastRemoteObject.exportObject(executionBuilder, 0); registry.rebind(ExecutionBuilder.LOOKUP_NAME, proxy); LOG.info("Registered ExecutionBuilder at: " + registry); } catch (RemoteException e) { LOG.severe("Bootstrap error while registering ExecutionBuilder..."); e.printStackTrace(); } }
Example 54
Project: ysoserial-master File: RMIRegistryExploit.java View source code |
public static void main(final String[] args) throws Exception {
final String host = args[0];
final int port = Integer.parseInt(args[1]);
final String command = args[3];
final Registry registry = LocateRegistry.getRegistry(host, port);
final String className = CommonsCollections1.class.getPackage().getName() + "." + args[2];
final Class<? extends ObjectPayload> payloadClass = (Class<? extends ObjectPayload>) Class.forName(className);
// ensure payload doesn't detonate during construction or deserialization
exploit(registry, payloadClass, command);
}
Example 55
Project: BestPlace-master File: TestEntropy.java View source code |
/**
* Test the registration to a existing registry.
*/
public void testWithExistantRegistry() {
final MockControlLoop mock = new MockControlLoop();
Entropy e = new Entropy(mock);
try {
LocateRegistry.createRegistry(4567);
e.setRegistryPort(4567);
Assert.assertFalse(e.isRunning());
e.startup();
Assert.assertTrue(e.isRunning());
e.shutdown();
Assert.assertFalse(e.isRunning());
} catch (Exception e2) {
Assert.fail(e2.getMessage(), e2);
}
}
Example 56
Project: brix-cms-master File: WorkspaceManagerExporterBean.java View source code |
public void afterPropertiesSet() throws Exception { try { 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); }
Example 57
Project: compass-fork-master File: CollectionTests.java View source code |
protected void setUp() throws Exception {
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
System.setProperty(Context.PROVIDER_URL, "rmi://localhost:1099");
try {
java.rmi.registry.LocateRegistry.createRegistry(1099);
} catch (Exception e) {
}
jotm = new Jotm(true, true);
Context ctx = new InitialContext();
ctx.rebind("java:comp/UserTransaction", jotm.getUserTransaction());
CompassConfiguration cpConf = new CompassConfiguration().configure("/org/compass/gps/device/hibernate/collection/compass.cfg.xml");
cpConf.getSettings().setBooleanSetting(CompassEnvironment.DEBUG, true);
compass = cpConf.buildCompass();
fileHandlerMonitor = FileHandlerMonitor.getFileHandlerMonitor(compass);
fileHandlerMonitor.verifyNoHandlers();
compass.getSearchEngineIndexManager().deleteIndex();
compass.getSearchEngineIndexManager().verifyIndex();
compassTemplate = new CompassTemplate(compass);
compassGps = new SingleCompassGps(compass);
Configuration conf = new Configuration().configure("/org/compass/gps/device/hibernate/collection/hibernate.cfg.xml").setProperty(Environment.HBM2DDL_AUTO, "create");
sessionFactory = conf.buildSessionFactory();
HibernateGpsDevice device = new HibernateGpsDevice();
device.setSessionFactory(sessionFactory);
device.setName("hibernateDevice");
compassGps.addGpsDevice(device);
compassGps.start();
}
Example 58
Project: consulo-master File: RemoteServer.java View source code |
@SuppressWarnings("UseOfSystemOutOrSystemErr")
protected static void start(Remote remote) throws Exception {
setupRMI();
banJNDI();
if (ourRemote != null)
throw new AssertionError("Already started");
ourRemote = remote;
Registry registry;
int port;
for (Random random = new Random(); ; ) {
port = random.nextInt(0xffff);
if (port < 4000)
continue;
try {
registry = LocateRegistry.createRegistry(port);
break;
} catch (ExportException ignored) {
}
}
try {
Remote stub = UnicastRemoteObject.exportObject(ourRemote, 0);
final String name = remote.getClass().getSimpleName() + Integer.toHexString(stub.hashCode());
registry.bind(name, stub);
String id = port + "/" + name;
System.out.println("Port/ID: " + id);
long waitTime = 2 * 60 * 1000L;
Object lock = new Object();
//noinspection InfiniteLoopStatement
while (true) {
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (lock) {
lock.wait(waitTime);
}
RemoteDeadHand deadHand = (RemoteDeadHand) registry.lookup(RemoteDeadHand.BINDING_NAME);
waitTime = deadHand.ping(id);
}
} catch (Throwable e) {
e.printStackTrace(System.err);
System.exit(1);
}
}
Example 59
Project: consumer-dispatcher-master File: ConsumerDispatcherMonitor.java View source code |
protected static void enableJMXRmi() throws IOException {
MonitorConf config = DispatcherConfig.getInstance().getMonitorConf();
LocateRegistry.createRegistry(config.getJmxRmiPort());
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
String address = String.format(fmtUrl, config.getJmxRmiHost(), config.getJmxRmiPort());
JMXServiceURL url = new JMXServiceURL(address);
JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
cs.start();
_logger.info("JMX enabled on:" + address);
}
Example 60
Project: coprhd-controller-master File: JmxServerWrapper.java View source code |
public void start() throws Exception {
log.debug("JMX server wrapper: jmx enabled ={} ", _jmxEnabled);
if (_jmxEnabled) {
try {
LocateRegistry.createRegistry(_jmxRemotePort);
log.info("start bind JMX to {}:{} serviceurl: {}", new Object[] { _jmxHost, _jmxRemotePort, _jmxFmtUrl });
JMXServiceURL jmxUrl = new JMXServiceURL(String.format(_jmxFmtUrl, _jmxRemoteExportPort, _jmxHost, _jmxRemotePort));
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
_jmxRemoteServer = JMXConnectorServerFactory.newJMXConnectorServer(jmxUrl, null, mbs);
_jmxRemoteServer.start();
jmxc = _jmxRemoteServer.toJMXConnector(null);
} catch (Exception e) {
log.error("JMX server startup failed", e);
throw e;
}
}
}
Example 61
Project: evosuite-master File: ClientServices.java View source code |
public boolean registerServices() {
UtilsRMI.ensureRegistryOnLoopbackAddress();
try {
int port = Properties.PROCESS_COMMUNICATION_PORT;
Registry registry = LocateRegistry.getRegistry(port);
clientNode = new ClientNodeImpl(registry);
ClientNodeRemote stub = (ClientNodeRemote) UtilsRMI.exportObject(clientNode);
registry.rebind(clientNode.getClientRmiIdentifier(), stub);
return clientNode.init();
} catch (Exception e) {
logger.error("Failed to register client services", e);
return false;
}
}
Example 62
Project: fcrepo-before33-master File: MockRmiJournalReceiver.java View source code |
/**
* Use this if you need to create an actual RMI connection to test the
* RmiTransport.
*/
public static void main(String[] args) throws RemoteException, AlreadyBoundException {
trace = true;
try {
MockRmiJournalReceiver receiver = new MockRmiJournalReceiver();
if (Arrays.asList(args).contains("throwException")) {
receiver.setOpenFileThrowsException(true);
}
Registry registry = LocateRegistry.createRegistry(1099);
registry.bind("RmiJournalReceiver", receiver);
Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
}
Example 63
Project: fos-core-master File: Runner.java View source code |
/**
* Launches the server.
* See @{link StartupConfiguration} for command line switches.
* <p/> Will start an embedded RMI registry if "-s" was specified.
*
* @param args the command line switches
* @throws ConfigurationException
*/
public static void main(String... args) throws ConfigurationException {
long time = System.currentTimeMillis();
StartupConfiguration parameters = new StartupConfiguration();
JCommander jCommander = new JCommander(parameters);
FosServer fosServer;
try {
jCommander.parse(args);
logger.info("Starting fos server using configuration from {}", parameters.getConfiguration());
FosConfig serverConfig = new FosConfig(new PropertiesConfiguration(parameters.getConfiguration()));
if (serverConfig.isEmbeddedRegistry()) {
LocateRegistry.createRegistry(serverConfig.getRegistryPort());
logger.debug("RMI registry started in port {}", serverConfig.getRegistryPort());
}
fosServer = new FosServer(serverConfig);
fosServer.bind();
logger.info("FOS Server started in {}ms", (System.currentTimeMillis() - time));
} catch (ParameterException e) {
jCommander.usage();
} catch (Exception e) {
logger.error("Could not launch RMI service", e);
}
}
Example 64
Project: fourinone-master File: BeanService.java View source code |
static final void putBean(String TPYFWYM, boolean TPYRZDY, int TPYDK, String rmname, ParkActive paobj) { if (TPYFWYM != null) System.setProperty(ConfigContext.getYMMZ(), TPYFWYM); if (TPYRZDY) System.setProperty(ConfigContext.getRZDY(), "true"); try { LocateRegistry.getRegistry(TPYDK).list(); } catch (Exception ex) { try { UnicastRemoteObject.exportObject(paobj, 0); Registry rgsty = LocateRegistry.createRegistry(TPYDK); rgsty.rebind(rmname, paobj); } catch (Exception e) { LogUtil.info("[ObjectService]", "[regObject]", "[Error Exception:]", e); } } }
Example 65
Project: fullsync-master File: RemoteController.java View source code |
public void startServer(int port, String password, ProfileManager profileManager, Synchronizer sync) throws RemoteException {
try {
this.port = port;
serverURL = "rmi://localhost:" + port + "/FullSync";
this.password = password;
if (remoteServer == null) {
remoteServer = new RemoteServer(profileManager, sync);
remoteServer.setPassword(password);
}
if (registry == null) {
registry = LocateRegistry.createRegistry(port);
}
Naming.rebind(serverURL, remoteServer);
isActive = true;
} catch (MalformedURLException e) {
ExceptionHandler.reportException(e);
}
}
Example 66
Project: hbci4javaserver-master File: ListenerPinTan.java View source code |
public void start() { HBCIUtils.log("starting rmi server as pintan listener", HBCIUtils.LOG_DEBUG); try { Registry reg = null; try { reg = LocateRegistry.createRegistry(Registry.REGISTRY_PORT); HBCIUtils.log("starting new registry", HBCIUtils.LOG_DEBUG); } catch (Exception e) { reg = LocateRegistry.getRegistry(Registry.REGISTRY_PORT); HBCIUtils.log("using already running registry", HBCIUtils.LOG_DEBUG); } reg.rebind("pintanListener", new RMIListenerImpl()); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
Example 67
Project: JBossAS51-master File: Server.java View source code |
public static void main(String[] args) throws Exception {
MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
int registryPort = Registry.REGISTRY_PORT;
Registry rmiRegistry = LocateRegistry.createRegistry(registryPort);
String jndiPath = "/jmxconnector";
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:" + registryPort + jndiPath);
// create new connector server and start it
JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
connectorServer.start();
System.out.println("Connector server started.");
//UnicastRemoteObject.unexportObject(rmiRegistry, true);
}
Example 68
Project: JBossAS_5_1_EDG-master File: Server.java View source code |
public static void main(String[] args) throws Exception {
MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
int registryPort = Registry.REGISTRY_PORT;
Registry rmiRegistry = LocateRegistry.createRegistry(registryPort);
String jndiPath = "/jmxconnector";
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:" + registryPort + jndiPath);
// create new connector server and start it
JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
connectorServer.start();
System.out.println("Connector server started.");
//UnicastRemoteObject.unexportObject(rmiRegistry, true);
}
Example 69
Project: jbosstools-integration-tests-master File: SimUtil.java View source code |
protected static void startRMI(IBrowsersimHandler handler, String handlerName, String mainClass, String[] args) {
try {
try {
UnicastRemoteObject.unexportObject(handler, true);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("RMI: export handler object");
handlerStub = (IBrowsersimHandler) UnicastRemoteObject.exportObject(handler, 0);
System.out.println("RMI: get regitry");
Registry registry = LocateRegistry.getRegistry();
System.out.println("RMI: registry rebind");
registry.rebind(handlerName, handlerStub);
System.out.println("Server is ready.");
} catch (Exception e) {
System.out.println("Server failed: " + e);
}
waitForSim(handler);
openSim(mainClass, args);
}
Example 70
Project: Jetwick-master File: RMIClient.java View source code |
public RMIClient init() {
if (service != null)
return this;
try {
// logger.info("sending to " + config.getRMIHost() + ":" + config.getRMIPort()
// + " using " + config.getRMIService());
Registry registry = LocateRegistry.getRegistry(config.getRMIHost(), config.getRMIPort());
// look up the remote object
service = (CommunicationService) registry.lookup(config.getRMIService());
return this;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
Example 71
Project: JFOA-master File: HelloServer.java View source code |
public static void main(String[] args) {
try {
//创建一个远程对象
IHello rhello = new HelloImpl();
//本地主机上的远程对象注册表Registry的实例,并指定端å?£ä¸º8888,这一æ¥å¿…ä¸?å?¯å°‘(Java默认端å?£æ˜¯1099),必ä¸?å?¯ç¼ºçš„一æ¥ï¼Œç¼ºå°‘æ³¨å†Œè¡¨åˆ›å»ºï¼Œåˆ™æ— æ³•ç»‘å®šå¯¹è±¡åˆ°è¿œç¨‹æ³¨å†Œè¡¨ä¸Š
LocateRegistry.createRegistry(8888);
//把远程对象注册到RMI注册æœ?务器上,并命å??为RHello
//绑定的URLæ ‡å‡†æ ¼å¼?为:rmi://host:port/name(å…¶ä¸å??è®®å??å?¯ä»¥çœ?略,下é?¢ä¸¤ç§?写法都是æ£ç¡®çš„)
Naming.bind("rmi://localhost:8888/RHello", rhello);
// Naming.bind("//localhost:8888/RHello",rhello);
System.out.println(">>>>>INFO:远程IHello对象绑定�功�");
} catch (RemoteException e) {
System.out.println("创建远程对象�生异常�");
e.printStackTrace();
} catch (AlreadyBoundException e) {
System.out.println("�生��绑定对象异常�");
e.printStackTrace();
} catch (MalformedURLException e) {
System.out.println("�生URL畸形异常�");
e.printStackTrace();
}
}
Example 72
Project: jmx-cli-master File: JmxAgent.java View source code |
public void start() throws Exception {
System.out.println("Starting JmxAgent on RMI port " + port);
System.setProperty("java.rmi.server.randomIDs", "true");
reg = LocateRegistry.createRegistry(port);
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
HashMap<String, Object> env = new HashMap<String, Object>();
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + port + "/jmxrmi");
server = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
System.out.println("Agent RMI connector exported with url " + url.toString());
server.start();
}
Example 73
Project: jqm-master File: JmxAgent.java View source code |
static synchronized void registerAgent(int registryPort, int serverPort, String hostname) throws JqmInitError {
if (init) {
// The agent is JVM-global, not engine specific, so prevent double start.
return;
}
jqmlogger.trace("registering remote agent");
try {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
JndiContext ctx = (JndiContext) NamingManager.getInitialContext(null);
ctx.registerRmiContext(LocateRegistry.createRegistry(registryPort));
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://" + hostname + ":" + serverPort + "/jndi/rmi://" + hostname + ":" + registryPort + "/jmxrmi");
JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
cs.start();
init = true;
jqmlogger.info("The JMX remote agent was registered. Connection string is " + url);
} catch (Exception e) {
throw new JqmInitError("Could not create remote JMX agent", e);
}
}
Example 74
Project: l4ia-master File: SearchServer.java View source code |
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("Usage: SearchServer <basedir>");
System.exit(-1);
}
//1
String basedir = args[0];
Directory[] dirs = new Directory[ALPHABET.length()];
Searchable[] searchables = new Searchable[ALPHABET.length()];
for (int i = 0; i < ALPHABET.length(); i++) {
dirs[i] = FSDirectory.open(new File(basedir, "" + ALPHABET.charAt(i)));
searchables[i] = new //2
IndexSearcher(//2
dirs[i]);
}
//3
LocateRegistry.createRegistry(1099);
//4
Searcher multiSearcher = new MultiSearcher(searchables);
RemoteSearchable //4
multiImpl = //4
new RemoteSearchable(multiSearcher);
//4
Naming.rebind("//localhost/LIA_Multi", multiImpl);
Searcher //5
parallelSearcher = //5
new ParallelMultiSearcher(searchables);
RemoteSearchable //5
parallelImpl = //5
new RemoteSearchable(parallelSearcher);
//5
Naming.rebind("//localhost/LIA_Parallel", parallelImpl);
System.out.println("Server started");
for (int i = 0; i < ALPHABET.length(); i++) {
dirs[i].close();
}
}
Example 75
Project: manifold-master File: Filenet.java View source code |
public static void main(String[] args) {
try {
java.rmi.registry.Registry r = java.rmi.registry.LocateRegistry.createRegistry(8305, new RMILocalClientSocketFactory(), new RMILocalSocketFactory());
// Registry started OK
System.out.println("FileNet Registry started and awaiting connections.");
// Sleep forever, until process is externally terminated
while (true) {
Thread.sleep(10000L);
}
} catch (InterruptedException e) {
} catch (RemoteException er) {
System.err.println("Remote exception in FileNet.main: " + er);
er.printStackTrace(System.err);
}
}
Example 76
Project: neo4j-components-svn-master File: RmiSailTest.java View source code |
public static void main(String[] args) throws Exception {
/* RESTORE ME
LocateRegistry.createRegistry( PORT );
final GraphDatabaseService graphDb = TestUtils.createGraphDb();
final IndexService idx = new CachingLuceneIndexService( graphDb );
Runtime.getRuntime().addShutdownHook( new Thread()
{
@Override
public void run()
{
TestUtils.deleteEntireNodeSpace( graphDb );
idx.shutdown();
graphDb.shutdown();
}
} );
RdfStore store = createStore( graphDb, idx );
new BatchInserter( graphDb, store )
.insert( BatchInserter.listFiles( args ) );
RmiSailServer.register( new GraphDbSail( graphDb, store ), new java.net.URI(
RESOURCE_URI ) );
System.out.println( "Server started" );
*/
}
Example 77
Project: org.ops4j.pax.exam2-master File: SuiteTest.java View source code |
private void checkNumberOfRestartsInSuite(int numRestarts) throws Exception {
FreePort freePort = new FreePort(20000, 21000);
int rmiPort = freePort.getPort();
System.setProperty("pax.exam.regression.rmi", Integer.toString(rmiPort));
Registry registry = LocateRegistry.createRegistry(rmiPort);
Remote remote = UnicastRemoteObject.exportObject(this, 0);
registry.rebind("PaxExamNotifier", remote);
TestNG testNG = new TestNG();
testNG.setVerbose(0);
testNG.setTestClasses(new Class[] { FilterTest.class, InjectTest.class });
testNG.run();
registry.unbind("PaxExamNotifier");
UnicastRemoteObject.unexportObject(this, true);
UnicastRemoteObject.unexportObject(registry, true);
assertEquals(messages.size(), numRestarts);
}
Example 78
Project: org.ops4j.pax.swissbox-master File: RemoteObjectTest.java View source code |
@Test
public void exportAndUnexport() throws RemoteException, AlreadyBoundException, NotBoundException {
URL location = getClass().getProtectionDomain().getCodeSource().getLocation();
System.setProperty("java.rmi.server.codebase", location.toString());
HelloServiceImpl hello = new HelloServiceImpl();
Registry registry = LocateRegistry.getRegistry(REGISTRY_PORT);
UnicastRemoteObject.exportObject(hello, 0);
registry.rebind("hello", hello);
HelloService remoteHello = (HelloService) registry.lookup("hello");
assertThat(remoteHello.getMessage(), is("Hello Pax!"));
registry.unbind("hello");
UnicastRemoteObject.unexportObject(hello, true);
}
Example 79
Project: play-dcep-master File: SingleDistributedEtalisInstanceRunner.java View source code |
public static void main(String[] args) throws ADLException, IllegalLifeCycleException, NoSuchInterfaceException, ProActiveException, DistributedEtalisException, IOException {
CentralPAPropertyRepository.JAVA_SECURITY_POLICY.setValue("proactive.java.policy");
CentralPAPropertyRepository.GCM_PROVIDER.setValue("org.objectweb.proactive.core.component.Fractive");
//Start component.
Factory factory = FactoryFactory.getFactory();
HashMap<String, Object> context = new HashMap<String, Object>();
Component root = (Component) factory.newComponent("DistributedEtalis", context);
GCM.getGCMLifeCycleController(root).startFc();
// Register component.
Registry registry = LocateRegistry.getRegistry();
Fractive.registerByName(root, "dEtalis1");
//Configure component.
ConfigApi configApi = ((ConfigApi) root.getFcInterface(ConfigApi.class.getSimpleName()));
configApi.setConfig(new DetalisConfigLocal("play-epsparql-clic2call-historical-data.trig"));
//Subscribe to print complex events to local console.
// testApi = ((eu.play_project.dcep.distributedetalis.api.DistributedEtalisTestApi) root.getFcInterface(DistributedEtalisTestApi.class.getSimpleName()));
// try {
// subscriber = PAActiveObject.newActive(ComplexEventSubscriber.class, new Object[] {});
// } catch (ActiveObjectCreationException e) {
// e.printStackTrace();
// } catch (NodeException e) {
// e.printStackTrace();
// }
// testApi.attach(subscriber);
System.out.println("Press 3x RETURN to shutdown the application");
System.in.read();
System.in.read();
System.in.read();
}
Example 80
Project: pylucene-master File: RemoteTestCase.java View source code |
public static void startServer(Searchable searchable) throws Exception {
// publish it
// use our own factories for testing, so we can bind to an ephemeral port.
RMIClientSocketFactory clientFactory = new RMIClientSocketFactory() {
public Socket createSocket(String host, int port) throws IOException {
return new Socket(host, port);
}
};
class TestRMIServerSocketFactory implements RMIServerSocketFactory {
ServerSocket socket;
public ServerSocket createServerSocket(int port) throws IOException {
return (socket = new ServerSocket(port));
}
}
;
TestRMIServerSocketFactory serverFactory = new TestRMIServerSocketFactory();
LocateRegistry.createRegistry(0, clientFactory, serverFactory);
RemoteSearchable impl = new RemoteSearchable(searchable);
port = serverFactory.socket.getLocalPort();
Naming.rebind("//localhost:" + port + "/Searchable", impl);
}
Example 81
Project: railo-master File: CLIFactory.java View source code |
public static Registry getRegistry(int port) { Registry registry = null; try { registry = LocateRegistry.createRegistry(port); } catch (RemoteException e) { } try { if (registry == null) registry = LocateRegistry.getRegistry(port); } catch (RemoteException e) { } RemoteServer.setLog(System.out); return registry; }
Example 82
Project: rmiio-slf4j-master File: TestServer.java View source code |
public static void main(String[] args) throws Exception {
FileServer server = new FileServer();
RemoteFileServer stub = (RemoteFileServer) UnicastRemoteObject.exportObject(server, 0);
// bind to registry
Registry registry = LocateRegistry.getRegistry();
registry.bind("RemoteFileServer", stub);
System.out.println("Server ready");
}
Example 83
Project: siebog-master File: RemoteAgent.java View source code |
private RemoteListener getListener() {
try {
Registry reg = LocateRegistry.getRegistry(remoteHost);
return (RemoteListener) reg.lookup(RemoteListener.class.getSimpleName());
} catch (Exception ex) {
throw new IllegalArgumentException("Cannot connect to the remote RMI service at " + remoteHost + ".", ex);
}
}
Example 84
Project: socius-master File: ServerBoot.java View source code |
public void inicializarServidor() {
try {
// Registra com o RMI
int porta = Integer.parseInt(ConfigSistema.getProperty("servidor.porta_escuta"));
System.setProperty("java.rmi.server.hostname", ConfigSistema.getProperty("cliente.ip_servidor"));
LocateRegistry.createRegistry(porta);
//cria um objeto remoto
Servidor servidor = new Servidor();
// Cria objeto responsável pela autenticação, o aceso ao servidor
// apenas será possÃvel se este liberar
AutenticacaoRemota autenticador = new AutenticadorUsuario(servidor);
// Cria URL onde o servidor irá escutar
// Exemplo de saida: //localhost:443/socius
StringBuilder urlRMI = new StringBuilder();
urlRMI.append("rmi://");
urlRMI.append(ConfigSistema.getProperty("servidor.ip_escuta"));
urlRMI.append(":");
urlRMI.append(ConfigSistema.getProperty("servidor.porta_escuta"));
urlRMI.append("/");
urlRMI.append(ConfigSistema.getProperty("servidor.nome_servico"));
//setar a instancia corrente
Naming.rebind(urlRMI.toString(), autenticador);
// Inicia Thread que irá manter atualizada a lista de clientes online
new MantemListaComputadoresOnlineThread(servidor).start();
System.out.println("Servidor inicializado. Aguardando conexões...");
} catch (RemoteExceptionMalformedURLException | ex) {
Logger.getLogger(Servidor.class.getName()).log(Level.SEVERE, null, ex);
}
}
Example 85
Project: solrcene-master File: RemoteTestCaseJ4.java View source code |
public static void startServer(Searchable searchable) throws Exception {
// publish it
// use our own factories for testing, so we can bind to an ephemeral port.
RMIClientSocketFactory clientFactory = new RMIClientSocketFactory() {
public Socket createSocket(String host, int port) throws IOException {
return new Socket(host, port);
}
};
class TestRMIServerSocketFactory implements RMIServerSocketFactory {
ServerSocket socket;
public ServerSocket createServerSocket(int port) throws IOException {
return (socket = new ServerSocket(port));
}
}
;
TestRMIServerSocketFactory serverFactory = new TestRMIServerSocketFactory();
LocateRegistry.createRegistry(0, clientFactory, serverFactory);
RemoteSearchable impl = new RemoteSearchable(searchable);
port = serverFactory.socket.getLocalPort();
Naming.rebind("//localhost:" + port + "/Searchable", impl);
}
Example 86
Project: spring-framework-2.5.x-master File: RmiRegistryFactoryBean.java View source code |
/**
* 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 explictly 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);
}
}
Example 87
Project: spring-framework-master File: RmiRegistryFactoryBean.java View source code |
/**
* 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);
}
}
Example 88
Project: spring-js-master File: RmiRegistryFactoryBean.java View source code |
/**
* 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 explictly 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);
}
}
Example 89
Project: transactions-essentials-master File: JtaTransactionServicePluginTestJUnit.java View source code |
@Before
public void setUp() throws Exception {
plugin = new JtaTransactionServicePlugin();
properties = new Properties();
properties.setProperty("com.atomikos.icatch.default_jta_timeout", "0");
properties.setProperty("com.atomikos.icatch.serial_jta_transactions", "true");
properties.setProperty("com.atomikos.icatch.client_demarcation", "true");
properties.setProperty("com.atomikos.icatch.tm_unique_name", "bla");
properties.setProperty("com.atomikos.icatch.rmi_export_class", "UnicastRemoteObject");
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
properties.setProperty(Context.PROVIDER_URL, "rmi://localhost:1099");
properties.setProperty("com.atomikos.icatch.automatic_resource_registration", "true");
try {
LocateRegistry.createRegistry(1099);
} catch (Exception ok) {
}
}
Example 90
Project: tuscany-sca-2.x-master File: OperationsRMIServer.java View source code |
public void run() {
try {
System.out.println("Starting the RMI server for calculator operations...");
Remote stub = UnicastRemoteObject.exportObject(OperationsRMIServer.this);
registry = LocateRegistry.createRegistry(8085);
registry.bind("AddService", stub);
registry.bind("SubtractService", stub);
registry.bind("MultiplyService", stub);
registry.bind("DivideService", stub);
System.out.println("RMI server for calculator operations is now started.");
} catch (Exception e) {
e.printStackTrace();
}
}
Example 91
Project: zoodb-master File: RmiTestRunner.java View source code |
public static void main(String[] args) {
// System.out.println("RmiTestRunner started: " + args[0]);
// System.out.println("RmiTestRunner time: " + new Date());
System.setSecurityManager(new NoSecurityManager());
try {
RmiTestRunner engine = new RmiTestRunner();
RmiTestRunnerAPI stub = (RmiTestRunnerAPI) UnicastRemoteObject.exportObject(engine, 0);
Registry registry = LocateRegistry.getRegistry();
registry.rebind(RmiTaskLauncher.RMI_NAME, stub);
// System.out.println("RmiTestRunner bound");
} catch (Exception e) {
e.printStackTrace();
}
// System.out.println("RmiTestRunner finished: " + args[0]);
}
Example 92
Project: activemq-master File: RemoteJMXBrokerFailoverTest.java View source code |
private void configureMBeanServer(BrokerService brokerService, int port) throws IOException {
// shared fs master/slave
brokerService.getPersistenceAdapter().setDirectory(new File(brokerService.getDataDirectoryFile(), "shared"));
ManagementContext managementContext = brokerService.getManagementContext();
// have mbean servers remain alive - like in karaf container
MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(managementContext.getJmxDomainName());
Registry registry = LocateRegistry.createRegistry(port + 1);
JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(new JMXServiceURL("service:jmx:rmi://localhost:" + port + "/jndi/rmi://localhost:" + (port + 1) + "/jmxrmi"), null, mbeanServer);
connectorServer.start();
serverList.addFirst(connectorServer);
managementContext.setMBeanServer(mbeanServer);
managementContext.setCreateConnector(false);
}
Example 93
Project: atmosphere-extensions-master File: RMIPluginTest.java View source code |
/**
* Test for filter.
*
* @throws Exception if test fails
*/
@Test
public void usingRmiFilter() throws Exception {
// Will contain the broadcasted message received from RMI
final List<Object> receivedMessages = new ArrayList<Object>();
final RMIBroadcastService service = new RMIBroadcastServiceImpl(null) {
@Override
public void send(Object message) {
receivedMessages.add(message);
}
};
// Create server notified by the filter
final Registry registry = LocateRegistry.createRegistry(4001);
registry.bind(RMIBroadcastService.class.getSimpleName() + "/RMITopic", service);
// Create broadcaster
final AtmosphereConfig config = new AtmosphereFramework().getAtmosphereConfig();
final DefaultBroadcasterFactory factory = new DefaultBroadcasterFactoryForTest(DefaultBroadcaster.class, "NEVER", config);
config.framework().setBroadcasterFactory(factory);
final Broadcaster broadcaster = factory.get(DefaultBroadcaster.class, "RMITopic");
broadcaster.getBroadcasterConfig().addFilter(new RMIFilter());
// Expect to receive the message in localhost:4001
broadcaster.broadcast("Use RMI");
// Check that the message has been received
assertEquals(1, receivedMessages.size());
assertEquals("Use RMI", receivedMessages.get(0));
}
Example 94
Project: bluecove-master File: Server.java View source code |
private void startRMIRegistry(String port) {
try {
if ((port != null) && (port.length() > 0)) {
rmiRegistryPort = Integer.parseInt(port);
}
registry = LocateRegistry.createRegistry(rmiRegistryPort);
} catch (RemoteException e) {
throw new Error("Fails to start RMIRegistry", e);
}
}
Example 95
Project: components-ness-jmx-master File: JmxExporter.java View source code |
@OnStage(LifecycleStage.START)
public void start() throws IOException {
System.setProperty("java.rmi.server.randomIDs", String.valueOf(config.useRandomIds()));
System.setProperty("java.rmi.server.hostname", config.getHostname().getHostAddress());
final JmxSocketFactory factory = new JmxSocketFactory(config.getHostname());
LocateRegistry.createRegistry(config.getRmiRegistryPort(), factory, factory);
connectorServer.start();
LOG.info("Started exporter on port %d", config.getRmiRegistryPort());
}
Example 96
Project: dch-master File: HelloWorldServer.java View source code |
public static void main(String[] args) {
try {
Registry reg = LocateRegistry.createRegistry(1099);
System.out.println("Registry created");
HelloWorld hello = new HelloWorld();
System.out.println("Object created");
reg.bind("HelloWorld", hello);
System.out.println("Object bound HelloWorld server is ready.");
} catch (Exception e) {
System.out.println("Hello Server failed: " + e);
}
}
Example 97
Project: dtf-master File: CommRMIServer.java View source code |
public void start() throws CommException { // this assures that the server starts up on the same hostname that was // defined as being the dtf.listen.addr for this component System.setProperty("java.rmi.server.hostname", _addr); if (_port != -1) { try { // Bind the remote object's stub in the registry _registry = LocateRegistry.createRegistry(_port, _rmisf, _rmisf); } catch (RemoteException e) { throw new CommException("Unable to start up RMIServer.", e); } } else { boolean bound = false; int retries = 0; _port = 30000; while (!bound) { try { _registry = LocateRegistry.createRegistry(_port, _rmisf, _rmisf); bound = true; } catch (RemoteException e) { retries++; _port++; } } } _logger.info("Listening at [" + _port + "]"); }
Example 98
Project: eclipse-jmx-master File: Activator.java View source code |
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean(new ArrayType(), ObjectName.getInstance(//$NON-NLS-1$
"net.jmesnil.test:type=ArrayType"));
mbs.registerMBean(new WritableAttributes(), ObjectName.getInstance(//$NON-NLS-1$
"net.jmesnil.test:type=WritableAttributes"));
mbs.registerMBean(new ComplexType(), ObjectName.getInstance(//$NON-NLS-1$
"net.jmesnil.test:type=ComplexType"));
mbs.registerMBean(new OperationResults(), ObjectName.getInstance(//$NON-NLS-1$
"net.jmesnil.test:type=OperationResults"));
mbs.registerMBean(new Registration(), ObjectName.getInstance(//$NON-NLS-1$
"net.jmesnil.test:type=Registration"));
mbs.registerMBean(new CustomizedAttributes(), ObjectName.getInstance(//$NON-NLS-1$
"net.jmesnil.test:type=CustomizedAttributes"));
mbs.registerMBean(new NotifEmitter(), ObjectName.getInstance(//$NON-NLS-1$
"net.jmesnil.test:type=NotifEmitter"));
try {
//$NON-NLS-1$ //$NON-NLS-2$
System.setProperty("java.rmi.server.randomIDs", "true");
LocateRegistry.createRegistry(3000);
JMXServiceURL url = new JMXServiceURL(//$NON-NLS-1$
"service:jmx:rmi:///jndi/rmi://:3000/jmxrmi");
cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
cs.start();
} catch (Exception e) {
e.printStackTrace();
}
}
Example 99
Project: fcrepo-master File: MockRmiJournalReceiver.java View source code |
/**
* Use this if you need to create an actual RMI connection to test the
* RmiTransport.
*/
public static void main(String[] args) throws RemoteException, AlreadyBoundException {
trace = true;
try {
MockRmiJournalReceiver receiver = new MockRmiJournalReceiver();
if (Arrays.asList(args).contains("throwException")) {
receiver.setOpenFileThrowsException(true);
}
Registry registry = LocateRegistry.createRegistry(1099);
registry.bind("RmiJournalReceiver", receiver);
Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
}
Example 100
Project: felix-master File: NamingService.java View source code |
public void start(BundleContext bc) throws Exception {
this.version = (String) bc.getBundle().getHeaders().get(Constants.BUNDLE_VERSION);
this.bc = bc;
String profile = bc.getProperty(BundleCache.CACHE_PROFILE_PROP);
if (profile == null) {
profile = System.getProperty(BundleCache.CACHE_PROFILE_PROP);
}
String rmiPortS = bc.getProperty("mosgi.jmxconsole.rmiport." + profile);
int rmiPort = 1099;
if (rmiPortS != null) {
rmiPort = Integer.parseInt(rmiPortS);
}
try {
this.log(LogService.LOG_INFO, "Running rmiregistry on " + rmiPort, null);
//!! Absolutely nececary for RMIClassLoading to work
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
m_registry = LocateRegistry.createRegistry(rmiPort);
//java.rmi.server.RemoteServer.setLog(System.out);
} catch (Exception e) {
this.bc = null;
throw new BundleException("Impossible to start rmiregistry");
}
sReg = bc.registerService(NamingServiceIfc.class.getName(), this, null);
this.log(LogService.LOG_INFO, "RMI Registry started " + version, null);
}
Example 101
Project: gMix-master File: DiscoveryRegistry.java View source code |
/***
* starts the rmi registry server. will be used later by test nodes to register.
* @param port
*/
private void startRegistry() {
System.out.println("starting RMI registry proxy...");
try {
SslRMIServerSocketFactory factory = new SslRMIServerSocketFactory(null, null, true);
LocateRegistry.createRegistry(port, new SslRMIClientSocketFactory(), factory);
} catch (Exception e) {
e.printStackTrace();
}
}