Le lundi 30 mai 2011 11:30:30, Rickard Öberg a écrit :
> 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

Hi Rickard,

It's great to see application assembly getting such improvements. Actually it
can be painfull when you have a lot of fragments. I will use this and it will 
reduce  assembly code in my applications.

I wonder what is the scope of the basic getClasses() scanner. Do it return all
classes in the same package as the "starting point" class ?

Regards

/Paul

-- 
Paul Merlin - eskatos.github.com

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to