I’m working on a SprinBoot application where I have two implementations of a particular Service, a real one and a proxy one. The interface looks like this:
`
@Service
public interface RefundService {
String checkHealth();
}`
The proxy implementation looks like this:
@Service @Qualifier("proxyRefundService") public class ProxyRefundService implements RefundService { ... }
Now, there’s a controller which needs to use this service in order to fullfill it’s duty. I’d like to use autowiring for this:
public RefundgwController(@Autowired @Qualifier(value = "proxyRefundService") RefundService refundService) { this.refundService = refundService; this.mapper = mapper; }
What I’d like to do is, depending on the request IP, decide which instance of RefundService
should be injected as part of the controller’s creation.
One thing to clarify: I’m not a Java expert, I usually code in PHP so perhaps I’m confusing some concepts here… Any idea/comment is welcome.
Thanks!
Mauro Chojrin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.