Search in sources :

Example 1 with Manager

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();
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) ManagerImpl(org.apache.karaf.shell.impl.action.command.ManagerImpl) BufferedReader(java.io.BufferedReader) Manager(org.apache.karaf.shell.api.action.lifecycle.Manager) URL(java.net.URL)

Aggregations

BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 Manager (org.apache.karaf.shell.api.action.lifecycle.Manager)1 ManagerImpl (org.apache.karaf.shell.impl.action.command.ManagerImpl)1