geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: [xbean] annotation based dependency injection
Date Wed, 05 Apr 2006 08:59:46 GMT
On Apr 4, 2006, at 11:37 PM, James Strachan wrote:

> On 4/4/06, David Blevins <> wrote:
>> On Apr 3, 2006, at 5:12 AM, James Strachan wrote:
>>>> so I'm sure the XBean/OpenEJB folks will be implementing this
>>> anyway.
>>> I'm not yet at that point in understanding what Dave B. has already
>>> done in OpenEJB 3, but you're right it will be of high priority to
>>> implement.
>>> Agreed. Adding support for AnDI into XBean would be pretty easy
>>> then OpenEJB could reuse that. I ultimately want the entire
>>> Geronimo kernel to support AnDI; whether you use EJB3 or not.
>> Trick is the @Resource annotation can't be used to annotate a
>> constructor.
>> Know anyone on JSR 250 who'd propose changing that?
> Good point - though before JSR 250 & EJB 3, when Pico was just
> starting, I tended to use the convention that contructor arguments
> were 'mandatory' properties and setter methods were for optional stuff
> (or stuff that can be configured after construction).
> i.e.  its kinda implicit that any constructor arguments must be
> injected to be able to construct the object - so they are mandatory
> already. I guess a container could shove in null objects or zero
> values if it can't find a value, but maybe its easier to just say that
> for constructor injection, the parameters should be considered
> mandatory?

I get it -- you're using @Resource to imply whether or not an object  
attribute is optional or required.  We're talking about different  
things then.  Was more going after EJB 3 perspective where @Resource  
is primarily used to label an object attribute with an identifier and  
optional mapping the injector understands (such as a jndi name, an  
xml attribute or element name, or whatever).

Seems like in your scenario, someone couldn't use the annotation to  
specify how object attribute would be populated via an injectable  
resource but still let it be an optional dependency.  Guessing you  
don't really care though :)


View raw message