try
{
URL fileURL = new URL(filename);
if (metaDataParser == null)
{
metaDataParser = new MetaDataParser(this, validateMetaData);
}
MetaData permd = metaDataParser.parseMetaDataURL(fileURL, "persistence");
return new PersistenceFileMetaData[] {(PersistenceFileMetaData)permd};
}
catch (MalformedURLException mue)
{
// User provided file is not found
NucleusLogger.METADATA.error("Error reading user-specified persistence.xml file " + filename, mue);
}
}
HashSet metadata = new HashSet();
ClassLoaderResolver clr = nucleusContext.getClassLoaderResolver(null);
try
{
// Find all "META-INF/persistence.xml" files in the CLASSPATH of the current thread
Enumeration files = clr.getResources("META-INF/persistence.xml",
Thread.currentThread().getContextClassLoader());
if (!files.hasMoreElements())
{
return null;
}
for ( ; files.hasMoreElements() ;)
{
// Parse the "persistence.xml"
URL fileURL = (URL)files.nextElement();
if (metaDataParser == null)
{
metaDataParser = new MetaDataParser(this, validateMetaData);
}
MetaData permd = metaDataParser.parseMetaDataURL(fileURL, "persistence");
metadata.add(permd);
}
}