I've committed the first mail example to the jBPM 4 codebase. The example shows usage of an inline template in a mail activity. While simple, the example is fully functional and having it working is a milestone. I used the Wiser mock server to verify emails are actually sent.
Other examples will be an external template and task notifications. Here is what I like and don't like about the current implementation. Input appreciated
A) Model and distribution of responsibilites between MailTemplate, MailProducer and MailSession
B) Template and activity syntax
Z) The way dynamic content is produced is not really amenable to templating engines. In the case of freemarker, the whole template content should be available to the engine, and a mechanism should exist to retrieve "compiled" templates by name. Templates take context variables as input and produce a character stream. Only the resulting output should be bound to a MailTemplate object, which would require no further evaluation.
Y) Related to the above point, the output produced by the template should be in a well defined format. Right now there is the "native" format shown in the example and in MailTemplateWireBinding. Rather than brewing our own mail template format, however, we might as well use an existing one, say XMTP.
X) Templates cannot be placed in a separate document yet (Tom, would the import feature help there?)