[Design the new POJO MicroContainer] - Re: Providing bean name aware feature
by alesj
"adrian(a)jboss.org" wrote :
| I said don't do it, to which you responded "I'll do it anyway. ;-)
|
I can deny it and delete/edit the post. :-)
But the 'mea culpa' would stay and haunt me ...
anonymous wrote :
| The point is that the internal MetaData model remains clean.
|
| The only thing you are changing internally is the "inject metadata" to allow
| it to get things from the context instead of another bean.
|
| You can do whatever tricks you like with the xml and annotations to remove
| any boiler plate as long it produces the same metadata underneath.
|
| There's a number of other areas where such a "shorthand" would be useful.
|
Yup.
This is what it should have been done in the first place. :-(
I'll ditch my crap and rewrite this to the upper features.
If there is a bean attribute on the element as well, should I do the actual bean context lookup and perform the fromContext on that context?
And for all the other cases - e.g. type and fromContext - throw exception?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4065039#4065039
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4065039
18 years, 8 months
[Design the new POJO MicroContainer] - Re: Providing bean name aware feature
by adrian@jboss.org
"alesj" wrote : "adrian(a)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(a)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
18 years, 8 months