Ejemplo n.º 1
0
  /** Loads the optional startup script */
  void loadStartupScript() {
    final String startupScript = shellSettings.settings().get(ShellSettings.STARTUP_SCRIPT);
    if (startupScript != null) {
      console.print("Loading startup script " + startupScript);

      new ExecutorWithProgress<Void>(
              console,
              new ExecutorWithProgress.ActionCallback<Void>() {
                @Override
                public Void execute() {
                  try {
                    scriptLoader.loadScript(startupScript);
                  } catch (Throwable t) {
                    logger.error("Error loading the startup script [{}]", startupScript, t);
                  }
                  return null;
                }
              })
          .execute();
    }
  }
Ejemplo n.º 2
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());
  }