protected String replaceAlias(String line, Session session) throws ShellException {
   boolean changed = true;
   Set<String> appNames = new HashSet<String>();
   while (changed) {
     changed = false;
     String appName = AppCommandParser.parseOutAppName(line);
     String prefixedKey = Alias.ALIAS_PREFIX + appName;
     String alias = (String) AbstractApp.safeGet(session, prefixedKey);
     if (alias != null && appNames.add(alias)) {
       changed = true;
       line = alias + line.substring(appName.length());
     }
   }
   return line;
 }
  public App findApp(String command) {
    Class<? extends App> app = this.apps.get(command);
    if (app == null) {
      return null;
    }

    App result = this.appInstances.get(app);
    if (result == null) {
      try {
        result = app.newInstance();
        ((AbstractApp) result).setServer(this);
        this.appInstances.put(app, result);
      } catch (Exception e) {
        // TODO It's OK, or is it?
      }
    }
    return result;
  }