geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: Generic way to handle annotations for integrating projects
Date Wed, 07 Mar 2007 13:33:02 GMT

On Mar 7, 2007, at 2:46 AM, Lasantha Ranaweera wrote:

> David,
>
> May be a silly question. How about handling JPA  related annotations?

I can think of 2 kinds of jpa related annotations.  There are  
PersistenceManagerRef and PersistenceUnitRef which are injection  
related and that we already handle with our NamingBuilder framework,  
and there are annotations on the entities to help make them  
persistence capable, which the jpa framework we use deals with  
without any help from us: informing the jpa framework about these is  
done by the PersistenceUnitBuilder.  As far as I know an entity  
managed by jpa cannot have injections which would be the situation  
relevant to this proposal.  Does this make sense?

thanks
david jencks


>
> Thanks,
> Lasantha
> David Jencks wrote:
>> 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