[jboss-user] [jBPM] - JBPM 5, WorkItemHandler as a Spring Bean

Michał Minicki do-not-reply at jboss.com
Thu Dec 23 09:36:10 EST 2010


Michał Minicki [http://community.jboss.org/people/Valgoerad] created the discussion

"JBPM 5, WorkItemHandler as a Spring Bean"

To view the discussion, visit: http://community.jboss.org/message/577346#577346

--------------------------------------------------------------
Hello. Is there a way to register domain specific work item handlers via Spring configuration? There is an example in the manual on how to create such nodes:  https://hudson.jboss.org/hudson/job/jBPM5/lastSuccessfulBuild/artifact/target/jbpm-5.0-SNAPSHOT-docs-build/jbpm-docs/html_single/index.html#d0e1542 https://hudson.jboss.org/hudson/job/jBPM5/lastSuccessfulBuild/artifact/target/jbpm-5.0-SNAPSHOT-docs-build/jbpm-docs/html_single/index.html#d0e1542

But I would like to inject EmailService to NotificationWorkItemHandler via Spring instead of doing this call:


     EmailService service = ServiceRegistry.getInstance().getEmailService();



In order to do so, I need to register this handler as a Spring bean and iject it via application context. My configuration at the moment is as follows:


    <drools:kbase id="knowledgeBase">
        <drools:resources>
            <drools:resource type="BPMN2" source="classpath:jbpm/churn/PodpowiadaczOfert.bpmn" />
            <drools:resource type="BPMN2" source="classpath:jbpm/simple01.bpmn" />
            <drools:resource type="BPMN2" source="classpath:jbpm/simple02.bpmn" />
            <drools:resource type="BPMN2" source="classpath:jbpm/simple03.bpmn" />
            <drools:resource type="BPMN2" source="classpath:jbpm/simple04.jbpmn" />
        </drools:resources>
 
        <drools:configuration>
            <!--<drools:multithread enabled="true" max-threads="5" /> -->
            <!--<drools:consequenceExceptionHandler handler="pl.cyfrowypolsat.workflow.SimpleException" /> -->
        </drools:configuration>
 
    </drools:kbase>
 
    <drools:ksession id="jpaSingleSessionCommandService" type="stateful" kbase="knowledgeBase">
        <drools:configuration>
            <drools:jpa-persistence>
                <drools:transaction-manager ref="transactionManager" />
                <drools:entity-manager-factory ref="entityManagerFactory" />
            </drools:jpa-persistence>
        </drools:configuration>
    </drools:ksession>    <drools:kbase id="knowledgeBase">
        <drools:resources>
            <drools:resource type="BPMN2" source="classpath:jbpm/churn/PodpowiadaczOfert.bpmn" />
            <drools:resource type="BPMN2" source="classpath:jbpm/simple01.bpmn" />
            <drools:resource type="BPMN2" source="classpath:jbpm/simple02.bpmn" />
            <drools:resource type="BPMN2" source="classpath:jbpm/simple03.bpmn" />
            <drools:resource type="BPMN2" source="classpath:jbpm/simple04.jbpmn" />
        </drools:resources>
 
        <drools:configuration>
            <!--<drools:multithread enabled="true" max-threads="5" /> -->
            <!--<drools:consequenceExceptionHandler handler="pl.cyfrowypolsat.workflow.SimpleException" /> -->
        </drools:configuration>
 
    </drools:kbase>
 
    <drools:ksession id="jpaSingleSessionCommandService" type="stateful" kbase="knowledgeBase">
        <drools:configuration>
            <drools:jpa-persistence>
                <drools:transaction-manager ref="transactionManager" />
                <drools:entity-manager-factory ref="entityManagerFactory" />
            </drools:jpa-persistence>
        </drools:configuration>
    </drools:ksession>

    <drools:kbase id="knowledgeBase">
        <drools:resources>
            <drools:resource type="BPMN2" source="classpath:jbpm/simple01.bpmn" />
        </drools:resources>
        <drools:configuration>
            <drools:multithread enabled="true" max-threads="5" />
        </drools:configuration>
    </drools:kbase>

    <drools:ksession id="jpaSingleSessionCommandService" type="stateful" kbase="knowledgeBase">
        <drools:configuration>
            <drools:jpa-persistence>
                <drools:transaction-manager ref="transactionManager" />
                <drools:entity-manager-factory ref="entityManagerFactory" />
            </drools:jpa-persistence>
        </drools:configuration>
    </drools:ksession>



How would I go about registering custom item handlers in the Session's WorkItemManger?


     ksession.getWorkItemManager().registerWorkItemHandler("Notification", new NotificationWorkItemHandler());
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/577346#577346]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20101223/56548d5c/attachment-0001.html 


More information about the jboss-user mailing list