{
log.debug("Reading resource: '" + resourceName + "'");
ObjectModelFactory omf = new AttributeMappingsBinding();
InputStream is = null;
AttributeMappings mappings = null;
try
{
// locate resource
is = SecurityActions.getThreadContextClassLoaderResource(resourceName);
// create unmarshaller
Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
// let JBossXB do it's magic using the AttributeMappingsBinding
mappings = (AttributeMappings)unmarshaller.unmarshal(is, omf, null);
}
catch (Exception e)
{
log.error("Accessing resource '" + resourceName + "'");
throw e;
}
finally
{
if (is != null)
{
// close the XML stream
is.close();
}
}
if (mappings == null)
{
log.warn("No bindings found in " + resourceName);
return;
}
log.debug("Found " + mappings.size() + " attribute mappings");
/**
* We have the MBeans now. Put them into the bindungs.
*/
Iterator it = mappings.iterator();
while (it.hasNext())
{
ManagedBean mmb = (ManagedBean)it.next();
String oidPrefix = mmb.getOidPrefix();
List attrs = mmb.getAttributes();