NameComponent [] nameXmlBlaster = new NameComponent[] { new NameComponent(contextId, contextKind) };
if (log.isLoggable(Level.FINE)) log.fine("Query NameServer -ORBInitRef NameService=" + glob.getProperty().get("ORBInitRef","") +
((System.getProperty("ORBInitRef.NameService") != null) ? System.getProperty("ORBInitRef.NameService") : "") +
" to find the xmlBlaster root context " + OrbInstanceFactory.getString(nameXmlBlaster));
org.omg.CORBA.Object obj = namingContextExt.resolve(nameXmlBlaster);
NamingContext relativeContext = org.omg.CosNaming.NamingContextExtHelper.narrow(obj);
if (relativeContext == null) {
throw new Exception("Can't resolve CORBA NameService");
}
NameComponent [] nameNode = new NameComponent[] { new NameComponent(clusterId, clusterKind) };
AuthServer authServerFirst = null;
String tmpId = ""; // for logging only
String tmpServerName = ""; // for logging only
String firstServerName = ""; // for logging only
int countServerFound = 0; // for logging only
String serverNameList = ""; // for logging only
try {
this.authServer = AuthServerHelper.narrow(relativeContext.resolve(nameNode));
}
catch (Exception ex) {
if (log.isLoggable(Level.FINE)) log.fine("Query NameServer to find a suitable xmlBlaster server for " + OrbInstanceFactory.getString(nameXmlBlaster) + "/" + OrbInstanceFactory.getString(nameNode));
BindingListHolder bl = new BindingListHolder();
BindingIteratorHolder bi = new BindingIteratorHolder();
relativeContext.list(0, bl, bi);
//for (int i=0; i<bl.value.length; i++) { // bl.value.length should be 0
// String id = bl.value[i].binding_name[0].id;
// String kind = bl.value[i].binding_name[0].kind;
// process the remaining bindings if an iterator exists:
if (this.authServer == null && bi.value != null) {
BindingHolder bh = new BindingHolder();
int i = 0;
while ( bi.value.next_one(bh) ) {
String id = bh.value.binding_name[0].id;
String kind = bh.value.binding_name[0].kind;
NameComponent [] nameNodeTmp = new NameComponent[] { new NameComponent(id, kind) };
tmpId = id;
countServerFound++;
tmpServerName = OrbInstanceFactory.getString(nameXmlBlaster)+"/"+OrbInstanceFactory.getString(nameNodeTmp);
if (i>0) serverNameList += ", ";
i++;
serverNameList += tmpServerName;
if (clusterId.equals(id) && clusterKind.equals(kind)) {
try {
if (log.isLoggable(Level.FINE)) log.fine("Trying to resolve NameService entry '"+OrbInstanceFactory.getString(nameNodeTmp)+"'");
this.authServer = AuthServerHelper.narrow(relativeContext.resolve(nameNodeTmp));
break; // found a matching server
}
catch (Exception exc) {
log.warning("Connecting to NameService entry '"+tmpServerName+"' failed: " + exc.toString());
}
}
if (authServerFirst == null) {
if (log.isLoggable(Level.FINE)) log.fine("Remember the first server");
try {
firstServerName = tmpServerName;
if (log.isLoggable(Level.FINE)) log.fine("Remember the first reachable xmlBlaster server from NameService entry '"+firstServerName+"'");
authServerFirst = AuthServerHelper.narrow(relativeContext.resolve(nameNodeTmp));
}
catch (Exception exc) {
log.warning("Connecting to NameService entry '"+tmpServerName+"' failed: " + exc.toString());
}
}