1

I am working on a legacy application and am converting it to spring. It currently uses a static flag to do some code differently depending on the country which it has been deployed in. For example:

public void myMethod() {
    //a load of code here

    if(Flags.US_BUILD == true) {
        //US Build exclusive code here
    }

    //do some more code
}

Intuitively my approach would be to decouple the U.S code into an interface for which the appropriate implementation get's wired in depending on whether the build is U.S or not. I am wondering if this can be configured in my spring beans definition file (ie checking against a flag to control how things are wired), or if I am aiming at the right approach at all?

mogronalol
  • 2,946
  • 8
  • 38
  • 56

2 Answers2

3

Have a look at Spring 3.1 Profiles.

Ralph
  • 118,862
  • 56
  • 287
  • 383
1

If you don't use spring 3.1 and can't use profiles (as Ralph suggested) you can look here https://stackoverflow.com/a/3036044/221951

Community
  • 1
  • 1
Piotr Gwiazda
  • 12,080
  • 13
  • 60
  • 91