I would like to init my ORB from property file (normally I init it like this, while running my examples: ./app -ORBInitRef NameService=corbaloc::localhost:2809/NameServic
You have to add -ORBInitRef
to the ORB arguments also. Compare it to the commandline you normaly use. ALL the arguments have to be passed to the ORB.init()
config.properties:
ORBInitRef NameService=corbaloc::localhost:2809/NameService
Java Code using it (ReadProps.java)
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import org.omg.CORBA.ORB;
public class ReadProps {
public static void main(String[] args) {
ORB clientsORB = org.omg.CORBA.ORB.init(readConfigFile(), null);
}
static String[] readConfigFile() {
Properties prop = new Properties();
String[] orbarg = new String[2];
try {
// load a properties file
prop.load(new FileInputStream("config.properties"));
// get the property value and print it out
orbarg[0] = "-ORBInitRef"; // <---- NEEDED
orbarg[1] = prop.getProperty("ORBInitRef");
} catch (IOException ex) {
ex.printStackTrace();
}
return orbarg;
}
}