use of org.apache.karaf.shell.api.action.lifecycle.Manager in project karaf by apache.
the class Main method discoverCommands.
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();
}
}
Aggregations