Search in sources :

Example 1 with SubShellCommand

use of org.apache.karaf.shell.impl.console.commands.SubShellCommand in project karaf by apache.

the class SessionFactoryImpl method unregister.

@Override
public void unregister(Object service) {
    synchronized (services) {
        super.unregister(service);
        if (service instanceof Command) {
            Command command = (Command) service;
            String scope = command.getScope();
            String name = command.getName();
            commandProcessor.removeCommand(scope, name);
            if (!Session.SCOPE_GLOBAL.equals(scope)) {
                if (subshells.get(scope).decrement() == 0) {
                    SubShellCommand subShell = subshells.remove(scope);
                    unregister(subShell);
                }
            }
        }
    }
}
Also used : ExitCommand(org.apache.karaf.shell.impl.console.commands.ExitCommand) SubShellCommand(org.apache.karaf.shell.impl.console.commands.SubShellCommand) HelpCommand(org.apache.karaf.shell.impl.console.commands.help.HelpCommand) Command(org.apache.karaf.shell.api.console.Command) SubShellCommand(org.apache.karaf.shell.impl.console.commands.SubShellCommand)

Example 2 with SubShellCommand

use of org.apache.karaf.shell.impl.console.commands.SubShellCommand in project karaf by apache.

the class SessionFactoryImpl method register.

@Override
public void register(Object service) {
    synchronized (services) {
        if (service instanceof Command) {
            Command command = (Command) service;
            String scope = command.getScope();
            String name = command.getName();
            if (!Session.SCOPE_GLOBAL.equals(scope)) {
                if (!subshells.containsKey(scope)) {
                    SubShellCommand subShell = new SubShellCommand(scope);
                    subshells.put(scope, subShell);
                    register(subShell);
                }
                subshells.get(scope).increment();
            }
            commandProcessor.addCommand(scope, wrap(command), name);
        }
        super.register(service);
    }
}
Also used : ExitCommand(org.apache.karaf.shell.impl.console.commands.ExitCommand) SubShellCommand(org.apache.karaf.shell.impl.console.commands.SubShellCommand) HelpCommand(org.apache.karaf.shell.impl.console.commands.help.HelpCommand) Command(org.apache.karaf.shell.api.console.Command) SubShellCommand(org.apache.karaf.shell.impl.console.commands.SubShellCommand)

Aggregations

Command (org.apache.karaf.shell.api.console.Command)2 ExitCommand (org.apache.karaf.shell.impl.console.commands.ExitCommand)2 SubShellCommand (org.apache.karaf.shell.impl.console.commands.SubShellCommand)2 HelpCommand (org.apache.karaf.shell.impl.console.commands.help.HelpCommand)2