Pages

Tuesday, 22 June 2010

jBPM Custom Mail Producer

As stated in the jBPM developers guide (13.4.1. Custom Producers) it is possible to plug in your own custom mail producer.

However, the topic in the developers guide is very brief and just by implementing the interface or extending the MailProducerImpl your code won’t work.

Option one: “Google”…. No luck this time - makes me wondering how many people really use jBPM 4?

Second option: diving into the source code myself and complete the puzzle on my own. After a couple of hours I came to a solutions that does the trick.

As you can see in the source code instantiating a mail provider is done in org.jbpm.jpdl.internal.xml.JpdlParser:

C1

So to enable a process to use a custom mail producer you extend the notification node with a class attribute as shown below:

J1

So far, so good.
Final step: writing your custom producer.
I started simply by creating an empty class which extends from MailProducerImpl :

C2

Running my code however resulted in the following error: Exception in thread "main" java.lang.NullPointerException
at org.jbpm.pvm.internal.email.impl.MailProducerImpl.fillFrom(MailProducerImpl.java:97)…

C3

It learned me that in case of specifying a custom mail producer a mail template is not set.
org.jbpm.jpdl.internal.xml.JpdlParser:

C4

To solve this error adjust the constructor of the mail producer by adding the following code:

C5

At the end this is how my Mail producer looks like (it is still extended from the default mail producer but at this point just implementing the interface would probably do the trick)

Last thing I want to mention is the override of the produce method. In that method I retrieve the current task from the TaskContext. This opens the possibility to use it in the other methods of the class . (Below also a code snippet from the org.jbpm.jpdl.internal.activity.MailListener which is responsible for maintaining the TaskContext).

C6

C7

Now you can spam yourself while testing and fine tuning your code :-)

Wednesday, 9 June 2010

5 things you should know when developing products with ADF11g

I’m trying to get this talk into OOW via Oracle Mix. So If you want to see my talk: 5 things you should know when developing products with ADF11g you should take a minute or 2 and vote for it.

https://mix.oracle.com/oow10/proposals