if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "getInitialContext: env={0}", env);
}
boolean useLB = propertyIsSet(myEnv, IIOP_ENDPOINTS_PROPERTY)
|| propertyIsSet(myEnv, LOAD_BALANCING_PROPERTY) ;
NamingClusterInfo namingClusterInfo = null;
if (useLB && !initialized) {
synchronized( SerialInitContextFactory.class ) {
if (!initialized) {
namingClusterInfo = services.getService(NamingClusterInfo.class);
namingClusterInfo.initGroupInfoService(myEnv, defaultHost, defaultPort, getORB(), services);
membershipChangeForced = true ;
initialized = true ;
}
}
}
if (useLB || initialized) {
// If myEnv already contains the IIOP_URL, don't get a new one:
// this getInitialContext call came from an internal
// new InitialContext call.
if (!myEnv.containsKey(IIOP_URL_PROPERTY)) {
Context ctx = SerialContext.getStickyContext() ;
if (ctx != null) {
return ctx ;
}
// If the IIOP endpoint list is explicitly set in the env,
// update rrPolicy to use that information, otherwise just
// rotate rrPolicy to the next element.
if(namingClusterInfo == null) {
namingClusterInfo = services.getService(NamingClusterInfo.class);
}
if (myEnv.containsKey( IIOP_ENDPOINTS_PROPERTY ) ||
myEnv.containsKey( LOAD_BALANCING_PROPERTY )) {
synchronized( SerialInitContextFactory.class ) {
namingClusterInfo.setClusterInstanceInfo(myEnv, defaultHost, defaultPort, membershipChangeForced);
}
}
List<String> rrList = namingClusterInfo.getNextRotation();
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "getInitialContext: RoundRobinPolicy list = {0}", rrList);
}
myEnv.put(IIOP_URL_PROPERTY, getCorbalocURL(rrList));
}