• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Spring beans with the same property name but different references

 
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic