当前位置: 首页>>代码示例>>Java>>正文


Java DefaultFileMonitor.start方法代码示例

本文整理汇总了Java中org.apache.commons.vfs2.impl.DefaultFileMonitor.start方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultFileMonitor.start方法的具体用法?Java DefaultFileMonitor.start怎么用?Java DefaultFileMonitor.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.vfs2.impl.DefaultFileMonitor的用法示例。


在下文中一共展示了DefaultFileMonitor.start方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFileModified

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public void testFileModified() throws Exception
{
    writeToFile(testFile);
    FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
    DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
    monitor.setDelay(100);
    monitor.addFile(fileObj);
    monitor.start();
    // Need a long delay to insure the new timestamp doesn't truncate to be the same as
    // the current timestammp. Java only guarantees the timestamp will be to 1 second.
    Thread.sleep(1000);
    long value = System.currentTimeMillis();
    boolean rc = testFile.setLastModified(value);
    assertTrue("setLastModified succeeded",rc);
    Thread.sleep(300);
    assertTrue("No event occurred", changeStatus != 0);
    assertTrue("Incorrect event", changeStatus == 1);
    monitor.stop();
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:20,代码来源:DefaultFileMonitorTests.java

示例2: testFileRecreated

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public void testFileRecreated() throws Exception
{
    FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
    DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
    monitor.setDelay(100);
    monitor.addFile(fileObj);
    monitor.start();
    writeToFile(testFile);
    Thread.sleep(300);
    assertTrue("No event occurred", changeStatus != 0);
    assertTrue("Incorrect event " + changeStatus, changeStatus == 3);
    changeStatus = 0;
    testFile.delete();
    Thread.sleep(300);
    assertTrue("No event occurred", changeStatus != 0);
    assertTrue("Incorrect event " + changeStatus, changeStatus == 2);
    changeStatus = 0;
    Thread.sleep(500);
    monitor.addFile(fileObj);
    writeToFile(testFile);
    Thread.sleep(300);
    assertTrue("No event occurred", changeStatus != 0);
    assertTrue("Incorrect event " + changeStatus, changeStatus == 3);
    monitor.stop();
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:26,代码来源:DefaultFileMonitorTests.java

示例3: start

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
/**
 * Starts watching the file system for changes to trigger a bake.
 *
 * @param res Commandline options
 * @param config Configuration settings
 */
public void start(final LaunchOptions res, CompositeConfiguration config) {
    try {
        FileSystemManager fsMan = VFS.getManager();
        FileObject listenPath = fsMan.resolveFile(res.getSource(), config.getString( ConfigUtil.Keys.CONTENT_FOLDER));
        FileObject templateListenPath = fsMan.resolveFile(res.getSource(), config.getString( ConfigUtil.Keys.TEMPLATE_FOLDER));
        FileObject assetPath = fsMan.resolveFile(res.getSource(), config.getString( ConfigUtil.Keys.ASSET_FOLDER));


        System.out.println("Watching for (content, template, asset) changes in [" + res.getSource() + "]");
        DefaultFileMonitor monitor = new DefaultFileMonitor(new CustomFSChangeListener(res, config));
        monitor.setRecursive(true);
        monitor.addFile(listenPath);
        monitor.addFile(templateListenPath);
        monitor.addFile(assetPath);
        monitor.start();
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
}
 
开发者ID:jbake-org,项目名称:jbake,代码行数:26,代码来源:BakeWatcher.java

示例4: watchDir

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
@Override
public void watchDir(File file) throws IOException {

	FileSystemManager fileSystemManager = VFS.getManager();
	FileObject dirToWatchFO = null;
	dirToWatchFO = fileSystemManager.resolveFile(file.getAbsolutePath());

	//IFileListenerService fileListener = this.beanService.getBean(ApacheDefaultFileListener.class);
	DefaultFileMonitor fileMonitor = this.beanService.getBean(DefaultFileMonitor.class);

	fileMonitor.setRecursive(true);
	fileMonitor.addFile(dirToWatchFO);
	fileMonitor.start();
	
	this.fileMonitors.add(fileMonitor);
}
 
开发者ID:vauvenal5,项目名称:pieShare,代码行数:17,代码来源:ApacheFileWatcherService.java

示例5: start

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
/**
 * Starts watching the file system for changes to trigger a bake.
 *
 * @param res Commandline options
 * @param config Configuration settings
 */
public void start(final LaunchOptions res, CompositeConfiguration config) {
    try {
        FileSystemManager fsMan = VFS.getManager();
        FileObject listenPath = fsMan.resolveFile(res.getSource(), config.getString( ConfigUtil.Keys.CONTENT_FOLDER));

        System.out.println("Watching for changes in [" + res.getSource() + "]");
        DefaultFileMonitor monitor = new DefaultFileMonitor(new CustomFSChangeListener(res, config));
        monitor.setRecursive(true);
        monitor.addFile(listenPath);
        monitor.start();
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:21,代码来源:BakeWatcher.java

示例6: startThread

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
/**
 * Start a worker thread to listen for directory changes.
 */
public void startThread() {
    thread = new Thread(this);
    listener = new WatchEventListener(config.getEvents(), config.getFolder());
    fm = new DefaultFileMonitor(listener);
    fm.setRecursive(false); 
    fm.addFile(resolvedAbsPath);
    fm.start();
    log.debug("Monitoring directory: " + resolvedAbsPath.toString());
    thread.start();
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:14,代码来源:WatchLocalRunner.java

示例7: startThread

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
/**
 * Start a worker thread to listen for directory changes.
 */
public void startThread() {
    thread = new Thread(this);
    listener = new WatchEventListener(config.getEvents(), config.getFolder() + config.getConnection().getPathtomonitor());
    fm = new DefaultFileMonitor(listener);
    fm.setRecursive(false);
    fm.addFile(resolvedAbsPath);
    fm.start();
    log.debug("Monitoring setup for directory: " + config.getFolder() + config.getConnection().getPathtomonitor());
    thread.start();
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:14,代码来源:WatchFTPRunner.java

示例8: setFileListener

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public void setFileListener(File file, EncryptedFileDob dob){
	FileObject listendir = null;
	try {
		FileSystemManager fsManager = VFS.getManager();
		listendir = fsManager.resolveFile(file.getPath());
	} catch (FileSystemException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	DefaultFileMonitor fm = new DefaultFileMonitor(new FileChangeListener(dob));
	 fm.setRecursive(true);
	 fm.addFile(listendir);
	 fm.start();
}
 
开发者ID:dev131,项目名称:DropTillLate_Application,代码行数:15,代码来源:FileHandler.java

示例9: testFileCreated

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public void testFileCreated() throws Exception
{
    FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
    DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
    monitor.setDelay(100);
    monitor.addFile(fileObj);
    monitor.start();
    writeToFile(testFile);
    Thread.sleep(300);
    assertTrue("No event occurred", changeStatus != 0);
    assertTrue("Incorrect event", changeStatus == 3);
    monitor.stop();
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:14,代码来源:DefaultFileMonitorTests.java

示例10: testFileDeleted

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public void testFileDeleted() throws Exception
{
    writeToFile(testFile);
    FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
    DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
    monitor.setDelay(100);
    monitor.addFile(fileObj);
    monitor.start();
    testFile.delete();
    Thread.sleep(300);
    assertTrue("No event occurred", changeStatus != 0);
    assertTrue("Incorrect event", changeStatus == 2);
    monitor.stop();
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:15,代码来源:DefaultFileMonitorTests.java

示例11: watch

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public void watch() throws FileSystemException {
    FileSystemManager manager = VFS.getManager();
    FileObject file = manager.resolveFile(
            this.compassCompiler.getConfigFile().getParentFile().getAbsolutePath());

    DefaultFileMonitor fm = new DefaultFileMonitor(new CompassWatchListener(this.compassCompiler));
    fm.setRecursive(true);
    fm.setDelay(2000);
    fm.addFile(file);
    fm.start();
}
 
开发者ID:ricardjp,项目名称:jcompass,代码行数:12,代码来源:CompassWatcher.java

示例12: init

import org.apache.commons.vfs2.impl.DefaultFileMonitor; //导入方法依赖的package包/类
public static void init() throws TalesException {

		try{

			if(!inited){

				inited = true;

				for(DirListenerObj dirObj : Config.getDirListenerList()){

					String dir = dirObj.getDir().replace("~", System.getProperty("user.home"));

					FileSystemManager fsManager = VFS.getManager();
					FileObject listendir = fsManager.resolveFile(dir);
					DefaultFileMonitor fm = new DefaultFileMonitor(new OnChange(dirObj));
					fm.setRecursive(true);
					fm.addFile(listendir);
					fm.start();
					
				}


				// prevents the app of exiting
				while(true){
					Thread.sleep(1000);
				}

			}

		}catch(Exception e){
			throw new TalesException(new Throwable(), e);
		}

	}
 
开发者ID:matsufan,项目名称:tales-core,代码行数:35,代码来源:DirListener.java


注:本文中的org.apache.commons.vfs2.impl.DefaultFileMonitor.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。