//Construct the desired AdministeredObject
Object newobj = Class.forName(ref.getClassName()).newInstance();
//version number MUST exist and it MUST be this version or a supported version
RefAddr versionAddr = ref.get(REF_VERSION);
//Support reading previous object versions here (2.0, 2.1 etc.). Floor is 2.0
if (versionAddr == null || !(newobj instanceof com.sun.messaging.AdministeredObject)) {
//if version number does not exist or it is not an AdministeredObject
throw new MissingVersionNumberException();
} else {
version = (String)versionAddr.getContent();
//Support reading previous object versions here (2.0, 2.1 etc.). Floor is 2.0
if ( ! (AO_VERSION_STR.equals(version) ||
AO_VERSION_STR_JMQ3B.equals(version) ||
AO_VERSION_STR_JMQ2.equals(version)) ){
//Reference contains a bad version number
throw new UnsupportedVersionNumberException(version);
}
if (ref.size() < 2) {
//Reference is corrupted
throw new CorruptedConfigurationPropertiesException();
}
RefAddr readOnlyAddr = ref.get(REF_READONLY);
if ("true".equals((String)readOnlyAddr.getContent())) {
//Reference has readOnly set
readOnly = true;
}
((AdministeredObject)newobj).storedVersion = version;
}
RefAddr refaddr;
String refContent;
//Skip the version # and r/o flag (start at 2)
//System.out.println("AOtoString="+ newobj.toString());
for (int i = 2; i < ref.size(); i++) {
refaddr = ref.get(i);
refContent = (String)refaddr.getContent();
//System.out.println("gOI:ref#="+i+"; refCntnt="+refContent);
//Guard against null values coming back from JNDI
//Some service-providers will return `null'; others will return "" (empty string)
if (refContent == null) {
refContent = "";
}
//If property fails to set then ignore since we may have looked up a newer object
try {
//XXX RFE:tharakan
//Need to add support migrating 2.x properties to 3.x
//System.out.println("gOI:settingProp");
//System.out.println("gOI:propName="+refaddr.getType());
((AdministeredObject)newobj).setProperty(refaddr.getType(), refContent);
//System.out.println("gOI:propName="+refaddr.getType()+" set successfully");
} catch (Exception bpe) {
//Ignore exception
//System.out.println("gOI:propName="+refaddr.getType()+" exception; "+bpe.getMessage());
//bpe.printStackTrace();