use of org.apache.felix.gogo.runtime.Closure in project karaf by apache.
the class SecuredCommand method execute.
@Override
public Object execute(final CommandSession commandSession, List<Object> arguments) throws Exception {
// TODO: remove the hack for .session
Session session = (Session) commandSession.get(".session");
// When need to translate closures to a compatible type for the command
for (int i = 0; i < arguments.size(); i++) {
Object v = arguments.get(i);
if (v instanceof Closure) {
final Closure closure = (Closure) v;
arguments.set(i, new VersatileFunction(closure));
}
if (v instanceof Token) {
arguments.set(i, v.toString());
}
}
return execute(session, arguments);
}
use of org.apache.felix.gogo.runtime.Closure in project karaf by apache.
the class CommandWrapper method execute.
@Override
public Object execute(final CommandSession commandSession, List<Object> arguments) throws Exception {
// TODO: remove the hack for .session
Session session = (Session) commandSession.get(".session");
// When need to translate closures to a compatible type for the command
for (int i = 0; i < arguments.size(); i++) {
Object v = arguments.get(i);
if (v instanceof Closure) {
final Closure closure = (Closure) v;
arguments.set(i, (org.apache.karaf.shell.api.console.Function) (s, a) -> closure.execute(commandSession, a));
}
}
return command.execute(session, arguments);
}
Aggregations