/** {@inheritDoc} */
  @Override
  public void postInit() {
    super.postInit();
    synchronized (lock) {
      if (fileAlterationMonitor == null) {
        fileWatchListener = new FileWatchListener(ConfigurationUtilities.getInstance());
        fileAlterationMonitor = new FileAlterationMonitor();
        File confDir = getFilesystemConfiguration().getConfigurationDirectory();
        FileAlterationObserver observer = new FileAlterationObserver(confDir);

        observer.addListener(getFileWatchListener());
        fileAlterationMonitor.addObserver(observer);

        try {
          fileAlterationMonitor.start();
        } catch (Exception exc) {
          logger.error("Could not start file monitor", exc);
        }
      }
    }
  }
  /** {@inheritDoc} */
  @Override
  public void preDestroy() {
    super.preDestroy();
    synchronized (lock) {
      try {
        if (fileAlterationMonitor != null) fileAlterationMonitor.stop(10);
        if (fileWatchListener != null) fileWatchListener.clear();

        fileAlterationMonitor = null;
        fileWatchListener = null;
      } catch (Exception exc) {
        logger.error("Could not stop file monitor", exc);
      }
    }
  }
Exemplo n.º 3
0
 /**
  * 从alterationMonitor中删除fileObserver
  *
  * @param fileObserver
  */
 private void removeObserver(SeafileObserver fileObserver) {
   alterationMonitor.removeObserver(fileObserver.getAlterationObserver());
 }
Exemplo n.º 4
0
 /**
  * 将fileObserver加入到alterationMonitor中
  *
  * @param fileObserver
  */
 private void addObserver(SeafileObserver fileObserver) {
   alterationMonitor.addObserver(fileObserver.getAlterationObserver());
 }
Exemplo n.º 5
0
 public void stop() throws Exception {
   alterationMonitor.stop();
 }
Exemplo n.º 6
0
 private void start() throws Exception {
   if (!started) {
     alterationMonitor.start();
     started = true;
   }
 }