开发者

Spring and factory object

I have an abstract class with a static method that returns either one concrete subclass

or another, depending on this static method's arguments.

How do I define a bean in spring configuration f开发者_开发技巧ile that will invoke this static method with the arguments?


From the Spring documentation, you just treat the parameters as constructor arguments:

<bean id="exampleBean" class="examples.ExampleBean" factory-method="createInstance">
  <constructor-arg ref="anotherExampleBean"/>
  <constructor-arg ref="yetAnotherBean"/>
  <constructor-arg value="1"/> 
</bean>


http://static.springsource.org/spring/docs/2.0.4/reference/beans.html

See sections 3.2.3.2.2 and 3.2.3.2.3 - I think that might be what you're looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜