@ProcessHandler
triggers support for POJO-centric wait-state handlers.
@Component
@ProcessHandler("fulfillment")
class FulfillmentComponent {
@State("request-to-external-webservice")
public void makeRequestToExternalWebService ( Execution execution, @ProcessVariable long customerId){
// ...
}
}
Wait-states may both be synchronous (e.g., the wait-state is entered and exited in the same transaction) or asynchronous (e.g., the wait-state is entered in one transaction, and then passivated to disk until such time as somebody signal
s the execution back into life).
I'm not sure how to handle this. Perhaps we could let the user return a Future<?>
whenever the wait-state should be signal
ed asynchronously?
e.g.,
// enter wait-state and sleep
Future<?> handlerResult = // invoke method
Object result = handlerResult.get()
// signal wait-state to continue processing
a bean annotated with @ProcessHandler signals to the Spring Activiti support that this bean should handle wait states with a given name. As a wait state may be entered, sleep, and then be signaled, we should also support this idiom in our API. Thus, a component might look like this:
@Component
@ProcessHandler("fulfillment")
class FulfillmentComponent {
@State("fulfillment-wait-state")
Future<Customer> sleepWaitStateWhileFutureExecutes( Execution ex, @ProcessVariable long customerId ){
}
}