If instead you want to switch the class/bean that implements a task then there are different options. If you are using the spring boot starter then the tasks can be matched to their implementations using spring expression language. So you might be able to build a property check into a spring expression. Another way would be to put a service task infront of the task that you want to switch the implementation of and use the DynamicBpmnService to switch the implementation. Or you could do that at startup, perhaps in a PostConstruct.
I'm not sure what you mean about finish after execution. That just sounds like you need an end event. Perhaps you have something like a dynamic subtask in mind. I don't want overcomplicate but you could look at the scenarios on
Your scenario sounds like it is probably simpler but I'm not entirely sure. It might help if you could post what bpmn/ideas you do have.