Commit 7857b9d8 authored by yannick legoc's avatar yannick legoc
Browse files

Connection to a remote Nomad server with Cameo.

parent bb4d48ac
......@@ -4,6 +4,6 @@
* First release with Maven build process management.
* "GUI zero-crash" mode.
* Inherited controllers / drivers management.
* Introduction of Cameo for starting the Nomad server.
* Introduction of Cameo for starting the real and simulated Nomad servers.
* Changed way to search for double dynamic properties (for multiplot purposes).
......@@ -18,6 +18,8 @@
package fr.ill.ics.nscclient.corbabase;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.omg.CORBA.ORB;
......@@ -27,6 +29,8 @@ import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;
import org.omg.PortableServer.POAManagerPackage.AdapterInactive;
import fr.ill.ics.util.ConfigManager;
public class CorbaORB {
......@@ -40,6 +44,22 @@ public class CorbaORB {
private CorbaORB () {
}
private static String getNameServiceFromNomadServerEndpoint(String endpoint) {
String prefix = "tcp://";
if (!endpoint.startsWith(prefix)) {
return null;
}
int index = endpoint.lastIndexOf(':');
if (index == -1) {
return null;
}
return endpoint.substring(6, index);
}
/*
* Example of jacorb properties:
* Properties jacorbProperties = new Properties();
......@@ -47,6 +67,23 @@ public class CorbaORB {
* jacorbProperties.setProperty("ORBInitRef.NameService", "corbaloc::localhost:2809/NameService");
*/
public void init(Properties jacorbProperties) {
// Loading the file jacorb.properties if jacorbProperties is null
if (jacorbProperties == null) {
InputStream stream = CorbaORB.class.getClassLoader().getResourceAsStream("jacorb.properties");
jacorbProperties = new Properties();
try {
jacorbProperties.load(stream);
}
catch (IOException e) {
System.err.println("Unable to load jacorb.properties");
}
}
String nomadServerEndpoint = ConfigManager.getInstance().getNomadServerEndpoint();
String nomadServerHostname = getNameServiceFromNomadServerEndpoint(nomadServerEndpoint);
jacorbProperties.setProperty("ORBInitRef.NameService", "corbaloc::" + nomadServerHostname + ":2809/NameService");
try {
// dummy args
......
......@@ -28,6 +28,7 @@ import java.util.Map;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.ConnectionTimeout;
import fr.ill.ics.cameo.Server;
import fr.ill.ics.util.ConfigManager;
/**
*
......@@ -87,20 +88,23 @@ public class ServerDisconnected extends ServerConnectionState {
}
}
System.out.println("starting nomad server with nappli");
System.out.println("Starting nomad server with Cameo");
// Get the server endpoint.
String nomadServerEndpoint = ConfigManager.getInstance().getNomadServerEndpoint();
// connect to the server
Server server = new Server("tcp://localhost:7000");
Server server = new Server(nomadServerEndpoint);
// start nomad server
try {
Application.Instance nomad = server.start("ns");
if (nomad.exists()) {
System.out.println("started " + nomad);
System.out.println("Started " + nomad);
}
} catch (ConnectionTimeout e) {
System.err.println("timeout while starting nomad server");
System.err.println("Timeout while starting nomad server");
}
server.terminate();
......
......@@ -538,4 +538,15 @@ public class ConfigManager {
public Set<ConfigurationException> getConfigurationExceptions() {
return configurationExceptions;
}
public String getNomadServerEndpoint() {
String nomadServerEndpoint = getStringOrNothingAtAll("nomadServerEndpoint");
if (nomadServerEndpoint != null) {
return nomadServerEndpoint;
}
return "tcp://localhost:7000";
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment