if (logger.isInfoEnabled())
{
logger.info("Initialising ORB with ID: " + orb_id);
}
Configuration orbsingletonConfig = ((ORBSingleton)org.omg.CORBA.ORBSingleton.init ()).configuration;
if (props != null)
{
orbsingletonConfig.setAttributes (props);
}
if ( args != null )
{
for ( int i = 0; i < args.length; i++ )
{
if (args[i] == null)
{
continue;
}
String arg = args[i].trim();
if (!arg.startsWith("-ORB"))
{
continue;
}
// skip over -ORBID argument since it is not applied here
if (arg.equalsIgnoreCase("-ORBID"))
{
i++;
continue;
}
// skip over -ORBSetListenEndpoint argument since it is not applied here
if (arg.equalsIgnoreCase("-ORBListenEndpoints"))
{
i++;
continue;
}
// Strip the leading '-'.
arg = arg.substring( 1 );
if (arg.equals("ORBDefaultInitRef"))
{
defaultInitRef = args[++i].trim();
continue;
}
// Look for an '=' in the argument
int equals_pos = arg.indexOf('=');
final String propertyName;
final String propertyValue;
if (equals_pos == -1)
{
//This is the compliant form like: -ORBInitRef <name>=<val>
if (arg.indexOf('.') >= 0)
{
// ORBInitRef.<name> value
throw new BAD_PARAM("-ORBInitRef.xxx yyy is not a valid format. Use -ORBInitRef name=value");
}
//Is there a next arg?
if ( (i + 1) >= (args.length) )
{
throw new BAD_PARAM("Invalid ORBInitRef format: -ORB<option> argument without value" );
}
String prop = args[ ++i ].trim();
//find the equals char that separates prop name from
//prop value
equals_pos = prop.indexOf('=');
if (equals_pos < 0)
{
if (arg.equals("ORBInitRef"))
{
throw new BAD_PARAM("Invalid ORBInitRef format -ORBInitRef " + prop + ". it should be -ORBInitRef name=value.");
}
// Form is -ORBWhatever value
propertyName = arg;
propertyValue = prop;
}
else
{
// Form is -ORBWhatever name=value
// add the property to environment
propertyName = arg + "." + prop.substring( 0, equals_pos );
propertyValue = prop.substring( equals_pos + 1);
if (propertyValue.length() == 0)
{
throw new BAD_PARAM("Invalid ORBInitRef format: -ORBInitRef name=value. value may not be omitted.");
}
}
}
else
{
//This is the wrong jacorb form -ORBInitRef.<name>=<val>
//get rid of the leading =
//add the property to environment
propertyName = arg.substring( 0, equals_pos );
propertyValue = arg.substring( equals_pos + 1);
if (propertyValue.length() == 0)
{
throw new BAD_PARAM("Invalid ORBInitRef format: -ORBInitRef name=value. value may not be omitted.");
}
}
if (logger.isDebugEnabled())
{
logger.debug("adding attribute " + propertyName + "=" + propertyValue);
}
configuration.setAttribute(propertyName, propertyValue);
// Upload this ORB argument to the Singleton.
orbsingletonConfig.setAttribute (propertyName, propertyValue);
}
}
internalInit();
}