String dependsName = dependsNode != null ? dependsNode.getNodeValue() : "";
NodeList propertyNodes = propertiesNode.getElementsByTagName(PROPERTY_ELEMENT_NAME);
/** If the name is provided get the OM from the top level else just load into the current PM **/
PropertyManagerPluginInterface pm = propertiesName != null ? pcm.getTopLevelPropertyManager().getChild(propertiesName) : pcm;
/** If the child doesn't already exist create one **/
if ( pm == null )
{
pm = pcm.createPropertyManager(propertiesName);
}
if ( verbose )
{
System.out.println("Properties loaded ("+uri+"):");
}
/** Associate the current URI with this property manager **/
pm.setUri(uri);
/** Associate this plugin with the property manager **/
pm.setIOPluginClassname(this.getClass().getName());
for (int nodeCount=0;nodeCount<propertyNodes.getLength();nodeCount++)
{
Element propertyNode = (Element)propertyNodes.item(nodeCount);
String propertyName = propertyNode.getAttribute(NAME_ATTRIBUTE_NAME);
String propertyValue = propertyNode.getAttribute(VALUE_ATTRIBUTE_NAME);
String propertyType = propertyNode.getAttribute(PROPERTY_TYPE_ATTRIBUTE_NAME);
if ( verbose )
{
System.out.println( propertyName +"="+ propertyValue );
}
// perform JBossAS style property substitutions. JBTM-369
propertyValue = StringPropertyReplacer.replaceProperties(propertyValue);
/** Set the property but don't allow any system property to be overridden **/
pm.setProperty(propertyName, propertyValue, false);
/** If the property is specified as a System property and it's not already a system property **/
if ( propertyType != null &&
propertyType.equalsIgnoreCase(SYSTEM_PROPERTY_TYPE_NAME) &&
System.getProperty(propertyName) == null )
{
/** Set this as a system property also **/
System.setProperty(propertyName, propertyValue);
}
}
/** If this has no dependents then it is a top-level module **/
if ( dependsName.length() == 0 && pm != pcm)
{
pcm.addChild(pm);
}
pmDependents.put(pm, dependsName);
/** If these properties belond to a named set store them **/
if ( propertiesName != null )
{
pms.put(propertiesName, pm);
}
}
/** Ensure dependency tree is kept **/
for (Enumeration e = pmDependents.keys();e.hasMoreElements();)
{
PropertyManagerPluginInterface pm = (PropertyManagerPluginInterface)e.nextElement();
String depends = (String)pmDependents.get(pm);
StringTokenizer strtok = new StringTokenizer(depends,",");
while (strtok.hasMoreElements())
{
String dependantName = strtok.nextToken().trim();
PropertyManager dependant = (PropertyManager)pms.get(dependantName);
if ( dependant == null )
{
throw new LoadPropertiesException("Dependency not found - property file invalid");
}
pm.addParent(dependant);
}
}
}
else
{