Hi,
In our project we have lots and lots of values, entities and transient
objects that need to be registered, and I myself consistently forget to
do it. So, I have now finally implemented a simple classpath scanner
that helps bulk registering of classes.
Here's how it works. You give it a "starting point" class. From there it
finds the corresponding path (file system or jars are supported), and
traverse that to return an Iterable<Class> that can then be further
filtered. This can then be used to register classes in Qi4j assemblies
easily.
Example>
for( Class aClass : filter( matches( ".*Value" ), getClasses(
TestValue.class ) ))
{
module.values(aClass);
}
---
The getClasses() is the basic scanner, and then I've further filtered it
by saying to only include classes whose names match a particular regexp.
You can do any kind of filtering you want, of course, so it is quite
flexible.
Has anyone else seen similar requirements? Anything I should add to this
before committing?
/Rickard
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev