Package br.com.ingenieux.mojo.jbake.util

Examples of br.com.ingenieux.mojo.jbake.util.DirWatcher


    getLog().info(
        "Now listening for changes on path " + inputDirectory.getPath());

    initServer();

    DirWatcher dirWatcher = null;

    try {
      dirWatcher = new DirWatcher(inputDirectory);
      final AtomicBoolean done = new AtomicBoolean(false);
      final BufferedReader reader = new BufferedReader(
          new InputStreamReader(System.in));

      (new Thread() {
        @Override
        public void run() {
          try {
            getLog()
                .info("Running. Enter a blank line to finish. Anything else forces re-rendering.");

            while (true) {
              String line = reader.readLine();

              if (isBlank(line)) {
                break;
              }

              reRender();
            }
          } catch (Exception exc) {
            getLog().info("Ooops", exc);
          } finally {
            done.set(true);
          }
        }
      }).start();

      dirWatcher.start();

      do {
        Long result = dirWatcher.processEvents();

        if (null == result) {
          // do nothing on purpose
        } else if (result >= lastProcessed) {
          getLog().info("Refreshing");

          super.execute();

          lastProcessed = Long.valueOf(System.currentTimeMillis());
        }
      } while (!done.get());
    } catch (Exception exc) {
      getLog().info("Oops", exc);

      throw new MojoExecutionException("Oops", exc);
    } finally {
      getLog().info("Finishing");

      if (null != dirWatcher)
        dirWatcher.stop();

      stopServer();
    }
  }
View Full Code Here


            done.set(true);
          }
        }
      }).start();

      DirWatcher dirWatcher = new DirWatcher(Paths.get(inputDirectory
          .getPath()));

      do {
        Boolean result = dirWatcher.processEvents();

        if (Boolean.FALSE.equals(result)) {
          Thread.sleep(1000);
        } else if (Boolean.TRUE.equals(result)) {
          getLog().info("Refreshing");
View Full Code Here

            done.set(true);
          }
        }
      }).start();

      DirWatcher dirWatcher = new DirWatcher(Paths.get(inputDirectory
          .getPath()));

      do {
        Boolean result = dirWatcher.processEvents();

        if (Boolean.FALSE.equals(result)) {
          Thread.sleep(1000);
        } else if (Boolean.TRUE.equals(result)) {
          getLog().info("Refreshing");
View Full Code Here

TOP

Related Classes of br.com.ingenieux.mojo.jbake.util.DirWatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.