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 org.apache.karaf.shell.api.console.Function() {
@Override
public Object execute(Session session, List<Object> arguments) throws Exception {
return closure.execute(commandSession, arguments);
}
});
}
}
return command.execute(session, arguments);