Bonjour à tous,
J'ai développé un petit code ORB que voici :
import java.util.Properties;
import org.omg.CORBA.ORB;
public class TestORBpresence {
// This is the ORB implementation used when nothing else is specified.
// Whoever provides this class customizes this string to
// point at their ORB implementation.
//
private static final String ORBClassKey = "org.omg.CORBA.ORBClass";
private static final String ORBSingletonClassKey = "org.omg.CORBA.ORBSingletonClass";
//
// Set OPenORB as the active ORB
//
private static final String activeORB = "org.openorb.orb.core.ORB";
private static final String activeORBSingleton = "org.openorb.orb.core.ORBSingleton";
/**
* @param args
*/
public static void main(String[] args) {
org.omg.CORBA.Object ns_ = null;
org.omg.CORBA.Object ts_ = null;
String ongoingTest_ = "";
String outError_ = null;
String OrbHostIpOrName_ = "localhost";
String OrbHostPort_ = "9870";
// Set de properties pour forcer l'usage d'openORB
Properties p = new Properties();
// Setting ORB implementation
p.put(ORBClassKey, activeORB);
p.put(ORBSingletonClassKey, activeORBSingleton);
// Setting the communication
p.put("org.omg.CORBA.ORBInitialHost", OrbHostIpOrName_);
p.put("org.omg.CORBA.ORBInitialPort", OrbHostPort_);
System.out.println("ORB testé IP/name = " + OrbHostIpOrName_ +
", on port " + OrbHostPort_);
try {
// Get a interface with an openORB ORB
org.openorb.orb.core.ORB orb = (org.openorb.orb.core.ORB) org.openorb.orb.core.ORB.init(args,p);
// Test Namming service presence
ongoingTest_ = new String("NameService");
ns_ = orb.resolve_initial_references("NameService");
System.out.println(">>>>>>>>>>>\nNameService\n" + ns_.toString() + "\n<<<<<<<<<<<<<");
ongoingTest_ = new String("TransactionService");
// Test Transaction service presence
ts_ = orb.resolve_initial_references("TransactionService");
// ts_ = orb.resolve_initial_references("TransactionServiceFoo");
System.out.println(">>>>>>>>>>>\nTransactionService\n" + ts_.toString() + "\n<<<<<<<<<<<<<");
} catch (Exception e) {
outError_ = ongoingTest_;// declare the test which failled
}
// create the errorCode to be given to InstallAnywhere
if (outError_ == null ){
System.out.println("openORB is up and running");
// set the IA propertie to OK
}
else {
System.out.println("Ending error : " + outError_);
// set the IA propertie to KO with the proper error code
}
}
}
Il marche très bien, le problème est que les properties ne sont pas prises en compte, par exemple si au lieu de mettre"localhost" je met "zzz" ou "toto", le programme fonctionne aussi bien. Il semble donc que le programme s'execute avec les properties par défaut...
Si quelqu'un a une idée....
Merci beaucoup en tout cas
Partager