geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Generic way to handle annotations for integrating projects
Date Tue, 06 Mar 2007 21:43:20 GMT
I've been working on annotation handling for jetty using xbean- 
reflect and have come up with a design for general annotation  
processing that I would like to propose we urge our integrated  
projects to allow or adopt.

This is appropriate when the injection only involves stuff looked up  
in jndi and when the sequence of events is

- construct instance
- inject stuff
- call postConstruct

with no intervening container lifecycle calls.

So I'd like each project to define an interface

public interface <Project>LifecycleSupport {

Object newInstance(String className); //might need a classloader too  
depending on whether the project has per-module instances

void destroyInstance(Object o);

}

and provide a way we can inject such an object into the projects  
framework.

We can then implement the newInstance method to construct and inject  
properties using xbean-reflect and call postConstruct, and  
destroyInstance to call preDestroy.


Another style has been popularized by tomcat (?) which has 3 methods

inject(Object)

postConstruct(Object)

preDestroy(Object)

We can use this style but then we wont be able to use xbean-reflect  
which hides all the hard part :-) and would let us go beyond the spec  
and support constructor injection if we can figure out how to get  
constructor metadata to it.

It's pretty trivial to implement an adapter between my proposal and  
the tomcat style, but not vice versa.

So, where would this be used?  The most likely bits are MyFaces, CXF,  
and Axis2.  I'm already doing something very similar for jetty and  
haven't looked to see if tomcat can be adapted this way.

Thoughts?

thanks
david jencks


Mime
View raw message