public String getDiscoveryResource() {
return "META-INF/services/org/apache/karaf/shell/commands";
}
protected void discoverCommands(Session session, ClassLoader cl, String resource) throws IOException, ClassNotFoundException {
Manager manager = new ManagerImpl(session.getRegistry(), session.getFactory().getRegistry(), true);
Enumeration<URL> urls = cl.getResources(resource);
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream()));
String line = r.readLine();
while (line != null) {
line = line.trim();
if (line.length() > 0 && line.charAt(0) != '#') {
final Class<?> actionClass = cl.loadClass(line);
manager.register(actionClass);
}
line = r.readLine();
}
r.close();
}