package com.blueland.bpm.manage.countAnalysis.service;


import java.io.File;

import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
import org.apache.commons.io.monitor.FileAlterationObserver;

/***
 * 文件变动事件处理器类
 * @author Zane
 * @Time 2019年1月5日 上午11:03:35
 */
public class MyFileListenerAdaptor extends FileAlterationListenerAdaptor{
	
	@Override
	public void onFileCreate(File file) {
		System.out.println("file create.............:"+file.getAbsolutePath());
		super.onFileCreate(file);
	}

	@Override
	public void onFileDelete(File file) {
		System.out.println("file delete.............:"+file.getAbsolutePath());
		super.onFileDelete(file);
	}

	
	@Override
	public void onStart(FileAlterationObserver observer) {
	//	System.out.println("start");
		super.onStart(observer);
	}
	
	@Override
	public void onStop(FileAlterationObserver observer) {
	//	System.out.println("stop");
		super.onStop(observer);
	}
	
	
	@Override
	public void onDirectoryCreate(File directory) {
		System.out.println("dir create........."+directory.getName());
		super.onDirectoryCreate(directory);
	}
	
	@Override
	public void onDirectoryDelete(File directory) {
		System.out.println("dir delete........."+directory.getName());
		super.onDirectoryCreate(directory);
	}
	public static void main(String[] args) {
		MyFileAlterationMonitor monitor = new MyFileAlterationMonitor("C:\\Program Files (x86)\\FlowPortal BPM 6.x\\Attachments", 
				"", 
				new MyFileListenerAdaptor());
		monitor.start();
	}
}
