I want to use @Qualifier to dynamically specifying parameters? how to do it ?
@Qualifier("two") 'two' as a parameter ,can be 'one' 'three' or other.
Can i use aop dynamically design 'two'?
means I want to change the name of service with a @Qualifier by parameters.
the parameter from the url 'Token'.
case: url: http://localhost:8080/insert/order, token has a parameter: companyId = one
@RestController
public class ApiWebService {
@Autowired
@Qualifier("two")
//@Qualifier("one")
private BaseService baseService;
@GetMapping("insert/order")
public void test() {
baseService.insertOrder();
}
}
@Service("one")
public class CompanyOneService extends BaseService {
@Override
public void insertOrder() {
System.out.println("conpanyOne");
System.out.println("baseInsertOrder");
}
}
@Service("two")
public class CompanyTwoService extends BaseService {
@Override
public void insertOrder(){
System.out.println("companyTwo");
System.out.println("baseInsertOrder");
}
}
three
four
...
@Service
public class BaseService {
public void insertOrder(){
System.out.println("baseInsertOrder");
}
}
@Conditional, though currently it is not entirely clear what you want to achieve... do you want to change the name of your services with a@Qualifieror do you want to insert a different service depending on a dynamic@Qualifier-> please specify, best with an editone, two, three, four?