[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Providing bean name aware feature

adrian@jboss.org do-not-reply at jboss.com
Tue Jul 17 08:56:48 EDT 2007


"alesj" wrote : "adrian at jboss.org" wrote : I thought I said not to add that xml config?
  |   | You're not listening to any of my objections on this which has just led to all
  |   | sorts of hacks and stupid configurations.
  |   | 
  | Yup.
  | I did respond I'll do them both though. :-(
  | 

I said don't do it, to which you responded "I'll do it anyway. ;-)


  | The thing is people - like ThomasD - want to write as little code as possible to get name injected.
  | 

Yes that is the annotation.

anonymous wrote : 
  | So that I don't screw it up for the Nth time, what should we use then? :-)
  | 

We just need a way to say I want to inject some metadata from the context.
There could be other things in future like:

  | @Inject(fromContext="metadata")
  | void setMetaData(MetaData md);
  | 
  | @Inject(fromContext="scope")
  | void setScope(Scope scope);
  | 

Though I doubt they will get used that often.
More likely would be the GUID when it has been implemented.

Injecting the name is probably not what people want anyway
if the name exists in multiple scopes/deployments.


  | @Inject(fromContext="id")
  | void setID(Object id);
  | 

"adrian at jboss.org" wrote : 
  | 3) The idea of hardwiring "setName" into the microcontainer code
  | as some kind of default is just stupid.
  | e.g. What if the bean already uses the "name" property for something else?

You should be aware that setName is not used for bean name, and you actually set name-method attribute.

Yes, but this is not what we want the annotation to look like.
The XML should reasonably match the annotation in structure and features.

If you're talking about ease of use then you can always have an
alternative annotation/xml element that means the same thing as the long winded
injection. e.g.


  | @BeanName // == @Inject(fromContext="name")
  | public void setName(String name);
  | 
  | <property name="name"><bean-name/></property>
  | or even
  | <bean-name property="name"/>
  | 

Both of the xml examples above could be parsed to the real PropertyMetaData

  | <property name="name"><inject fromContext="name"/></property>
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4064983#4064983

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4064983



More information about the jboss-dev-forums mailing list