The common way to implement an Imixs Workflow application is to bind a business object to a workflow model and process it by calling the Imixs Workflow engine.
@EJB WorkflowService wfm; ItemCollection workitem=new ItemCollection(); .... // set model data workitem.replaceItemValue("$modelversion", "1.0.0"); workitem.replaceItemValue("$processid", 100); workitem.replaceItemValue("$activityid", 10); // process workitem workitem=wfm.processWorkItem(workitem);
We call this a ‘model-binding’ because you bind your business object during the development of your application to a workflow model. This means that you typical first design your workflow model and after that you start implementing your application. So as a developer you know the model and can assign a possible workflow activity into your business object. Imixs Workflow provides different methods to compute the possible workflow activities during runtime so you are not forced to hard code the activities in your code.
But in some cases you might need to follow a different strategy. In a scenario where the modeling process takes place very late, you may not be able to bind your business objects to an workflow activity by assigning an activityID. This situation occurs when you first develop your business methods, and then need to link them to workflow activities of a workflow model. This means that the method call itself identifies the activity in the workflow model to be processed by the workflow engine. So each method call is bound to an workflow activity. We call it the ‘method-binding’. To provide an appropriate model, the process designer need to know the different business methods implemented from the workflow application. So he can bind the method-name directly to the workflow activities of a workflow model.
This kind of late binding enforces to work with Interceptor classes. This concept is a common way in Java EE to implement cross-cutting functionality. So the solution here is to intercept the call of a business method and find the corresponding workflow activity in a model. Then you can process the business object.
@EJB WorkflowService wfm; ItemCollection workitem=findWorkitem(); ItemCollection activity=findActivityByMethod(workitem,methodName); .... // set activityid workitem.replaceItemValue("$activityid", activity.getItemValueInteger("numActivityID"); // process workitem workitem=wfm.processWorkItem(workitem);