cancel
Showing results for 
Search instead for 
Did you mean: 

Override Code

sanjaybandhaniya
Elite Collaborator
Elite Collaborator

I want to override setAssignee method of activiti/alfersco workflow.How Can I do that?

I found that TaskEntity.java class is called during set assignee.

Is this proper way to change existing  setAssignee below method of TaskEntity.java?

 public void setAssignee(String assignee, boolean dispatchAssignmentEvent, boolean dispatchUpdateEvent) {}

7 REPLIES 7

afaust
Legendary Innovator
Legendary Innovator

Why do you want to change / override that method in the first place? Generally speaking it is not recommend / actually discouraged to make changes to the core classes / sources just to addess a business requirement. If you need some different behaviour from task assignment, you should implement a proper API facade / action wrapper around the things you need to adapt.

How Can I  Implement  API facade / action wrapper for setAssignee()?

Can you provide some help on that?

I don't want to sound rude, but the facade pattern is a common software design pattern. Any help I would provide would basically just be a TL;DR summary of that pattern at this point...

can you provide some more detail?

abbask01
Star Collaborator
Star Collaborator

why not use taskListener instead? write your business logic on "assign" event then send the variable to the setAssignee

Regards,
Abbas

sanjaybandhaniya
Elite Collaborator
Elite Collaborator

This is not for particular workflow.it is for all workflow.

can you describe how can i achieve?

you can a listener before every task assignment. This thread might help you - Does engine have a hook to install an event listener?

update: use AbstractBpmnParseHandler instead of AbstractBpmnParseListener (with 5.22 engine)

example:

public class AssingmentExample extends AbstractBpmnParseHandler<UserTask>  {

    @Override
    protected void executeParse(BpmnParse arg0, UserTask userTask) {

        // add your custom logic here
        userTask.setAssignee("// your assignee here");
    }

    @Override
    protected Class<? extends BaseElement> getHandledType() {
        // TODO Auto-generated method stub
        return null;
    }

}

Register this with your process engine configuration.

Regards,
Abbas