I would like to know what's the better things between these situations in therme of performance :
@Component
public class A{
public void doSomethingOne(){
ServiceDelegateA serviceA = (ServiceDelegateA) ApplicationContextUtils.getBean("ServiceDelegateA");
serviceA.compute();
}
public void doSomethingTwo(){
ServiceDelegateB serviceB = (ServiceDelegateB) ApplicationContextUtils.getBean("ServiceDelegateB");
serviceB.doAction();
}
}
Or
@Component
public class A{
@Autowired
ServiceDelegateA serviceA;
@Autowired
ServiceDelegateB serviceB;
public void doSomethingOne(){
serviceA.compute();
}
public void doSomethingTwo(){
serviceB.doAction();
}
}
Thank your in advance for help and your advices.