private DefaultExpanderResolver resolveDSLFiles() throws IOException {
DefaultExpanderResolver resolver = new DefaultExpanderResolver();
final File dir = new File( this.srcdir.getAbsolutePath() );
DSLMappingFile file = new DSLTokenizedMappingFile();
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir,
String name) {
return name.endsWith( ".dsl" );
}
};
String[] children = dir.list( filter );
if ( children.length == 0 ) {
throw new BuildException( "There are no DSL files for this directory:" + this.srcdir.getAbsolutePath() );
}
for ( int index = 0; index < children.length; index++ ) {
if ( file.parseAndLoad( new StringReader( loadResource( children[index] ) ) ) ) {
final Expander expander = new DefaultExpander();
expander.addDSLMapping( file.getMapping() );
resolver.addExpander( "*",
expander );
} else {
throw new RuntimeDroolsException( "Error parsing and loading DSL file." + file.getErrors() );
}
}
return resolver;
}