[jboss-user] [Microcontainer] - Re: What is the correct time to invoke the getProperties on
jaikiran
do-not-reply at jboss.com
Tue Feb 24 09:13:27 EST 2009
"alesj" wrote : The builder just builds metadata.
| Annotation's metadata population happens only in Describe state,
| as we know there that our CL exists == can do class info inspection.
|
Makes sense.
"alesj" wrote :
| I looks like you're actually trying to do what AnnotationToBeanMetaDataFactory is meant for.
After looking at the AnnotationToBeanMetadatFactory, i don't think that's what i am after. So to give you an exact idea of what i am trying to do:
I am dynamically building a bean MyBean which needs another bean MyOtherBean to be injected in it:
public class MyBean
| {
|
| // Inject information will be dynamically added, including the bean name
| // to be injected
| @Inject
| private MyOtherBean otherBean;
| ...
| }
|
The easy way to dynamically build this bean and add the injection attributes is this:
| MyBean mybean = new MyBean();
| BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("blah", mybean.getClass().getName());
| builder.setConstructorValue(mybean);
|
| // create the inject attributes
| ValueMetaData inject = builder.createInject("beanNameOftheDependency", null, null, ControllerState.DESCRIBED);
| builder.addPropertyMetaData("otherBean", inject);
Works fine. However, the thing that i want to avoid is this line:
builder.addPropertyMetaData("otherBean", inject)
I was trying to avoid adding the inject/depends on a "field name" and instead was trying to see if i could create the metadata based on the "type" to inject. Something like:
builder.addPropertyMetadata(MyOtherBean.class.getName(),inject);
The MC would then look for a field of type MyOtherBean and create the injection on MyBean.
So if tomorrow, someone dislikes the field name and changes it to:
public class MyBean
| {
|
| // Inject information will be dynamically added, including the bean name
| // to be injected
| @Inject
| private MyOtherBean iDontLikeTheEarlierName;
| ...
| }
then i could still have this entire thing working.
Maybe MC already has something to achieve this and i am not finding the correct API?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4212615#4212615
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4212615
More information about the jboss-user
mailing list