users@jaxb.java.net

Re: Classpath scanning for classes

From: Brian Pontarelli <brian_at_pontarelli.com>
Date: Thu, 12 Jun 2008 15:59:14 -0600

Hehe. Yeah the name is slightly strange because there is also a
ResourceClassLoaderResolver that just returns URLs.

I doubt I'll have much time to help out on this in the near future
except give advice and point you in the right direction (having done a
lot of discovery stuff lately). JCatapult is taking up a LOT of my time
right now. Once the MVC is finished I could probably help out on
whatever is needed here.

-bp


Dimitris Andreou wrote:
> I think I mentioned that they use ASM too to avoid class loading. So
> someone should pick the best implementation. Not me though, because
> amazingly, I was unable to track either code.
> Next time I'll ask for direct links. There is simply no matching class
> in spring that starts with "Classpath", or ends in "Reader" and does
> this work. (And yes, the name has 4 or 5 words in it, so it would be a
> miracle if they themselves remembered the names). No, the author
> didn't remember even the package name :(
> Anyway, it seems that ClassClassLoaderResolver.AnnotatedWith class
> does just that. (ClassClassLoaderResolver? Strange name there :)). So,
> Koshuke, it seems Brian can handle the issue more effectively! :)
> Bye,
> Dimitris
>
> Koshuke, I think you found your volunteer :)
>
> O/H Brian Pontarelli έγραψε:
>>
>> I've done just that in the Java.net Commons trunk. It is in a class
>> called ClassClassLoaderResolver and it leverages ASM to do the byte
>> code parsing. ASM is *MUCH* faster than loading the class into the
>> JVM. Feel free to take a look and see:
>>
>> https://java-net-commons.dev.java.net
>>
>> I use it in JCatapult (http://www.jcatapult.org) to locate Guice
>> modules dynamically as well as in the new JCatapult MVC to find class
>> annotated with @Action, which are controllers. It works really well.
>> The version on trunk should work and you can just copy and paste it
>> into your project.
>>
>> -bp
>>
>>
>> Kohsuke Kawaguchi wrote:
>>>
>>> Thank you.
>>>
>>> I'd imagine a little glue code that uses this to figure out classes
>>> with a JAXB annotation and then return it as Class[] would be a nice
>>> JAXB commons project.
>>>
>>> From there, people can easily create JAXBContext.
>>>
>>> Would you be interested in writing on, Dimitris? :-)
>>>
>>> Dimitris Andreou wrote:
>>>> Hi Koshuke,
>>>> I'm at SpringOne conference @ Belgium. I see that spring (2.5) has
>>>> a new utility that scans classes out of the classpath (searching
>>>> for some annotated classes).
>>>> Although I was not able to find the code (yet), it sounds like that
>>>> could be modified/used to alleviate the need for XmlSeeAlso. Well,
>>>> there are caveats for you
>>>> (or, your replacement anyway! :)) to consider though. It supports
>>>> either directories or jar files, and parses .class files with ASM
>>>> to avoid actually loading them.
>>>> And it uses some package-prefix filtering, or else it would be
>>>> hugely slow.
>>>> Even if the need of an annotation won't be completely eliminated
>>>> (you would still need a package prefix to look for...), maybe
>>>> another annotation, or XmlSeeAlso itself,
>>>> could handle package declarations, and would look in them for
>>>> subtypes.
>>>>
>>>> Anyway, just dropped a note in case you would find this interesting.
>>>
>>>
>>
>>
>