I would like to maintain the behavior in Bean, according to SOLID principles. So I would like to do something like this:
@Component
public MyDelegate implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
MyBusinessObject bo = (MyBusinessObject) execution.getVariable("bo");
bo.save();
}
}
public class MyBusinessObject {
@Autowired
private MyService service;
private String field1;
private String field2;
// Getters and settters
public void save() {
this.service.save(this);
}
}
However, as the spin probably instantiates the variable by new, spring will understand that it would have to inject the service. I would like to know if there is a way to achieve this result.