@Override
public boolean foundInJar(Bundle bundle, String zipFileName, ZipEntry zipEntry, InputStream in) throws Exception {
String zipEntryName = zipEntry.getName();
if ((zipEntryName.endsWith(".faces-config.xml") && zipEntryName.indexOf('/', "META-INF/".length()) == -1) || zipEntryName.equals("META-INF/faces-config.xml")) {
ConfigurationResource configurationResource = new ConfigurationResource(zipFileName, zipEntryName);
FacesConfig facesConfig = defaultFacesConfigUnmarshaller.getFacesConfig(in, configurationResource.getConfigurationResourceURL(bundle).toExternalForm());
configurationResource.setFacesConfig(facesConfig);
metaInfConfigurationResources.add(configurationResource);
}
return true;
}
});
} catch (Exception e) {
throw new DeploymentException("Fail to scan faces-config.xml configuration files", e);
} finally {
if (reference != null) {
bundle.getBundleContext().ungetService(reference);
}
}
//2 WEB-INF/classes/META-INF folder
Enumeration<URL> classesEn = bundle.findEntries(moduleNamePrefix + "WEB-INF/classes/META-INF/", "*faces-config.xml", false);
if (classesEn != null) {
while (classesEn.hasMoreElements()) {
String filePath = classesEn.nextElement().getPath();
if (filePath.endsWith("/faces-config.xml") || filePath.endsWith(".faces-config.xml")) {
metaInfConfigurationResources.add(new ConfigurationResource(null, filePath));
}
}
}
//3 META-INF folder
Enumeration<URL> metaInfEn = bundle.findEntries(moduleNamePrefix + "META-INF/", "*faces-config.xml", false);
if (metaInfEn != null) {
while (metaInfEn.hasMoreElements()) {
String filePath = metaInfEn.nextElement().getPath();
if (filePath.endsWith("/faces-config.xml") || filePath.endsWith(".faces-config.xml")) {
metaInfConfigurationResources.add(new ConfigurationResource(null, filePath));
}
}
}
return metaInfConfigurationResources;
}