I just did a ** COMPLETELY UNTESTED** commit that shows the basic outline
of how I think it should work.
See: svn diff -c 72623
Once this works, i.e. it is tested, you can write a generic annotation deployer
that runs off the module.
Something like:
| public GenericAnnotationDeployer extends AbstractRealDeployer<Module>
| {
| public GenericAnnotationDeployer()
| {
| super(Module.class);
| setStage(DeploymentStages.POST_CLASSLOADER);
| }
|
| public void deploy(DeploymentUnit unit, Module module)
| {
| module.visit(new MyVisitor());
| }
|
| public class MyVisitor extends ClassVisitor
| {
| public void visit(ResourceContext context)
| {
| // Annotation processing here
| }
| }
| }
|
This approach has a number of advantages:
1) This is a generic classloader resource visitor that understands the
classloading rules. i.e. nested roots are not processed twice, the
include/exclude filters are applied, etc.
2) Although the example above visits classes it is generic enough to work
for resources (or anything else you want to filter).
3) The current visit is implemented for the VFSClassLoader. But it could
be done for any classloader plugged in as a Module.
4) The VFS api is not exposed through this api so there can be no complaints
from other projects about JBoss dependencies. The ResourceContext
exposes things like the URL, name, classLoader, InputStream, bytes
of the resource which can be easily used in other projects.
5) It doesn't require any classloading to do the visit. It only requires
the classloader to exist. But this could be relaxed since we only require that
to include it in the ResourceContext in case somebody wants to actually
do classloading.
6) The deployer can get on with doing what it does best. Processing annotations
rather than worrying about classloading rules or where classes are located, etc.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4146200#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...