Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic bean.xml in Spring Framework  RSS feed

 
tusharlondhe londheAdmin
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I have a bean.xml

<bean id="User" class="com.module.spring.basic.User">
<property name="userName">
<value>ABCD</value>
</property>
</bean>

Now how to make this bean.xml dynamic so that I can pass user provided values.
 
Bhagat Singh Rawat
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tusharlondhe londheAdmin wrote:Hi Guys,

I have a bean.xml

<bean id="User" class="com.module.spring.basic.User">
<property name="userName">
<value>ABCD</value>
</property>
</bean>

Now how to make this bean.xml dynamic so that I can pass user provided values.



Once you get the bean instance by using ctx.getBean("User"), then you can set dynamic name value as userBean.setUserName("User_New_Name") before using the hard coded name "ABCD".
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I would only set the property in the xml, only if I wanted a default value, and even then if it isn't deploy specific, then I would put the default value in my code.

Anyway, just because you set a property in configuration doesn't mean that you can never call the setter method yourself in code once you get a reference to it.

Mark
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!