コード例 #1
0
ファイル: D.java プロジェクト: vongosling/btrace
  /**
   * Submits a D-script from given file and receives the BTrace script argument array as DTrace
   * macro arguments. The events from DTrace are wrapped as BTrace commands and listener given is
   * notified.
   *
   * @param fileName path to D-script file to submit
   */
  public static void submitFile(String fileName) {
    init();
    if (fileName != null && !fileName.isEmpty()) {
      try {
        File dscript = new File(fileName);
        if (dscript.exists()) {
          Consumer cons = newConsumer();
          cons.compile(dscript, rt.$$());
          start(cons);
        }
      } catch (final IOException e) {
        rt.send(
            ErrorCommand.class,
            new AbstractCommand.Initializer<ErrorCommand>() {

              public void init(ErrorCommand cmd) {
                cmd.setCause(e);
              }
            });
      } catch (final DTraceException dEx) {
        rt.send(
            ErrorCommand.class,
            new AbstractCommand.Initializer<ErrorCommand>() {

              public void init(ErrorCommand cmd) {
                cmd.setCause(dEx);
              }
            });
      }
    }
  }
コード例 #2
0
ファイル: D.java プロジェクト: vongosling/btrace
  /**
   * Submits a D-script string and receives the BTrace script argument array as DTrace macro
   * arguments. The events from DTrace are wrapped as BTrace commands and listener given is
   * notified.
   *
   * @param program D-script as a string
   */
  public static void submit(String oneliner) {
    init();
    if (oneliner != null && !oneliner.isEmpty()) {
      try {
        Consumer cons = newConsumer();
        cons.compile(oneliner, rt.$$());
        start(cons);
      } catch (final DTraceException dEx) {
        rt.send(
            ErrorCommand.class,
            new AbstractCommand.Initializer<ErrorCommand>() {

              public void init(ErrorCommand cmd) {
                cmd.setCause(dEx);
              }
            });
      }
    }
  }
コード例 #3
0
ファイル: DTrace.java プロジェクト: sdgdsffdsfff/btrace
 /**
  * Submits a D-script string and passes the given argument array as DTrace macro arguments. The
  * events from DTrace are wrapped as BTrace commands and listener given is notified.
  *
  * @param program D-script as a string
  * @param args DTrace macro arguments
  * @param listener BTrace command listener that is notified
  */
 public static void submit(String program, String[] args, CommandListener listener)
     throws DTraceException {
   Consumer cons = newConsumer(args, listener);
   cons.compile(program, args);
   start(cons, listener);
 }