You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xbean-dev@geronimo.apache.org by David Blevins <da...@visi.com> on 2006/11/02 08:13:00 UTC

Re: xbean-finder: ClassFinder

More updates to the ClassFinder....

You can now construct the finder with exactly the list of classes you  
want to search for annotations.  It uses var args too, so you can  
easily specify one class if you like.  Convenient for when you have  
some of the code that "picks" which class or classes should be  
scraped for annotated methods, fields, constructors, etc.

I also added a 'findClassesInPackage' method that allows you to suck  
in all the classes under a certain package name.  This can be done  
recursively or not.

-David

On Oct 30, 2006, at 8:47 PM, David Blevins wrote:

>
> On Oct 27, 2006, at 12:13 PM, David Blevins wrote:
>
>> So added a finder for searching for classes that have a specific  
>> annotation, etc.  It's there it works and is better than some of  
>> the code i've seen that does the same, but... I still hate it as  
>> like all the approaches I've seen it loads the classes and uses  
>> reflection to determine if the annotation is present.
>>
>> This is the most insecure code I can think of, so I'm yanking it  
>> in leu of an asm-based approach.  So take this as your warning not  
>> to start consuming the ClassFinder just yet.
>>
>
> Done.  It's now ASM-based and you can lookup any of the following  
> annotated things:
>
>   - Packages
>   - Classes
>   - Constructors
>   - Methods
>   - Fields
>
> Reflection does not occur till you ask for a set of classes that  
> have the annotation you require.  The loaded classes are then kept  
> for future use.
>
> -David
>
>


Re: xbean-finder: ClassFinder

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 11/2/06, David Blevins <da...@visi.com> wrote:
> More updates to the ClassFinder....
>
> You can now construct the finder with exactly the list of classes you
> want to search for annotations.  It uses var args too, so you can
> easily specify one class if you like.  Convenient for when you have
> some of the code that "picks" which class or classes should be
> scraped for annotated methods, fields, constructors, etc.
>
> I also added a 'findClassesInPackage' method that allows you to suck
> in all the classes under a certain package name.  This can be done
> recursively or not.

Awesome! I've already taken a look at the changes and wonder why it
wasn't me who came up with such an easy yet brilliant solution. I
think I couldn't already have done it, but somehow I can't find an
answer why I didn't ;-) It seems so easy now.

Time to write some docs and examples about it. I'll be doing some for
OpenEJB 3 (it looks it became a reference implementation for XBean and
those new features ;-))

Jacek

-- 
Jacek Laskowski
http://www.jaceklaskowski.pl