Java Code Examples for

The following examples show how to use These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: roboconf-platform   Source File:    License: Apache License 2.0 6 votes vote down vote up
public void onStart( final FileAlterationObserver observer ) {

	if( this.alreadyStarted.getAndSet( true ))

	this.logger.fine("Initial provisioning of templates...");
	final Collection<File> templateFiles = FileUtils.listFiles(

			// Find readable template files.
					FileFilterUtils.suffixFileFilter( ".tpl" ),

			// Directory filter: go through the root template directory and its direct children.
			new TemplateDirectoryFileFilter( this.templateDir ));

	process( templateFiles );
Example 2
Source Project: roboconf-platform   Source File:    License: Apache License 2.0 4 votes vote down vote up
 * Constructor.
 * @param manager the templating manager, to which event handling is delegated.
 * @param templateDir the templates directory to watch.
 * @param pollInterval the poll interval.
 * @throws IOException if there is a problem watching the template directory.
public TemplateWatcher( final TemplatingManager manager, final File templateDir, final long pollInterval ) {
	this.templateDir = templateDir;

	// Register the custom helpers.
	this.handlebars.registerHelper( AllHelper.NAME, new AllHelper());
	this.handlebars.registerHelper( IsKeyHelper.NAME, new IsKeyHelper());

	// Pretty formatting
	this.handlebars.prettyPrint( true );

	// Create the observer, register this object as the event listener.
	FileFilter fileFilter = FileFilterUtils.or(
					FileFilterUtils.suffixFileFilter( ".tpl" ),
					new TemplateFileFilter(templateDir)),
					new TemplateSubDirectoryFileFilter(templateDir))

	FileAlterationObserver observer = new FileAlterationObserver( this.templateDir, fileFilter );
	observer.addListener( this );

	// Create the monitor.
	this.monitor = new FileAlterationMonitor( pollInterval, observer );
	this.monitor.setThreadFactory( THREAD_FACTORY );

	this.manager = manager;
	this.logger.fine( "Template watcher is watching "
			+ this.templateDir
			+ " with an interval of " + pollInterval + " ms." );
Example 3
Source Project: allure1   Source File:    License: Apache License 2.0 2 votes vote down vote up
 * Returns list of files matches specified regex in specified directories
 * @param regex       to match file names
 * @param directories to find
 * @return list of files matches specified regex in specified directories
public static List<File> listFilesByRegex(String regex, File... directories) {
    return listFiles(directories,
            new RegexFileFilter(regex),