in commands/src/main/java/org/jclouds/karaf/commands/table/internal/osgi/OSGiScriptEngineManager.java [260:295]
private List<String> findFactoryCandidates(BundleContext context) {
Bundle[] bundles = context.getBundles();
List<String> factoryCandidates = new ArrayList<String>();
for (Bundle bundle : bundles) {
if (bundle == null) {
continue;
}
if (bundle.getSymbolicName().equals("system.bundle")) {
continue;
}
Enumeration<URL> urls = bundle.findEntries("META-INF/services",
"javax.script.ScriptEngineFactory", false);
if (urls == null) {
continue;
}
while (urls.hasMoreElements()) {
URL u = (URL) urls.nextElement();
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(u.openStream()));
String line;
while ((line = reader.readLine()) != null) {
line = line.trim();
// ignore comments and empty lines
if (!line.isEmpty() && !line.startsWith("#")) {
factoryCandidates.add(line);
}
}
} catch (IOException ignored) {
}
}
}
return factoryCandidates;
}