plexiti / camunda-grails-plugin

Integrates Camunda BPM with the Grails framework.
http://grails.org/plugin/camunda
Apache License 2.0
18 stars 8 forks source link

Use a 'process application' for embedded engines #58

Closed Ofenlord closed 8 years ago

Ofenlord commented 8 years ago

Hi Martin,

i want to use the Process Application Event Listener Plugin, because i will react on userTask events without changing the bpmn file with DelegateCode. I saw that plugin in camunda docs.

https://docs.camunda.org/manual/7.3/guides/user-guide/#process-applications-process-application-event-listeners

is it posible to use that plugin?

Thanks for reply.

Cheers Uwe

martinschimak commented 8 years ago

Are you using a shared or embedded engine? For shared, according to the camunda docs, the plugin should already be preconfigured with a Camunda BPM (tomcat) distribution. You would then just need to register a http://plexiti.github.io/camunda-grails-plugin/guide/configuration.html#process-application-class which looks similar to what is shown in https://docs.camunda.org/manual/7.3/guides/user-guide/#process-applications-process-application-event-listeners but would need to extend a SpringServletProcessApplication!

Ofenlord commented 8 years ago

i use an embedded engine. i tried that what u posted before i wrote u, but "notify" was not called Am 19.11.2015 5:32 nachm. schrieb "Martin Schimak" <notifications@github.com

:

Are you using a shared or embedded engine? For shared, according to the camunda docs, the plugin should already be preconfigured with a Camunda BPM (tomcat) distribution. You would then just need to register a http://plexiti.github.io/camunda-grails-plugin/guide/configuration.html#process-application-class which looks similar to what is shown in https://docs.camunda.org/manual/7.3/guides/user-guide/#process-applications-process-application-event-listeners but would need to extend a SpringServletProcessApplication!

— Reply to this email directly or view it on GitHub https://github.com/plexiti/camunda-grails-plugin/issues/58#issuecomment-158110452 .

martinschimak commented 8 years ago

Hi @Ofenlord - for embedded engines the concept of "process applications" is currently not supported by the grails plugin. I realise I should improve that. However, in the meantime, you can also register a global TaskListener by implementing a BpmnParseListener. Something like:

public class MyBpmnParseListener extends AbstractBpmnParseListener {

    def taskListener = new MyTaskListener()

    @Override
    public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
        def behavior = activity.getActivityBehavior()
        if (behavior instanceof UserTaskActivityBehavior) {
            TaskDefinition taskDefinition = behavior.getTaskDefinition()
            taskDefinition.addTaskListener(TaskListener.EVENTNAME_CREATE, taskListener)
            taskDefinition.addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, taskListener)
            taskDefinition.addTaskListener(TaskListener.EVENTNAME_COMPLETE, taskListener)
            taskDefinition.addTaskListener(TaskListener.EVENTNAME_DELETE, taskListener)
        }
    }

}

You can then register such ParseListeners inside the camunda/engine/configuration section of Config.groovy - compare the documentation of https://docs.camunda.org/javadoc/camunda-bpm-platform/7.3/org/camunda/bpm/engine/impl/cfg/ProcessEngineConfigurationImpl.html#setCustomPostBPMNParseListeners%28java.util.List%29 which translates to something like

camunda {
   engine {
      configuration {
         customPostBPMNParseListeners = [ new MyBpmnParseListener() ]
      }
   }
}

for the grails plugin. Untested, just copy/pasted and typed here. :smile:

Ofenlord commented 8 years ago

ok thanks. i will try it out. ^^ Am 20.11.2015 2:20 nachm. schrieb "Martin Schimak" <notifications@github.com

:

Hi @Ofenlord https://github.com/Ofenlord - for embedded engines the concept of "process applications" is currently not supported by the grails plugin. I realise I should improve that. However, in the meantime, you can also register a global TaskListener by implementing a BpmnParseListener. Something like:

public class MyBpmnParseListener extends AbstractBpmnParseListener {

def taskListener = new MyTaskListener()

@Override
public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
    def behavior = activity.getActivityBehavior()
    if (behavior instanceof UserTaskActivityBehavior) {
        TaskDefinition taskDefinition = behavior.getTaskDefinition()
        taskDefinition.addTaskListener(TaskListener.EVENTNAME_CREATE, taskListener)
        taskDefinition.addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, taskListener)
        taskDefinition.addTaskListener(TaskListener.EVENTNAME_COMPLETE, taskListener)
        taskDefinition.addTaskListener(TaskListener.EVENTNAME_DELETE, taskListener)
    }
}

}

You can then register such ParseListeners inside the camunda/engine/configuration section of Config.groovy - compare the documentation of https://docs.camunda.org/javadoc/camunda-bpm-platform/7.3/org/camunda/bpm/engine/impl/cfg/ProcessEngineConfigurationImpl.html#setCustomPostBPMNParseListeners%28java.util.List%29 which translates to something like

camunda { engine { configuration { customPostBPMNParseListeners = [ new MyBpmnParseListener() ] } } }

for the grails plugin. Untested, just copy/pasted and typed here. [image: :smile:]

— Reply to this email directly or view it on GitHub https://github.com/plexiti/camunda-grails-plugin/issues/58#issuecomment-158401370 .

martinschimak commented 8 years ago

So, basically the 'process applications' for embedded engines are possible now and I also already tested the process application event listeners successfully. Having said that, the changes needed for that are a bit close to a heart operation. So I will need to test a few more things before that will be released within 0.6.0. I very much hope that this will be possible before new year.