The TaskDefinitionBean by design is intended to follow the command pattern. You are supposed to tell it what to do with parameters and it will do exactly that. Within the TaskDefinitionBean, you can use the Strategy pattern to invoke

1. Another Bean(Service)

2. Hit a database to get a job definition or params to fetch data from a URL

3. Do something specific and repetetive.

The TaskDefinitionBean is supposed to be stateless and should be assigned any job that it is supposed to perform. Just the invocation will be controlled from controlled from here

@PostMapping(path="/taskdef", consumes = "application/json", produces="application/json")

public void scheduleATask(@RequestBody TaskDefinition taskDefinition) {

taskDefinitionBean.setTaskDefinition(taskDefinition);

--

--