File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Spring beans with the same property name but different references Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring beans with the same property name but different references" Watch "Spring beans with the same property name but different references" New topic
Author

Spring beans with the same property name but different references

Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
Hi,

This is the way we have code currently.



I was wondering if I can have something like below. I want to be able to use TesterTwo or TesterThree in certain scenarios without any changes to the java class referencing the bean.


Is this possible? If yes, how?

Thanks.


Be Humble... Be Nice.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Under what circumstances. Can it be defined in code. You can use Spring 3.0 Expression Language, or the PropertyPlaceholderConfigurer.

SPel would be #{} where inside the curly braces is some method call or other evaluation that determines what you want to set your ref to.

PropertyPlaceholderConfigurer would be ${variable_name} using a .properties file to store the ref value.

There are always the Factory pattern you can use to create the ref that you need also.

There are many solutions, but without knowing how you determine the ref value you want we can't help more.

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
 
subject: Spring beans with the same property name but different references