private void run(final SessionFactory sessionFactory, String command, final InputStream in, final PrintStream out, final PrintStream err, ClassLoader cl) throws Exception {
final TerminalFactory terminalFactory = new TerminalFactory();
try {
final Terminal terminal = new JLineTerminal(terminalFactory.getTerminal());
Session session = createSession(sessionFactory, command.length() > 0 ? null : in, out, err, terminal);
session.put("USER", user);
session.put("APPLICATION", application);
discoverCommands(session, cl, getDiscoveryResource());