*/
public class ResourceMapFactory {
private static final Log log = LogFactory.getLog(ResourceMapFactory.class);
public static ResourceMap createResourceMap(OMElement elem) {
ResourceMap resourceMap = null;
Iterator it = elem.getChildrenWithName(
new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "resource"));
while (it.hasNext()) {
// Lazily create the ResourceMap, so that when no <resource>
// elements are found, the method returns null.
if (resourceMap == null) {
resourceMap = new ResourceMap();
}
OMElement resourceElem = (OMElement)it.next();
OMAttribute location = resourceElem.getAttribute
(new QName(XMLConfigConstants.NULL_NAMESPACE, "location"));
if (location == null) {
handleException("The 'location' attribute is required for a resource definition");
}
OMAttribute key = resourceElem.getAttribute(
new QName(XMLConfigConstants.NULL_NAMESPACE, "key"));
if (key == null) {
handleException("The 'key' attribute is required for a resource definition");
}
resourceMap.addResource(location.getAttributeValue(), key.getAttributeValue());
}
return resourceMap;
}