}
return null;
}
}
Closeable handle;
try {
// If the file exists
if (file.exists()) {
// Mount Exploded dir
if (file.isDirectory()) {
handle = VFS.mountReal(file.getPhysicalFile(), file);
}
// Mount EJB JAR
else if (file.getName().endsWith(EXTENSION_JAR)) {
if (provider == null) {
provider = TempFileProvider.create("jbossejbmodulescanner", ses);
}
handle = VFS.mountZip(file.getPhysicalFile(), file, provider);
}
// No conditions met
else {
// So it's obvious if we've got something we didn't properly mount
ROOT_LOGGER.skippingUnknownFileType(file);
return null;
}
}
// Not a real file
else {
ROOT_LOGGER.fileNotFound(file);
return null;
}
try {
/*
* Directories and real JARs are handled the same way in VFS, so just do
* one check and skip logic to test isDirectory or not
*/
// Look for META-INF/ejb-jar.xml
final VirtualFile ejbJarXml = file.getChild(PATH_EJB_JAR_XML);
if (ejbJarXml.exists()) {
if (ROOT_LOGGER.isTraceEnabled()) {
ROOT_LOGGER.tracef("Found descriptor %s in %s", ejbJarXml.getPathNameRelativeTo(file), file);
}
return getModuleNameFromEjbJar(file, ejbJarXml);
}
// Look for at least one .class with an EJB annotation
if (containsEjbComponentClass(file)) {
return getModuleNameFromFileName(file);
}
// Return
return null;
} finally {
try {
handle.close();
} catch (final IOException e) {
// Ignore
ROOT_LOGGER.cannotCloseFile(e, file);
}
}