public static void main(String... args) {
   File cacheDirectory = new File(".cache");
   CachedRepresentationManager manager = CachedRepresentationManager.create(cacheDirectory);
   try {
     ShellConsole console = ShellUtil.console();
     console
         .title("ESWC 2015 - LDP4j Tutorial - Contacts Application Shell ")
         .message("v%s%n", System.getProperty("shell.build", "XXX"));
     ContactsShell shell = new ContactsShell(console, ResourceRepository.create(), manager);
     shell.execute();
     console.title("Bye!!!");
   } finally {
     manager.dispose();
   }
 }
示例#2
0
  /** {@inheritDoc} */
  @Override
  public synchronized void stopApp() {
    super.stopApp();

    println(" ");
    println("Remote shell session terminated.");
    println("type ~. to exit rsh");
    println(" ");
    // Give a couple of seconds to help ensure that the message will be sent.
    try {
      Thread.sleep(2000);
    } catch (InterruptedException ie) {
    }
    getInputPipe().close();
    getOutputPipe().close();

    if (timerTask != null) {
      timerTask.cancel();
    }

    if (cons != null) {
      cons.destroy();
    }
  }
示例#3
0
  public void performJob(String name) {

    bb.addListener(
        GraphAttrSet.name,
        new Listener() {
          public void keyChanged(String key, Object value) {
            GraphModel gm = bb.getData(GraphAttrSet.name);
            try {
              main_interpreter.set(gm.getLabel(), gm);
            } catch (EvalError evalError) {
              evalError.printStackTrace();
            }
          }
        });
    evaluations += "clr(){console.clear();}";
    evaluations = "import graphlab.graph.graph.*;" + evaluations;

    ext_console = (ShellConsole) UIUtils.getComponent(bb, "ShellSideBar");
    ext_console.shell = this;
    final ShellConsole console = ext_console;
    main_interpreter = new Interpreter(console);
    parser = new InwardCommandParser(main_interpreter, this);
    parser.addCommands(new GraphCommands(bb));
    //        parser.addCommands(new ShellServerCommands(bb));
    parser.addCommands(new VertexCommands(bb));
    parser.addCommands(new EdgeCommands(bb));
    parser.addCommands(new NativeCommands(bb));
    evaluations = InwardCommandParser.evaluations;
    ShellCodeCompletion code_completion =
        new ShellCodeCompletion(
            main_interpreter, parser.commands, parser.abbrs, code_completion_dictionary);
    console.setNameCompletion(code_completion);

    new Thread() {
      public void run() {
        try {
          main_interpreter.set("abbreviations", parser.abbrs);
          main_interpreter.set("code_completion_dictionary", code_completion_dictionary);
          main_interpreter.set("evaluations", evaluations);
          main_interpreter.set("console", console);
          main_interpreter.set("blackboard", bb);
          main_interpreter.set("graphdata", new GraphData(bb));
          parser.abbrs.put("_clr", "clr");
          //                    main_interpreter.set("me", Shell.this);
          main_interpreter.eval(evaluations);
        } catch (EvalError evalError) {
          evalError.printStackTrace();
        }
        main_interpreter.run();
      }
    }.start();

    // for not printing 'by niemeyer'
    new Thread() {

      public void run() {
        try {
          Thread.sleep(1000);
          console.clear();
          console.print("bsh % ");
        } catch (InterruptedException e) {
          ExceptionHandler.catchException(e);
        }
      }
    }.start();
  }