Example #1
0
  @Override
  public void shutdown() {
    if (closed.compareAndSet(false, true)) {
      if (scheduler != null) {
        logger.debug("Shutting down the scheduler");
        scheduler.shutdown();
      }
      shellScope.closeAllResources();

      shellHttpClient.shutdown();

      console.println();
      console.println(MessagesProvider.getMessage(ShellSettings.BYE_MESSAGE));

      console.shutdown();
    }
  }
Example #2
0
 protected void doRun() {
   while (true) {
     CompilableSource source = null;
     try {
       source = compilableSourceReader.read(getPrompt());
     } catch (Exception e) {
       logger.error(e.getMessage(), e);
       console.println("Error while checking the input: " + e.toString());
     }
     if (source != null) {
       Object jsResult = scriptExecutor.execute(source);
       Object javaResult = unwrap(jsResult);
       if (javaResult instanceof ExitSignal) {
         shutdown();
         return;
       }
       if (javaResult != null) {
         console.println(javaToString(javaResult));
       }
     }
   }
 }
Example #3
0
  protected void printLogoAndWelcomeMessage() {

    StringBuilder logoBuilder = new StringBuilder();
    logoBuilder.append("               ___       \n");
    logoBuilder.append("             //   \\\\   \n");
    logoBuilder
        .append("         (( ((     ))    ")
        .append(MessagesProvider.getMessage(ShellSettings.WELCOME_MESSAGE));
    logoBuilder.append("         ((  \\\\___//   \n");
    logoBuilder.append("        {{     //        \n");
    logoBuilder.append("         ((   //  ))     \n");
    logoBuilder.append("         ((  //    }}    \n");
    logoBuilder.append("         ((_______))     \n");

    console.println(logoBuilder.toString());
  }
Example #4
0
  protected void enablePlaygroundMode() {
    console.print("Enabling playground mode");

    final StringBuilder messageBuilder = new StringBuilder();

    new ExecutorWithProgress<Void>(
            console,
            new ExecutorWithProgress.ActionCallback<Void>() {
              @Override
              public Void execute() {
                Node<ShellNativeClient, JsonInput, JsonOutput> node = nodeFactory.newLocalNode();
                shellScope.registerJavaObject("node", node);
                messageBuilder.append(node.toString()).append(" available as node").append("\n");
                ShellNativeClient shellNativeClient = node.client();
                shellScope.registerJavaObject("es", shellNativeClient);
                messageBuilder.append(shellNativeClient.toString()).append(" available as es");
                return null;
              }
            })
        .execute();

    console.println(messageBuilder.toString());
  }
Example #5
0
 protected void registerClient(ShellNativeClient shellNativeClient) {
   shellScope.registerJavaObject("es", shellNativeClient);
   console.println(shellNativeClient.toString() + " available as es");
 }