[jbpm-commits] JBoss JBPM SVN: r4573 - in jbpm4/trunk: .settings and 30 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Apr 16 18:39:51 EDT 2009


Author: alex.guizar at jboss.com
Date: 2009-04-16 18:39:50 -0400 (Thu, 16 Apr 2009)
New Revision: 4573

Added:
   jbpm4/trunk/modules/pvm/.settings/org.eclipse.jdt.core.prefs
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailContext.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/TemplateMailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/AddressResolver.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/IdentityAddressResolver.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/PatternDescriptor.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl/
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl/AddressFilterTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailTemplateWireTest.java
   jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch10-Emails.xml
Removed:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailContext.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/TemplateMailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/AddressResolver.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/IdentityAddressResolver.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/api/
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/model/
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl/
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl/AddressFilterTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/spring/
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/
Modified:
   jbpm4/trunk/.project
   jbpm4/trunk/.settings/org.maven.ide.eclipse.prefs
   jbpm4/trunk/hudson/hudson-home/jobs/jBPM4-Container-Matrix/config.xml
   jbpm4/trunk/modules/api/.project
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/identity/User.java
   jbpm4/trunk/modules/integration/
   jbpm4/trunk/modules/pvm/.project
   jbpm4/trunk/modules/pvm/pom.xml
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/spi/IdentitySession.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java
   jbpm4/trunk/modules/pvm/src/test/resources/jbpm.wire.bindings.xml
   jbpm4/trunk/modules/userguide/src/main/docbook/en/master.xml
   jbpm4/trunk/pom.xml
Log:
merge r4409:4572 from email branch

Modified: jbpm4/trunk/.project
===================================================================
--- jbpm4/trunk/.project	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/.project	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,12 +1,17 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>jbpm4</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-	</buildSpec>
-	<natures>
-		<nature>org.maven.ide.eclipse.maven2Nature</nature>
-	</natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>jbpm4</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Modified: jbpm4/trunk/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- jbpm4/trunk/.settings/org.maven.ide.eclipse.prefs	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/.settings/org.maven.ide.eclipse.prefs	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,8 +1,9 @@
-#Wed Mar 25 11:07:34 CET 2009
-activeProfiles=
-eclipse.preferences.version=1
-fullBuildGoals=
-includeModules=false
-resolveWorkspaceProjects=true
-resourceFilterGoals=
-version=1
+#Thu Apr 16 16:21:44 CDT 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1

Modified: jbpm4/trunk/hudson/hudson-home/jobs/jBPM4-Container-Matrix/config.xml
===================================================================
--- jbpm4/trunk/hudson/hudson-home/jobs/jBPM4-Container-Matrix/config.xml	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/hudson/hudson-home/jobs/jBPM4-Container-Matrix/config.xml	2009-04-16 22:39:50 UTC (rev 4573)
@@ -30,13 +30,11 @@
       <values>
         <string>jboss422</string>
         <string>jboss423</string>
-        <string>jboss500</string>
       </values>
     </axis>
     <axis>
       <name>DATABASE</name>
       <values>
-        <string>hsqldb</string>
         <string>mysql</string>
         <string>oracle</string>
       </values>

Modified: jbpm4/trunk/modules/api/.project
===================================================================
--- jbpm4/trunk/modules/api/.project	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/api/.project	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,18 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>api</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>org.maven.ide.eclipse.maven2Nature</nature>
-	</natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>jbpm-api</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/identity/User.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/identity/User.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/identity/User.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -31,4 +31,6 @@
   
   String getGivenName();
   String getFamilyName();
+
+  String getEmailAddress();
 }


Property changes on: jbpm4/trunk/modules/integration
___________________________________________________________________
Name: svn:ignore
   + target


Modified: jbpm4/trunk/modules/pvm/.project
===================================================================
--- jbpm4/trunk/modules/pvm/.project	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/.project	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,18 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>pvm</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>org.maven.ide.eclipse.maven2Nature</nature>
-	</natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>jbpm-pvm</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Copied: jbpm4/trunk/modules/pvm/.settings/org.eclipse.jdt.core.prefs (from rev 4572, jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.core.prefs)
===================================================================
--- jbpm4/trunk/modules/pvm/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/.settings/org.eclipse.jdt.core.prefs	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,5 @@
+#Tue Apr 14 00:52:21 CDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5

Modified: jbpm4/trunk/modules/pvm/pom.xml
===================================================================
--- jbpm4/trunk/modules/pvm/pom.xml	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/pom.xml	2009-04-16 22:39:50 UTC (rev 4573)
@@ -33,6 +33,13 @@
     <table.prefix>JBPM_</table.prefix>
     <!--test.resources.directory>${project.build.directory}/test-resources</test.resources.directory-->
   </properties>
+  <repositories>
+  	<repository>
+  		<id>Snapshot</id>
+  		<name>JBoss Snapshot</name>
+  		<url>http://snapshots.jboss.org/maven2/</url>
+  	</repository>
+  </repositories>
 
   <!-- Dependencies -->
   <dependencies>
@@ -50,6 +57,10 @@
     </dependency>
 
     <dependency>
+      <groupId>commons-email</groupId>
+      <artifactId>commons-email</artifactId>
+    </dependency>
+    <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
     </dependency>

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email)

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl)

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,102 +0,0 @@
-package org.jbpm.pvm.internal.email.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.regex.Pattern;
-
-import javax.mail.internet.InternetAddress;
-
-/**
- * Allows filtering of to/cc/bcc recipient lists based on regular expressions for include and
- * exclude patterns.
- * 
- * @author Brad Davis
- */
-public class AddressFilter {
-
-  /**
-   * patterns of addresses to be included. all addresses are included when omitted.
-   */
-  private List<Pattern> includePatterns;
-  /**
-   * patterns of addresses to be excluded. no addresses are excluded when omitted.
-   */
-  private List<Pattern> excludePatterns;
-
-  public Collection<InternetAddress> filter(final Collection<InternetAddress> addresses) {
-    Collection<InternetAddress> filteredAddresses = new HashSet<InternetAddress>();
-    if (addresses != null) {
-      // Loop over for addresses to decide what to keep.
-      for (InternetAddress address : addresses) {
-        if (includeAddress(address) && !excludeAddress(address)) {
-          filteredAddresses.add(address);
-        }
-      }
-    }
-    return filteredAddresses;
-  }
-
-  /**
-   * Determines whether the given address is included, based on regular expressions.
-   * 
-   * @param address email address to match against regex
-   * @return <code>false</code> if include patterns are present and the address does not match any
-   *         pattern, <code>true</code> otherwise
-   */
-  protected boolean includeAddress(InternetAddress address) {
-    if (includePatterns == null || includePatterns.isEmpty()) return true;
-    for (Pattern pattern : includePatterns) {
-      if (pattern.matcher(address.toString()).matches()) return true;
-    }
-    return false;
-  }
-
-  /**
-   * Determines whether the given address is excluded, based on regular expressions.
-   * 
-   * @param address email address to match against regex
-   * @return <code>true</code> if exclude patterns are present and the address matches a pattern,
-   *         <code>false</code> otherwise
-   */
-  protected boolean excludeAddress(InternetAddress address) {
-    if (excludePatterns == null) return false;
-    for (Pattern pattern : excludePatterns) {
-      if (pattern.matcher(address.toString()).matches()) return true;
-    }
-    return false;
-  }
-
-  /**
-   * Gets the patterns of addresses to be included. All addresses are included when omitted.
-   */
-  public List<Pattern> getIncludePatterns() {
-    return includePatterns;
-  }
-
-  public void addIncludePattern(Pattern includePattern) {
-    if (includePatterns == null) includePatterns = new ArrayList<Pattern>();
-    includePatterns.add(includePattern);
-  }
-
-  protected void setIncludePatterns(List<Pattern> includePatterns) {
-    this.includePatterns = includePatterns;
-  }
-
-  /**
-   * Gets the patterns of addresses to be excluded. No addresses are excluded when omitted.
-   */
-  public List<Pattern> getExcludePatterns() {
-    return excludePatterns;
-  }
-
-  public void addExcludePattern(Pattern excludePattern) {
-    if (excludePatterns == null) excludePatterns = new ArrayList<Pattern>();
-    excludePatterns.add(excludePattern);
-  }
-
-  protected void setExcludePatterns(List<Pattern> excludePatterns) {
-    this.excludePatterns = excludePatterns;
-  }
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,102 @@
+package org.jbpm.pvm.internal.email.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import javax.mail.internet.InternetAddress;
+
+/**
+ * Allows filtering of to/cc/bcc recipient lists based on regular expressions for include and
+ * exclude patterns.
+ * 
+ * @author Brad Davis
+ */
+public class AddressFilter {
+
+  /**
+   * patterns of addresses to be included. all addresses are included when omitted.
+   */
+  private List<Pattern> includePatterns;
+  /**
+   * patterns of addresses to be excluded. no addresses are excluded when omitted.
+   */
+  private List<Pattern> excludePatterns;
+
+  public Collection<InternetAddress> filter(final Collection<InternetAddress> addresses) {
+    Collection<InternetAddress> filteredAddresses = new HashSet<InternetAddress>();
+    if (addresses != null) {
+      // Loop over for addresses to decide what to keep.
+      for (InternetAddress address : addresses) {
+        if (includeAddress(address) && !excludeAddress(address)) {
+          filteredAddresses.add(address);
+        }
+      }
+    }
+    return filteredAddresses;
+  }
+
+  /**
+   * Determines whether the given address is included, based on regular expressions.
+   * 
+   * @param address email address to match against regex
+   * @return <code>false</code> if include patterns are present and the address does not match any
+   *         pattern, <code>true</code> otherwise
+   */
+  protected boolean includeAddress(InternetAddress address) {
+    if (includePatterns == null || includePatterns.isEmpty()) return true;
+    for (Pattern pattern : includePatterns) {
+      if (pattern.matcher(address.toString()).matches()) return true;
+    }
+    return false;
+  }
+
+  /**
+   * Determines whether the given address is excluded, based on regular expressions.
+   * 
+   * @param address email address to match against regex
+   * @return <code>true</code> if exclude patterns are present and the address matches a pattern,
+   *         <code>false</code> otherwise
+   */
+  protected boolean excludeAddress(InternetAddress address) {
+    if (excludePatterns == null) return false;
+    for (Pattern pattern : excludePatterns) {
+      if (pattern.matcher(address.toString()).matches()) return true;
+    }
+    return false;
+  }
+
+  /**
+   * Gets the patterns of addresses to be included. All addresses are included when omitted.
+   */
+  public List<Pattern> getIncludePatterns() {
+    return includePatterns;
+  }
+
+  public void addIncludePattern(Pattern includePattern) {
+    if (includePatterns == null) includePatterns = new ArrayList<Pattern>();
+    includePatterns.add(includePattern);
+  }
+
+  protected void setIncludePatterns(List<Pattern> includePatterns) {
+    this.includePatterns = includePatterns;
+  }
+
+  /**
+   * Gets the patterns of addresses to be excluded. No addresses are excluded when omitted.
+   */
+  public List<Pattern> getExcludePatterns() {
+    return excludePatterns;
+  }
+
+  public void addExcludePattern(Pattern excludePattern) {
+    if (excludePatterns == null) excludePatterns = new ArrayList<Pattern>();
+    excludePatterns.add(excludePattern);
+  }
+
+  protected void setExcludePatterns(List<Pattern> excludePatterns) {
+    this.excludePatterns = excludePatterns;
+  }
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.email.impl;
-
-import java.net.URL;
-
-/**
- * @author Alejandro Guizar
- */
-public class AttachmentTemplate {
-
-	private String name;
-	private String description;
-	private String url;
-	private String resource;
-	private String file;
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getDescription() {
-		return description;
-	}
-
-	public void setDescription(String description) {
-		this.description = description;
-	}
-
-	public String getUrl() {
-		return url;
-	}
-
-	public void setUrl(String url) {
-		this.url = url;
-	}
-
-	public String getResource() {
-		return resource;
-	}
-
-	public void setResource(String resource) {
-		this.resource = resource;
-	}
-
-	public String getFile() {
-		return file;
-	}
-
-	public void setFile(String file) {
-		this.file = file;
-	}
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.email.impl;
+
+import java.net.URL;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class AttachmentTemplate {
+
+	private String name;
+	private String description;
+	private String url;
+	private String resource;
+	private String file;
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	public String getUrl() {
+		return url;
+	}
+
+	public void setUrl(String url) {
+		this.url = url;
+	}
+
+	public String getResource() {
+		return resource;
+	}
+
+	public void setResource(String resource) {
+		this.resource = resource;
+	}
+
+	public String getFile() {
+		return file;
+	}
+
+	public void setFile(String file) {
+		this.file = file;
+	}
+
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.email.impl;
-
-import org.jbpm.identity.User;
-import org.jbpm.pvm.internal.email.spi.RecipientNameBuilder;
-
-/**
- * @author Alejandro Guizar
- */
-public class GivenSpaceFamilyNameBuilder implements RecipientNameBuilder {
-
-	public String buildName(User user) {
-		String givenName = user.getGivenName();
-		String familyName = user.getFamilyName();
-
-		return givenName != null ? familyName != null ? givenName + ' ' + familyName : givenName
-				: familyName;
-	}
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.email.impl;
+
+import org.jbpm.api.identity.User;
+import org.jbpm.pvm.internal.email.spi.RecipientNameBuilder;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class GivenSpaceFamilyNameBuilder implements RecipientNameBuilder {
+
+	public String buildName(User user) {
+		String givenName = user.getGivenName();
+		String familyName = user.getFamilyName();
+
+		return givenName != null ? familyName != null ? givenName + ' ' + familyName : givenName
+				: familyName;
+	}
+
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,242 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.email.impl;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.commons.mail.Email;
-import org.apache.commons.mail.EmailAttachment;
-import org.apache.commons.mail.EmailException;
-import org.apache.commons.mail.HtmlEmail;
-import org.apache.commons.mail.MultiPartEmail;
-import org.apache.commons.mail.SimpleEmail;
-import org.jbpm.JbpmException;
-import org.jbpm.env.Environment;
-import org.jbpm.identity.Group;
-import org.jbpm.identity.User;
-import org.jbpm.model.OpenExecution;
-import org.jbpm.pvm.internal.email.spi.MailProducer;
-import org.jbpm.pvm.internal.email.spi.RecipientNameBuilder;
-import org.jbpm.pvm.internal.identity.spi.IdentitySession;
-import org.jbpm.pvm.internal.script.ScriptManager;
-
-/**
- * Default mail producer.
- * 
- * @author Alejandro Guizar
- */
-public class MailProducerImpl implements MailProducer {
-
-  private MailTemplate template;
-
-  public MailTemplate getTemplate() {
-    return template;
-  }
-
-  public void setTemplate(MailTemplate template) {
-    this.template = template;
-  }
-
-  public Collection<Email> produce(OpenExecution execution) {
-    try {
-      Email email = instantiateEmail(template);
-      fillRecipients(template, execution, email);
-      fillSubject(execution, email);
-      fillBody(execution, email);
-      return Collections.singleton(email);
-    }
-    catch (EmailException e) {
-      throw new JbpmException("could not produce email", e);
-    }
-  }
-
-  protected Email instantiateEmail(MailTemplate template) {
-    return template.getHtml() != null ? new HtmlEmail() : template.getAttachmentTemplates()
-        .isEmpty() ? new MultiPartEmail() : new SimpleEmail();
-  }
-
-  protected void fillRecipients(MailTemplate template, OpenExecution execution, Email email)
-      throws EmailException {
-    Environment environment = Environment.getCurrent();
-    IdentitySession identitySession = environment.get(IdentitySession.class);
-    RecipientNameBuilder recipientNameBuilder = environment.get(RecipientNameBuilder.class);
-
-    // to
-    RecipientTemplate to = template.getTo();
-    if (to != null) {
-      for (String address : evaluateRecipients(to.getAddresses(), execution)) {
-        email.addTo(address);
-      }
-      for (String actorId : evaluateRecipients(to.getActors(), execution)) {
-        Collection<User> users = resolveUsers(identitySession, actorId);
-        for (User user : users) {
-          email.addTo(user.getEmailAddress(), recipientNameBuilder.buildName(user));
-        }
-      }
-    }
-
-    // cc
-    RecipientTemplate cc = template.getCc();
-    if (cc != null) {
-      for (String address : evaluateRecipients(cc.getAddresses(), execution)) {
-        email.addCc(address);
-      }
-      for (String actorId : evaluateRecipients(cc.getActors(), execution)) {
-        Collection<User> users = resolveUsers(identitySession, actorId);
-        for (User user : users) {
-          email.addCc(user.getEmailAddress(), recipientNameBuilder.buildName(user));
-        }
-      }
-    }
-
-    // bcc
-    RecipientTemplate bcc = template.getBcc();
-    if (bcc != null) {
-      for (String address : evaluateRecipients(bcc.getAddresses(), execution)) {
-        email.addBcc(address);
-      }
-      for (String actorId : evaluateRecipients(bcc.getActors(), execution)) {
-        Collection<User> users = resolveUsers(identitySession, actorId);
-        for (User user : users) {
-          email.addBcc(user.getEmailAddress(), recipientNameBuilder.buildName(user));
-        }
-      }
-    }
-  }
-
-  private String evaluateExpression(String expression, OpenExecution execution) {
-    ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
-    return scriptManager.evaluateExpression(expression, execution, template.getLanguage())
-        .toString();
-  }
-
-  private String[] evaluateRecipients(String recipients, OpenExecution execution) {
-    return evaluateExpression(recipients, execution).split("[,|\\s]+");
-  }
-
-  private static Collection<User> resolveUsers(IdentitySession identitySession, String actorId) {
-    // first, try to resolve actorId as user
-    User user = identitySession.findUserById(actorId);
-    if (user != null) return Collections.singleton(user);
-
-    // next, try to resolve as group
-    Group group = identitySession.findGroupById(actorId);
-    if (group != null) return identitySession.findUsersByGroup(actorId);
-
-    // give up
-    return Collections.emptySet();
-  }
-
-  protected void fillSubject(OpenExecution execution, Email email) {
-    email.setSubject(evaluateExpression(template.getSubject(), execution));
-  }
-
-  protected void fillBody(OpenExecution execution, Email email) throws EmailException {
-    if (template.getHtml() == null) {
-      email.setMsg(evaluateExpression(template.getText(), execution));
-    }
-    else {
-      HtmlEmail htmlEmail = (HtmlEmail) email;
-      htmlEmail.setHtmlMsg(evaluateExpression(template.getHtml(), execution));
-      htmlEmail.setTextMsg(evaluateExpression(template.getText(), execution));
-    }
-  }
-
-  protected void addAttachments(OpenExecution execution, Email email) throws EmailException {
-    List<AttachmentTemplate> attachmentTemplates = template.getAttachmentTemplates();
-    if (attachmentTemplates.isEmpty()) return;
-
-    MultiPartEmail multiPartEmail = (MultiPartEmail) email;
-    for (AttachmentTemplate attachmentTemplate : attachmentTemplates) {
-      EmailAttachment attachment = new EmailAttachment();
-      attachment.setDisposition(EmailAttachment.ATTACHMENT);
-
-      // name
-      String name = attachmentTemplate.getName();
-      if (name != null) attachment.setName(evaluateExpression(name, execution));
-
-      // description
-      String description = attachmentTemplate.getDescription();
-      if (description != null)
-        attachment.setDescription(evaluateExpression(description, execution));
-
-      // file
-      String file = attachmentTemplate.getFile();
-      if (file != null) {
-        File targetFile = new File(evaluateExpression(file, execution));
-        if (!targetFile.isFile()) {
-          throw new EmailException("could not fetch attachment from " + targetFile);
-        }
-        attachment.setPath(targetFile.getPath());
-        // extract attachment name from file
-        if (name == null) attachment.setName(targetFile.getName());
-      }
-      else {
-        URL targetUrl;
-        // url
-        String url = attachmentTemplate.getUrl();
-        if (url != null) {
-          try {
-            targetUrl = new URL(evaluateExpression(url, execution));
-          }
-          catch (MalformedURLException e) {
-            throw new EmailException("could not fetch attachment from " + url, e);
-          }
-        }
-        // resource
-        else {
-          String resource = attachmentTemplate.getResource();
-          targetUrl =
-              Environment.getCurrent().getClassLoader().getResource(
-                  evaluateExpression(resource, execution));
-          if (targetUrl == null) {
-            throw new EmailException("could not fetch attachment from " + resource);
-          }
-        }
-        attachment.setURL(targetUrl);
-        // extract attachment name from url
-        if (name == null) {
-          String resourceName = extractResourceName(targetUrl);
-          attachment.setName(resourceName);
-        }
-      }
-
-      multiPartEmail.attach(attachment);
-    }
-  }
-
-  private static String extractResourceName(URL url) {
-    String path = url.getPath();
-    if (path == null || path.length() == 0) return null;
-
-    // skip trailing slash
-    int sepIndex = path.lastIndexOf('/', path.length() - 1);
-    if (sepIndex == -1) return null;
-
-    return path.substring(sepIndex);
-  }
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,242 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.email.impl;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.mail.Email;
+import org.apache.commons.mail.EmailAttachment;
+import org.apache.commons.mail.EmailException;
+import org.apache.commons.mail.HtmlEmail;
+import org.apache.commons.mail.MultiPartEmail;
+import org.apache.commons.mail.SimpleEmail;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.env.Environment;
+import org.jbpm.api.identity.Group;
+import org.jbpm.api.identity.User;
+import org.jbpm.api.model.OpenExecution;
+import org.jbpm.pvm.internal.email.spi.MailProducer;
+import org.jbpm.pvm.internal.email.spi.RecipientNameBuilder;
+import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+/**
+ * Default mail producer.
+ * 
+ * @author Alejandro Guizar
+ */
+public class MailProducerImpl implements MailProducer {
+
+  private MailTemplate template;
+
+  public MailTemplate getTemplate() {
+    return template;
+  }
+
+  public void setTemplate(MailTemplate template) {
+    this.template = template;
+  }
+
+  public Collection<Email> produce(OpenExecution execution) {
+    try {
+      Email email = instantiateEmail(template);
+      fillRecipients(template, execution, email);
+      fillSubject(execution, email);
+      fillBody(execution, email);
+      return Collections.singleton(email);
+    }
+    catch (EmailException e) {
+      throw new JbpmException("could not produce email", e);
+    }
+  }
+
+  protected Email instantiateEmail(MailTemplate template) {
+    return template.getHtml() != null ? new HtmlEmail() : template.getAttachmentTemplates()
+        .isEmpty() ? new MultiPartEmail() : new SimpleEmail();
+  }
+
+  protected void fillRecipients(MailTemplate template, OpenExecution execution, Email email)
+      throws EmailException {
+    Environment environment = Environment.getCurrent();
+    IdentitySession identitySession = environment.get(IdentitySession.class);
+    RecipientNameBuilder recipientNameBuilder = environment.get(RecipientNameBuilder.class);
+
+    // to
+    RecipientTemplate to = template.getTo();
+    if (to != null) {
+      for (String address : evaluateRecipients(to.getAddresses(), execution)) {
+        email.addTo(address);
+      }
+      for (String actorId : evaluateRecipients(to.getActors(), execution)) {
+        Collection<User> users = resolveUsers(identitySession, actorId);
+        for (User user : users) {
+          email.addTo(user.getEmailAddress(), recipientNameBuilder.buildName(user));
+        }
+      }
+    }
+
+    // cc
+    RecipientTemplate cc = template.getCc();
+    if (cc != null) {
+      for (String address : evaluateRecipients(cc.getAddresses(), execution)) {
+        email.addCc(address);
+      }
+      for (String actorId : evaluateRecipients(cc.getActors(), execution)) {
+        Collection<User> users = resolveUsers(identitySession, actorId);
+        for (User user : users) {
+          email.addCc(user.getEmailAddress(), recipientNameBuilder.buildName(user));
+        }
+      }
+    }
+
+    // bcc
+    RecipientTemplate bcc = template.getBcc();
+    if (bcc != null) {
+      for (String address : evaluateRecipients(bcc.getAddresses(), execution)) {
+        email.addBcc(address);
+      }
+      for (String actorId : evaluateRecipients(bcc.getActors(), execution)) {
+        Collection<User> users = resolveUsers(identitySession, actorId);
+        for (User user : users) {
+          email.addBcc(user.getEmailAddress(), recipientNameBuilder.buildName(user));
+        }
+      }
+    }
+  }
+
+  private String evaluateExpression(String expression, OpenExecution execution) {
+    ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
+    return scriptManager.evaluateExpression(expression, execution, template.getLanguage())
+        .toString();
+  }
+
+  private String[] evaluateRecipients(String recipients, OpenExecution execution) {
+    return evaluateExpression(recipients, execution).split("[,|\\s]+");
+  }
+
+  private static Collection<User> resolveUsers(IdentitySession identitySession, String actorId) {
+    // first, try to resolve actorId as user
+    User user = identitySession.findUserById(actorId);
+    if (user != null) return Collections.singleton(user);
+
+    // next, try to resolve as group
+    Group group = identitySession.findGroupById(actorId);
+    if (group != null) return identitySession.findUsersByGroup(actorId);
+
+    // give up
+    return Collections.emptySet();
+  }
+
+  protected void fillSubject(OpenExecution execution, Email email) {
+    email.setSubject(evaluateExpression(template.getSubject(), execution));
+  }
+
+  protected void fillBody(OpenExecution execution, Email email) throws EmailException {
+    if (template.getHtml() == null) {
+      email.setMsg(evaluateExpression(template.getText(), execution));
+    }
+    else {
+      HtmlEmail htmlEmail = (HtmlEmail) email;
+      htmlEmail.setHtmlMsg(evaluateExpression(template.getHtml(), execution));
+      htmlEmail.setTextMsg(evaluateExpression(template.getText(), execution));
+    }
+  }
+
+  protected void addAttachments(OpenExecution execution, Email email) throws EmailException {
+    List<AttachmentTemplate> attachmentTemplates = template.getAttachmentTemplates();
+    if (attachmentTemplates.isEmpty()) return;
+
+    MultiPartEmail multiPartEmail = (MultiPartEmail) email;
+    for (AttachmentTemplate attachmentTemplate : attachmentTemplates) {
+      EmailAttachment attachment = new EmailAttachment();
+      attachment.setDisposition(EmailAttachment.ATTACHMENT);
+
+      // name
+      String name = attachmentTemplate.getName();
+      if (name != null) attachment.setName(evaluateExpression(name, execution));
+
+      // description
+      String description = attachmentTemplate.getDescription();
+      if (description != null)
+        attachment.setDescription(evaluateExpression(description, execution));
+
+      // file
+      String file = attachmentTemplate.getFile();
+      if (file != null) {
+        File targetFile = new File(evaluateExpression(file, execution));
+        if (!targetFile.isFile()) {
+          throw new EmailException("could not fetch attachment from " + targetFile);
+        }
+        attachment.setPath(targetFile.getPath());
+        // extract attachment name from file
+        if (name == null) attachment.setName(targetFile.getName());
+      }
+      else {
+        URL targetUrl;
+        // url
+        String url = attachmentTemplate.getUrl();
+        if (url != null) {
+          try {
+            targetUrl = new URL(evaluateExpression(url, execution));
+          }
+          catch (MalformedURLException e) {
+            throw new EmailException("could not fetch attachment from " + url, e);
+          }
+        }
+        // resource
+        else {
+          String resource = attachmentTemplate.getResource();
+          targetUrl =
+              Environment.getCurrent().getClassLoader().getResource(
+                  evaluateExpression(resource, execution));
+          if (targetUrl == null) {
+            throw new EmailException("could not fetch attachment from " + resource);
+          }
+        }
+        attachment.setURL(targetUrl);
+        // extract attachment name from url
+        if (name == null) {
+          String resourceName = extractResourceName(targetUrl);
+          attachment.setName(resourceName);
+        }
+      }
+
+      multiPartEmail.attach(attachment);
+    }
+  }
+
+  private static String extractResourceName(URL url) {
+    String path = url.getPath();
+    if (path == null || path.length() == 0) return null;
+
+    // skip trailing slash
+    int sepIndex = path.lastIndexOf('/', path.length() - 1);
+    if (sepIndex == -1) return null;
+
+    return path.substring(sepIndex);
+  }
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,46 +0,0 @@
-package org.jbpm.pvm.internal.email.impl;
-
-import java.util.Properties;
-
-import javax.mail.Authenticator;
-import javax.mail.Session;
-
-/**
- * Settings for establishing a session with a mail server.
- * 
- * @author Brad Davis
- */
-public class MailServer {
-
-  private AddressFilter addressFilter;
-  private Properties sessionProperties;
-  private Authenticator authenticator;
-
-  public AddressFilter getAddressFilter() {
-    return addressFilter;
-  }
-
-  protected void setAddressFilter(AddressFilter filter) {
-    this.addressFilter = filter;
-  }
-
-  public Properties getSessionProperties() {
-    return sessionProperties;
-  }
-
-  protected void setSessionProperties(Properties sessionProperties) {
-    this.sessionProperties = sessionProperties;
-  }
-
-  public Authenticator getAuthenticator() {
-    return authenticator;
-  }
-
-  protected void setAuthenticator(Authenticator authenticator) {
-    this.authenticator = authenticator;
-  }
-
-  public Session createMailSession() {
-    return Session.getDefaultInstance(sessionProperties, authenticator);
-  }
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,46 @@
+package org.jbpm.pvm.internal.email.impl;
+
+import java.util.Properties;
+
+import javax.mail.Authenticator;
+import javax.mail.Session;
+
+/**
+ * Settings for establishing a session with a mail server.
+ * 
+ * @author Brad Davis
+ */
+public class MailServer {
+
+  private AddressFilter addressFilter;
+  private Properties sessionProperties;
+  private Authenticator authenticator;
+
+  public AddressFilter getAddressFilter() {
+    return addressFilter;
+  }
+
+  protected void setAddressFilter(AddressFilter filter) {
+    this.addressFilter = filter;
+  }
+
+  public Properties getSessionProperties() {
+    return sessionProperties;
+  }
+
+  protected void setSessionProperties(Properties sessionProperties) {
+    this.sessionProperties = sessionProperties;
+  }
+
+  public Authenticator getAuthenticator() {
+    return authenticator;
+  }
+
+  protected void setAuthenticator(Authenticator authenticator) {
+    this.authenticator = authenticator;
+  }
+
+  public Session createMailSession() {
+    return Session.getDefaultInstance(sessionProperties, authenticator);
+  }
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,71 +0,0 @@
-package org.jbpm.pvm.internal.email.impl;
-
-import java.util.Collection;
-import java.util.List;
-
-import javax.mail.Session;
-import javax.mail.internet.InternetAddress;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.mail.Email;
-import org.apache.commons.mail.EmailException;
-import org.jbpm.pvm.internal.email.spi.MailSession;
-
-public class MailSessionImpl implements MailSession {
-
-  private List<MailServer> mailServers;
-
-  private static final Log log = LogFactory.getLog(MailSessionImpl.class);
-
-  public void send(Collection<Email> emails) {
-    // Emails need to have the sessions populated.
-    for (Email email : emails) {
-      Collection<InternetAddress> to = email.getToAddresses();
-      Collection<InternetAddress> cc = email.getCcAddresses();
-      Collection<InternetAddress> bcc = email.getBccAddresses();
-
-      for (MailServer mailServer : mailServers) {
-        AddressFilter addressFilter = mailServer.getAddressFilter();
-        Session mailSession = mailServer.createMailSession();
-        email.setMailSession(mailSession);
-
-        // Need to apply filter.
-        try {
-          if(addressFilter!=null) {
-	          Collection<InternetAddress> toFiltered = addressFilter.filter(to);
-	          Collection<InternetAddress> ccFiltered = addressFilter.filter(cc);
-	          Collection<InternetAddress> bccFiltered = addressFilter.filter(bcc);
-	
-	          // Set the email with the new filtered addresses.
-	          email.setTo(toFiltered);
-	          email.setCc(ccFiltered);
-	          email.setBcc(bccFiltered);
-	
-	          // If there is someone to send it to, then send it.
-	          if (!(toFiltered.isEmpty() && ccFiltered.isEmpty() && bccFiltered.isEmpty())) {
-	            email.send();
-	          }
-          }
-          else {
-        	  //If no filter is set, then accept all.
-        	  email.send();
-          }
-        }
-        catch (EmailException e) {
-          log.error("An exception occurred while sending email.", e);
-          // TODO: Does anything else need to occur here?
-        }
-      }
-    }
-  }
-
-  public List<MailServer> getMailServers() {
-    return mailServers;
-  }
-
-  protected void setMailServers(List<MailServer> mailServers) {
-    this.mailServers = mailServers;
-  }
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,71 @@
+package org.jbpm.pvm.internal.email.impl;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.mail.Session;
+import javax.mail.internet.InternetAddress;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.mail.Email;
+import org.apache.commons.mail.EmailException;
+import org.jbpm.pvm.internal.email.spi.MailSession;
+
+public class MailSessionImpl implements MailSession {
+
+  private List<MailServer> mailServers;
+
+  private static final Log log = LogFactory.getLog(MailSessionImpl.class);
+
+  public void send(Collection<Email> emails) {
+    // Emails need to have the sessions populated.
+    for (Email email : emails) {
+      Collection<InternetAddress> to = email.getToAddresses();
+      Collection<InternetAddress> cc = email.getCcAddresses();
+      Collection<InternetAddress> bcc = email.getBccAddresses();
+
+      for (MailServer mailServer : mailServers) {
+        AddressFilter addressFilter = mailServer.getAddressFilter();
+        Session mailSession = mailServer.createMailSession();
+        email.setMailSession(mailSession);
+
+        // Need to apply filter.
+        try {
+          if(addressFilter!=null) {
+	          Collection<InternetAddress> toFiltered = addressFilter.filter(to);
+	          Collection<InternetAddress> ccFiltered = addressFilter.filter(cc);
+	          Collection<InternetAddress> bccFiltered = addressFilter.filter(bcc);
+	
+	          // Set the email with the new filtered addresses.
+	          email.setTo(toFiltered);
+	          email.setCc(ccFiltered);
+	          email.setBcc(bccFiltered);
+	
+	          // If there is someone to send it to, then send it.
+	          if (!(toFiltered.isEmpty() && ccFiltered.isEmpty() && bccFiltered.isEmpty())) {
+	            email.send();
+	          }
+          }
+          else {
+        	  //If no filter is set, then accept all.
+        	  email.send();
+          }
+        }
+        catch (EmailException e) {
+          log.error("An exception occurred while sending email.", e);
+          // TODO: Does anything else need to occur here?
+        }
+      }
+    }
+  }
+
+  public List<MailServer> getMailServers() {
+    return mailServers;
+  }
+
+  protected void setMailServers(List<MailServer> mailServers) {
+    this.mailServers = mailServers;
+  }
+
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,131 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.email.impl;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.mail.Message.RecipientType;
-
-/**
- * Template for electronic mail, complete with recipients, subject, content and attachments.
- * 
- * @author Alejandro Guizar
- */
-public class MailTemplate {
-
-  private String name;
-  private String language;
-  private Map<RecipientType, RecipientTemplate> recipientTemplates = new HashMap<RecipientType, RecipientTemplate>();
-  private String subject;
-  private String text;
-  private String html;
-  private List<AttachmentTemplate> attachmentTemplates = new ArrayList<AttachmentTemplate>();
-
-  /**
-   * Name of this template, useful for referencing it from mail activities.
-   */
-  public String getName() {
-    return name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  /**
-   * Templating engine meant to produce dynamic content.
-   */
-  public String getLanguage() {
-    return language;
-  }
-
-  public void setLanguage(String language) {
-    this.language = language;
-  }
-
-  public RecipientTemplate getRecipientTemplate(RecipientType recipientType) {
-    return recipientTemplates.get(recipientType);
-  }
-
-  public void setRecipientTemplate(RecipientType recipientType, RecipientTemplate recipientTemplate) {
-    recipientTemplates.put(recipientType, recipientTemplate);
-  }
-
-  public RecipientTemplate getTo() {
-    return getRecipientTemplate(RecipientType.TO);
-  }
-
-  public void setTo(RecipientTemplate to) {
-    setRecipientTemplate(RecipientType.TO, to);
-  }
-
-  public RecipientTemplate getCc() {
-    return getRecipientTemplate(RecipientType.CC);
-  }
-
-  public void setCc(RecipientTemplate cc) {
-    setRecipientTemplate(RecipientType.CC, cc);
-  }
-
-  public RecipientTemplate getBcc() {
-    return getRecipientTemplate(RecipientType.BCC);
-  }
-
-  public void setBcc(RecipientTemplate bcc) {
-    setRecipientTemplate(RecipientType.BCC, bcc);
-  }
-
-  public String getSubject() {
-    return subject;
-  }
-
-  public void setSubject(String subject) {
-    this.subject = subject;
-  }
-
-  public String getText() {
-    return text;
-  }
-
-  public void setText(String text) {
-    this.text = text;
-  }
-
-  public String getHtml() {
-    return html;
-  }
-
-  public void setHtml(String html) {
-    this.html = html;
-  }
-
-  public List<AttachmentTemplate> getAttachmentTemplates() {
-    return attachmentTemplates;
-  }
-
-  public void addAttachmentTemplate(AttachmentTemplate attachmentTemplate) {
-    attachmentTemplates.add(attachmentTemplate);
-  }
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.email.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.mail.Message.RecipientType;
+
+/**
+ * Template for electronic mail, complete with recipients, subject, content and attachments.
+ * 
+ * @author Alejandro Guizar
+ */
+public class MailTemplate {
+
+  private String name;
+  private String language;
+  private Map<RecipientType, RecipientTemplate> recipientTemplates = new HashMap<RecipientType, RecipientTemplate>();
+  private String subject;
+  private String text;
+  private String html;
+  private List<AttachmentTemplate> attachmentTemplates = new ArrayList<AttachmentTemplate>();
+
+  /**
+   * Name of this template, useful for referencing it from mail activities.
+   */
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  /**
+   * Templating engine meant to produce dynamic content.
+   */
+  public String getLanguage() {
+    return language;
+  }
+
+  public void setLanguage(String language) {
+    this.language = language;
+  }
+
+  public RecipientTemplate getRecipientTemplate(RecipientType recipientType) {
+    return recipientTemplates.get(recipientType);
+  }
+
+  public void setRecipientTemplate(RecipientType recipientType, RecipientTemplate recipientTemplate) {
+    recipientTemplates.put(recipientType, recipientTemplate);
+  }
+
+  public RecipientTemplate getTo() {
+    return getRecipientTemplate(RecipientType.TO);
+  }
+
+  public void setTo(RecipientTemplate to) {
+    setRecipientTemplate(RecipientType.TO, to);
+  }
+
+  public RecipientTemplate getCc() {
+    return getRecipientTemplate(RecipientType.CC);
+  }
+
+  public void setCc(RecipientTemplate cc) {
+    setRecipientTemplate(RecipientType.CC, cc);
+  }
+
+  public RecipientTemplate getBcc() {
+    return getRecipientTemplate(RecipientType.BCC);
+  }
+
+  public void setBcc(RecipientTemplate bcc) {
+    setRecipientTemplate(RecipientType.BCC, bcc);
+  }
+
+  public String getSubject() {
+    return subject;
+  }
+
+  public void setSubject(String subject) {
+    this.subject = subject;
+  }
+
+  public String getText() {
+    return text;
+  }
+
+  public void setText(String text) {
+    this.text = text;
+  }
+
+  public String getHtml() {
+    return html;
+  }
+
+  public void setHtml(String html) {
+    this.html = html;
+  }
+
+  public List<AttachmentTemplate> getAttachmentTemplates() {
+    return attachmentTemplates;
+  }
+
+  public void addAttachmentTemplate(AttachmentTemplate attachmentTemplate) {
+    attachmentTemplates.add(attachmentTemplate);
+  }
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.email.impl;
-
-/**
- * Template for email recipients, either addresses or actors.
- * 
- * @author Alejandro Guizar
- */
-public class RecipientTemplate {
-
-	private String addresses;
-	private String actors;
-
-	public String getAddresses() {
-		return addresses;
-	}
-
-	public void setAddresses(String addresses) {
-		this.addresses = addresses;
-	}
-
-	public String getActors() {
-		return actors;
-	}
-
-	public void setActors(String actors) {
-		this.actors = actors;
-	}
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.email.impl;
+
+/**
+ * Template for email recipients, either addresses or actors.
+ * 
+ * @author Alejandro Guizar
+ */
+public class RecipientTemplate {
+
+	private String addresses;
+	private String actors;
+
+	public String getAddresses() {
+		return addresses;
+	}
+
+	public void setAddresses(String addresses) {
+		this.addresses = addresses;
+	}
+
+	public String getActors() {
+		return actors;
+	}
+
+	public void setActors(String actors) {
+		this.actors = actors;
+	}
+
+}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer)

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailContext.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailContext.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailContext.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,46 +0,0 @@
-package org.jbpm.pvm.internal.email.producer;
-
-import java.util.Collection;
-
-import org.jbpm.identity.Group;
-import org.jbpm.identity.User;
-
-public class MailContext {
-
-	private Collection<User> actors;
-	private Collection<Group> groups;
-	private Collection<String> toAddresses;
-	private Collection<String> ccAddresses;
-	private Collection<String> bccAddresses;
-	public Collection<User> getActors() {
-		return actors;
-	}
-	public void setActors(Collection<User> actors) {
-		this.actors = actors;
-	}
-	public Collection<Group> getGroups() {
-		return groups;
-	}
-	public void setGroups(Collection<Group> groups) {
-		this.groups = groups;
-	}
-	public Collection<String> getToAddresses() {
-		return toAddresses;
-	}
-	public void setToAddresses(Collection<String> toAddresses) {
-		this.toAddresses = toAddresses;
-	}
-	public Collection<String> getCcAddresses() {
-		return ccAddresses;
-	}
-	public void setCcAddresses(Collection<String> ccAddresses) {
-		this.ccAddresses = ccAddresses;
-	}
-	public Collection<String> getBccAddresses() {
-		return bccAddresses;
-	}
-	public void setBccAddresses(Collection<String> bccAddresses) {
-		this.bccAddresses = bccAddresses;
-	}
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailContext.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailContext.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailContext.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailContext.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,46 @@
+package org.jbpm.pvm.internal.email.producer;
+
+import java.util.Collection;
+
+import org.jbpm.api.identity.Group;
+import org.jbpm.api.identity.User;
+
+public class MailContext {
+
+	private Collection<User> actors;
+	private Collection<Group> groups;
+	private Collection<String> toAddresses;
+	private Collection<String> ccAddresses;
+	private Collection<String> bccAddresses;
+	public Collection<User> getActors() {
+		return actors;
+	}
+	public void setActors(Collection<User> actors) {
+		this.actors = actors;
+	}
+	public Collection<Group> getGroups() {
+		return groups;
+	}
+	public void setGroups(Collection<Group> groups) {
+		this.groups = groups;
+	}
+	public Collection<String> getToAddresses() {
+		return toAddresses;
+	}
+	public void setToAddresses(Collection<String> toAddresses) {
+		this.toAddresses = toAddresses;
+	}
+	public Collection<String> getCcAddresses() {
+		return ccAddresses;
+	}
+	public void setCcAddresses(Collection<String> ccAddresses) {
+		this.ccAddresses = ccAddresses;
+	}
+	public Collection<String> getBccAddresses() {
+		return bccAddresses;
+	}
+	public void setBccAddresses(Collection<String> bccAddresses) {
+		this.bccAddresses = bccAddresses;
+	}
+
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailProducer.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,12 +0,0 @@
-package org.jbpm.pvm.internal.email.producer;
-
-import java.util.Collection;
-
-import org.apache.commons.mail.Email;
-import org.jbpm.Execution;
-
-public interface MailProducer {
-
-	public Collection<Email> produce(final Execution exe, final MailContext mailContext) throws Exception;
-
-}
\ No newline at end of file

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailProducer.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailProducer.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailProducer.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/MailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,12 @@
+package org.jbpm.pvm.internal.email.producer;
+
+import java.util.Collection;
+
+import org.apache.commons.mail.Email;
+import org.jbpm.api.Execution;
+
+public interface MailProducer {
+
+	public Collection<Email> produce(final Execution exe, final MailContext mailContext) throws Exception;
+
+}
\ No newline at end of file

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl)

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,149 +0,0 @@
-package org.jbpm.pvm.internal.email.producer.impl;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.mail.Email;
-import org.apache.commons.mail.HtmlEmail;
-import org.apache.commons.mail.MultiPartEmail;
-import org.jbpm.Execution;
-import org.jbpm.env.Environment;
-import org.jbpm.pvm.internal.email.producer.MailContext;
-import org.jbpm.pvm.internal.script.ScriptManager;
-
-/**
- * Create an HTML email message using JBPM script manager.  Provide HTML to embed with image.
- * Body becomes the text alternative, subject, and html are rendered using the script manager.
- * Images need to be hosted to be embedded within the message.
- * 
- * @author Brad Davis
- *
- */
-public class HtmlScriptMailProducer extends ScriptMailProducer {
-
-	private static final Pattern imgSrcPattern = Pattern.compile("<img[^>]*(src=['\"](\\S+)['\"])[^>]*",Pattern.CASE_INSENSITIVE);
-	private static final Log log = LogFactory.getLog(HtmlScriptMailProducer.class);
-	
-	protected String html; 
-	
-	public Collection<Email> produce(Execution exe, MailContext mailContext) throws Exception {
-
-		if(log.isTraceEnabled())
-		{
-			log.trace("Starting: "+(new Date()));
-		}
-		ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
-		
-		//Apply the scripting language to the process.
-		this.text = (String)scriptManager.evaluateScript(this.text, exe, language);
-		this.subject = (String)scriptManager.evaluateScript(this.subject, exe, language);
-		this.html = (String)scriptManager.evaluate(this.html, exe, language);
-		this.resolveUrlAttachments(scriptManager, exe);
-		
-		//Create an HTML message.
-		HtmlEmail email = new HtmlEmail();
-		//Populate recipients.
-		this.populateAddresses(mailContext, email);
-		this.populateUrlAttachments((MultiPartEmail)email);
-		
-		//Set the regular body [non-html] and subject.
-		email.setTextMsg(this.text);
-		email.setSubject(this.subject);
-		
-		//Keep track of the CIDs that have replaced SRCs to reduce
-		//calls to replace.  Should improve efficiency.
-		Set<String> cidSet = new HashSet<String>();
-		//Create a matcher based on our regex.
-		Matcher imgMatcher = imgSrcPattern.matcher(html);
-		
-		//While there are matches, loop through them.
-		while(imgMatcher.find())
-		{
-			//Embed the SRC image, and get a reference to the embedded CID.
-			String replace = embedImage(email,imgMatcher.group(2));
-			if(replace==null)
-			{
-				log.warn("The image source is not provided.  Skipping: "+imgMatcher.group());
-				continue;
-			}
-			//If this CID has not replaced a URL in the past, replace it now.
-			if(cidSet.add(replace))
-			{
-				//Replace the original SRC URL with the CID SRC URL.
-				this.html=this.html.replace(imgMatcher.group(2), replace);
-			}
-			else
-			{
-				if(log.isDebugEnabled())
-				{
-					log.debug("Skipped replace as the image has been handled before: "+imgMatcher.group(2));
-				}
-			}
-				
-		}
-		
-		if(log.isDebugEnabled())
-		{
-			log.debug("Embedded HTML: "+this.html);
-		}
-		try {
-			//Set the embedded HTML to the Email Message.
-			email.setHtmlMsg(this.html);
-		}
-		catch(Exception e)
-		{
-			//TODO: what do we do here?
-		}
-		if(log.isTraceEnabled())
-		{
-			log.trace("Complete: "+(new Date()));
-		}
-		
-		//Return the rendered message.
-		Collection<Email> collection = new HashSet<Email>();
-		collection.add(email);
-		return collection;
-	}
-	
-
-
-	public String embedImage(HtmlEmail email, String imageSrc)
-	{
-		if(imageSrc==null||imageSrc.length()==0)
-		{
-			return null;
-		}
-		if(imageSrc.startsWith("cid:"))
-		{
-			return imageSrc;
-		}
-		
-		//If the image hasn't been embedded yet, embed it.
-		String src = imageSrc;
-		String hashName = Integer.toString(src.hashCode());
-		String cid = null; 
-		try{
-			cid = email.embed(src, hashName);
-		}
-		catch(Exception e)
-		{
-			log.error("Error fetching image.",e);
-			return imageSrc;
-		}
-		//Return the embedded name to replace the src.
-		return "cid:"+cid;
-		
-	}
-
-
-	public void setHtml(String html) {
-		this.html = html;
-	}
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,149 @@
+package org.jbpm.pvm.internal.email.producer.impl;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.mail.Email;
+import org.apache.commons.mail.HtmlEmail;
+import org.apache.commons.mail.MultiPartEmail;
+import org.jbpm.api.Execution;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.email.producer.MailContext;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+/**
+ * Create an HTML email message using JBPM script manager.  Provide HTML to embed with image.
+ * Body becomes the text alternative, subject, and html are rendered using the script manager.
+ * Images need to be hosted to be embedded within the message.
+ * 
+ * @author Brad Davis
+ *
+ */
+public class HtmlScriptMailProducer extends ScriptMailProducer {
+
+	private static final Pattern imgSrcPattern = Pattern.compile("<img[^>]*(src=['\"](\\S+)['\"])[^>]*",Pattern.CASE_INSENSITIVE);
+	private static final Log log = LogFactory.getLog(HtmlScriptMailProducer.class);
+	
+	protected String html; 
+	
+	public Collection<Email> produce(Execution exe, MailContext mailContext) throws Exception {
+
+		if(log.isTraceEnabled())
+		{
+			log.trace("Starting: "+(new Date()));
+		}
+		ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
+		
+		//Apply the scripting language to the process.
+		this.text = (String)scriptManager.evaluateScript(this.text, exe, language);
+		this.subject = (String)scriptManager.evaluateScript(this.subject, exe, language);
+		this.html = (String)scriptManager.evaluate(this.html, exe, language);
+		this.resolveUrlAttachments(scriptManager, exe);
+		
+		//Create an HTML message.
+		HtmlEmail email = new HtmlEmail();
+		//Populate recipients.
+		this.populateAddresses(mailContext, email);
+		this.populateUrlAttachments((MultiPartEmail)email);
+		
+		//Set the regular body [non-html] and subject.
+		email.setTextMsg(this.text);
+		email.setSubject(this.subject);
+		
+		//Keep track of the CIDs that have replaced SRCs to reduce
+		//calls to replace.  Should improve efficiency.
+		Set<String> cidSet = new HashSet<String>();
+		//Create a matcher based on our regex.
+		Matcher imgMatcher = imgSrcPattern.matcher(html);
+		
+		//While there are matches, loop through them.
+		while(imgMatcher.find())
+		{
+			//Embed the SRC image, and get a reference to the embedded CID.
+			String replace = embedImage(email,imgMatcher.group(2));
+			if(replace==null)
+			{
+				log.warn("The image source is not provided.  Skipping: "+imgMatcher.group());
+				continue;
+			}
+			//If this CID has not replaced a URL in the past, replace it now.
+			if(cidSet.add(replace))
+			{
+				//Replace the original SRC URL with the CID SRC URL.
+				this.html=this.html.replace(imgMatcher.group(2), replace);
+			}
+			else
+			{
+				if(log.isDebugEnabled())
+				{
+					log.debug("Skipped replace as the image has been handled before: "+imgMatcher.group(2));
+				}
+			}
+				
+		}
+		
+		if(log.isDebugEnabled())
+		{
+			log.debug("Embedded HTML: "+this.html);
+		}
+		try {
+			//Set the embedded HTML to the Email Message.
+			email.setHtmlMsg(this.html);
+		}
+		catch(Exception e)
+		{
+			//TODO: what do we do here?
+		}
+		if(log.isTraceEnabled())
+		{
+			log.trace("Complete: "+(new Date()));
+		}
+		
+		//Return the rendered message.
+		Collection<Email> collection = new HashSet<Email>();
+		collection.add(email);
+		return collection;
+	}
+	
+
+
+	public String embedImage(HtmlEmail email, String imageSrc)
+	{
+		if(imageSrc==null||imageSrc.length()==0)
+		{
+			return null;
+		}
+		if(imageSrc.startsWith("cid:"))
+		{
+			return imageSrc;
+		}
+		
+		//If the image hasn't been embedded yet, embed it.
+		String src = imageSrc;
+		String hashName = Integer.toString(src.hashCode());
+		String cid = null; 
+		try{
+			cid = email.embed(src, hashName);
+		}
+		catch(Exception e)
+		{
+			log.error("Error fetching image.",e);
+			return imageSrc;
+		}
+		//Return the embedded name to replace the src.
+		return "cid:"+cid;
+		
+	}
+
+
+	public void setHtml(String html) {
+		this.html = html;
+	}
+
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,55 +0,0 @@
-package org.jbpm.pvm.internal.email.producer.impl;
-
-import java.util.Collection;
-
-import org.apache.commons.mail.Email;
-import org.jbpm.Execution;
-import org.jbpm.env.Environment;
-import org.jbpm.pvm.internal.email.producer.MailContext;
-import org.jbpm.pvm.internal.script.ScriptManager;
-
-/**
- * Created to produce simple text emails using the JBPM script manager.
- * Provide the script language to transform the subject and body.
- * @author Brad Davis
- *
- */
-public class ScriptMailProducer extends SimpleMailProducer {
-	
-	protected String language;
-	
-	@Override
-	public Collection<Email> produce(final Execution exe, final MailContext mailContext)
-			throws Exception {
-
-		ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
-		
-		//Here, you just need to populate the subject and body of the message
-		//as evaluated by the JBPM script manager.
-		this.text = (String)scriptManager.evaluateScript(this.text, exe, language);
-		this.subject = (String)scriptManager.evaluateScript(this.subject, exe, language);
-		this.resolveUrlAttachments(scriptManager,exe);
-		
-		//Populate and produce email based on SimpleMailProducer logic now that fields
-		//have been resolved using the JBPM script manager.
-		return super.produce(exe, mailContext);
-	}
-
-	public void setLanguage(String language) {
-		this.language = language;
-	}
-	
-	protected void resolveUrlAttachments(final ScriptManager scriptManager, final Execution exe) { 
-		//Resolve attachments from script to URL.
-		if(urlAttachments!=null&&!urlAttachments.isEmpty())
-		{
-			for(String urlKey : urlAttachments.keySet())
-			{
-				String url = urlAttachments.get(urlKey);
-				url = (String)scriptManager.evaluateScript(url, exe, language);
-				urlAttachments.put(urlKey, url);
-			}
-		}
-	}
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,55 @@
+package org.jbpm.pvm.internal.email.producer.impl;
+
+import java.util.Collection;
+
+import org.apache.commons.mail.Email;
+import org.jbpm.api.Execution;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.email.producer.MailContext;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+/**
+ * Created to produce simple text emails using the JBPM script manager.
+ * Provide the script language to transform the subject and body.
+ * @author Brad Davis
+ *
+ */
+public class ScriptMailProducer extends SimpleMailProducer {
+	
+	protected String language;
+	
+	@Override
+	public Collection<Email> produce(final Execution exe, final MailContext mailContext)
+			throws Exception {
+
+		ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
+		
+		//Here, you just need to populate the subject and body of the message
+		//as evaluated by the JBPM script manager.
+		this.text = (String)scriptManager.evaluateScript(this.text, exe, language);
+		this.subject = (String)scriptManager.evaluateScript(this.subject, exe, language);
+		this.resolveUrlAttachments(scriptManager,exe);
+		
+		//Populate and produce email based on SimpleMailProducer logic now that fields
+		//have been resolved using the JBPM script manager.
+		return super.produce(exe, mailContext);
+	}
+
+	public void setLanguage(String language) {
+		this.language = language;
+	}
+	
+	protected void resolveUrlAttachments(final ScriptManager scriptManager, final Execution exe) { 
+		//Resolve attachments from script to URL.
+		if(urlAttachments!=null&&!urlAttachments.isEmpty())
+		{
+			for(String urlKey : urlAttachments.keySet())
+			{
+				String url = urlAttachments.get(urlKey);
+				url = (String)scriptManager.evaluateScript(url, exe, language);
+				urlAttachments.put(urlKey, url);
+			}
+		}
+	}
+
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,167 +0,0 @@
-package org.jbpm.pvm.internal.email.producer.impl;
-
-import java.net.URL;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-
-import javax.mail.internet.InternetAddress;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.mail.Email;
-import org.apache.commons.mail.EmailException;
-import org.apache.commons.mail.MultiPartEmail;
-import org.apache.commons.mail.SimpleEmail;
-import org.jbpm.Execution;
-import org.jbpm.env.Environment;
-import org.jbpm.identity.Group;
-import org.jbpm.identity.User;
-import org.jbpm.pvm.internal.email.producer.MailContext;
-import org.jbpm.pvm.internal.email.producer.MailProducer;
-import org.jbpm.pvm.internal.email.resolver.AddressResolver;
-
-/**
- * Creates a simple email, with subject, body, and recipients.
- * @author Brad Davis
- *
- */
-public class SimpleMailProducer implements MailProducer {
-
-	private final static Log log = LogFactory.getLog(SimpleMailProducer.class);
-	
-	protected String text;
-	protected String subject;
-	protected Map<String,String> urlAttachments;
-	
-	public Collection<Email> produce(final Execution exe, final MailContext mailContext) throws Exception {
-		//Create a simple email with the body set.
-		Email email;
-		
-		//If there are attachments, must be multipart message.
-		if(urlAttachments!=null&&!urlAttachments.isEmpty())
-		{
-			email = new MultiPartEmail();
-		}
-		else
-		{
-			//Otherwise, it is simple.
-			email = new SimpleEmail();
-		}
-		
-		//Resolve and populate to, cc, bcc addresses.
-		populateAddresses(mailContext, email);
-		
-		//If there are attachments, add them to the email.
-		if(urlAttachments!=null&&!urlAttachments.isEmpty())
-		{
-			populateUrlAttachments((MultiPartEmail)email);
-		}
-		
-		//Set subject and message.
-		email.setSubject(subject);
-		email.setMsg(text);
-		
-		Collection<Email> emails = new HashSet<Email>();
-		emails.add(email);
-		
-		return emails;
-	}
-	
-	protected void populateAddresses(MailContext mailContext, Email email) throws EmailException
-	{
-		//Add the addresses.
-		if(mailContext.getToAddresses()!=null)
-		{
-			for(String a : mailContext.getToAddresses())
-			{
-				email.addTo(a);
-			}
-		}
-		if(mailContext.getCcAddresses()!=null)
-		{
-			for(String a : mailContext.getCcAddresses())
-			{
-				email.addCc(a);
-			}
-		}
-		if(mailContext.getBccAddresses()!=null)
-		{
-			for(String a : mailContext.getBccAddresses())
-			{
-				email.addBcc(a);
-			}
-		}
-		
-		//Get address resolver.
-		AddressResolver resolver = Environment.getFromCurrent(AddressResolver.class);;
-		
-		//Resolve actors and groups.
-		if(mailContext.getActors()!=null)
-		{
-			for(User user : mailContext.getActors())
-			{
-				InternetAddress address = resolver.resolveUserAddress(user);
-				email.addTo(address.getAddress(), this.constructName(user));
-			}
-		}
-		if(mailContext.getGroups()!=null)
-		{
-			for(Group group : mailContext.getGroups())
-			{
-				Collection<InternetAddress> addresses = resolver.resolveGroupAddresses(group);
-				for(InternetAddress address : addresses)
-				{
-					email.addTo(address.getAddress());
-				}
-			}
-		}
-	}
-	
-	protected String constructName(User user)
-	{
-		String name = null;
-		if(user.getGivenName()!=null&&user.getGivenName().length()>0)
-		{
-			name = user.getGivenName();
-		}
-		if(user.getFamilyName()!=null&&user.getFamilyName().length()>0)
-		{
-			if(name==null)
-			{
-				name = user.getFamilyName();
-			}
-			else
-			{
-				name += " "+user.getFamilyName();
-			}
-		}
-		
-		return name;
-	}
-	
-	protected void populateUrlAttachments(MultiPartEmail email) throws Exception
-	{
-		if(urlAttachments!=null&&!urlAttachments.isEmpty())
-		{
-			for(String urlKey : urlAttachments.keySet())
-			{
-				URL url = new URL(urlAttachments.get(urlKey));
-				((MultiPartEmail)email).attach(url,urlKey,urlKey);
-			}
-		}
-	}
-
-	
-	public void setText(String text) {
-		this.text = text;
-	}
-
-	public void setSubject(String subject) {
-		this.subject = subject;
-	}
-
-	public void setUrlAttachments(Map<String, String> urlAttachments) {
-		this.urlAttachments = urlAttachments;
-	}
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,167 @@
+package org.jbpm.pvm.internal.email.producer.impl;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+
+import javax.mail.internet.InternetAddress;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.mail.Email;
+import org.apache.commons.mail.EmailException;
+import org.apache.commons.mail.MultiPartEmail;
+import org.apache.commons.mail.SimpleEmail;
+import org.jbpm.api.Execution;
+import org.jbpm.api.env.Environment;
+import org.jbpm.api.identity.Group;
+import org.jbpm.api.identity.User;
+import org.jbpm.pvm.internal.email.producer.MailContext;
+import org.jbpm.pvm.internal.email.producer.MailProducer;
+import org.jbpm.pvm.internal.email.resolver.AddressResolver;
+
+/**
+ * Creates a simple email, with subject, body, and recipients.
+ * @author Brad Davis
+ *
+ */
+public class SimpleMailProducer implements MailProducer {
+
+	private final static Log log = LogFactory.getLog(SimpleMailProducer.class);
+	
+	protected String text;
+	protected String subject;
+	protected Map<String,String> urlAttachments;
+	
+	public Collection<Email> produce(final Execution exe, final MailContext mailContext) throws Exception {
+		//Create a simple email with the body set.
+		Email email;
+		
+		//If there are attachments, must be multipart message.
+		if(urlAttachments!=null&&!urlAttachments.isEmpty())
+		{
+			email = new MultiPartEmail();
+		}
+		else
+		{
+			//Otherwise, it is simple.
+			email = new SimpleEmail();
+		}
+		
+		//Resolve and populate to, cc, bcc addresses.
+		populateAddresses(mailContext, email);
+		
+		//If there are attachments, add them to the email.
+		if(urlAttachments!=null&&!urlAttachments.isEmpty())
+		{
+			populateUrlAttachments((MultiPartEmail)email);
+		}
+		
+		//Set subject and message.
+		email.setSubject(subject);
+		email.setMsg(text);
+		
+		Collection<Email> emails = new HashSet<Email>();
+		emails.add(email);
+		
+		return emails;
+	}
+	
+	protected void populateAddresses(MailContext mailContext, Email email) throws EmailException
+	{
+		//Add the addresses.
+		if(mailContext.getToAddresses()!=null)
+		{
+			for(String a : mailContext.getToAddresses())
+			{
+				email.addTo(a);
+			}
+		}
+		if(mailContext.getCcAddresses()!=null)
+		{
+			for(String a : mailContext.getCcAddresses())
+			{
+				email.addCc(a);
+			}
+		}
+		if(mailContext.getBccAddresses()!=null)
+		{
+			for(String a : mailContext.getBccAddresses())
+			{
+				email.addBcc(a);
+			}
+		}
+		
+		//Get address resolver.
+		AddressResolver resolver = Environment.getFromCurrent(AddressResolver.class);;
+		
+		//Resolve actors and groups.
+		if(mailContext.getActors()!=null)
+		{
+			for(User user : mailContext.getActors())
+			{
+				InternetAddress address = resolver.resolveUserAddress(user);
+				email.addTo(address.getAddress(), this.constructName(user));
+			}
+		}
+		if(mailContext.getGroups()!=null)
+		{
+			for(Group group : mailContext.getGroups())
+			{
+				Collection<InternetAddress> addresses = resolver.resolveGroupAddresses(group);
+				for(InternetAddress address : addresses)
+				{
+					email.addTo(address.getAddress());
+				}
+			}
+		}
+	}
+	
+	protected String constructName(User user)
+	{
+		String name = null;
+		if(user.getGivenName()!=null&&user.getGivenName().length()>0)
+		{
+			name = user.getGivenName();
+		}
+		if(user.getFamilyName()!=null&&user.getFamilyName().length()>0)
+		{
+			if(name==null)
+			{
+				name = user.getFamilyName();
+			}
+			else
+			{
+				name += " "+user.getFamilyName();
+			}
+		}
+		
+		return name;
+	}
+	
+	protected void populateUrlAttachments(MultiPartEmail email) throws Exception
+	{
+		if(urlAttachments!=null&&!urlAttachments.isEmpty())
+		{
+			for(String urlKey : urlAttachments.keySet())
+			{
+				URL url = new URL(urlAttachments.get(urlKey));
+				((MultiPartEmail)email).attach(url,urlKey,urlKey);
+			}
+		}
+	}
+
+	
+	public void setText(String text) {
+		this.text = text;
+	}
+
+	public void setSubject(String subject) {
+		this.subject = subject;
+	}
+
+	public void setUrlAttachments(Map<String, String> urlAttachments) {
+		this.urlAttachments = urlAttachments;
+	}
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/TemplateMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/TemplateMailProducer.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/TemplateMailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,25 +0,0 @@
-package org.jbpm.pvm.internal.email.producer.impl;
-
-import java.util.Collection;
-
-import org.apache.commons.mail.Email;
-import org.jbpm.Execution;
-import org.jbpm.pvm.internal.email.producer.MailContext;
-import org.jbpm.pvm.internal.email.producer.MailProducer;
-
-public class TemplateMailProducer implements MailProducer {
-
-	protected String templateName;
-	
-	public Collection<Email> produce(Execution exe, MailContext mailContext) throws Exception {
-		//Find out which producer is being used in the template.
-		MailProducer templatedProducer = readTemplate(templateName);
-		
-		return templatedProducer.produce(exe, mailContext);
-	}
-
-	protected MailProducer readTemplate(String templateName)
-	{
-		return null; //Actually do the reading and create the appropriate producer.
-	}
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/TemplateMailProducer.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/TemplateMailProducer.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/TemplateMailProducer.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/TemplateMailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,25 @@
+package org.jbpm.pvm.internal.email.producer.impl;
+
+import java.util.Collection;
+
+import org.apache.commons.mail.Email;
+import org.jbpm.api.Execution;
+import org.jbpm.pvm.internal.email.producer.MailContext;
+import org.jbpm.pvm.internal.email.producer.MailProducer;
+
+public class TemplateMailProducer implements MailProducer {
+
+	protected String templateName;
+	
+	public Collection<Email> produce(Execution exe, MailContext mailContext) throws Exception {
+		//Find out which producer is being used in the template.
+		MailProducer templatedProducer = readTemplate(templateName);
+		
+		return templatedProducer.produce(exe, mailContext);
+	}
+
+	protected MailProducer readTemplate(String templateName)
+	{
+		return null; //Actually do the reading and create the appropriate producer.
+	}
+}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver)

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/AddressResolver.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/AddressResolver.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/AddressResolver.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,15 +0,0 @@
-package org.jbpm.pvm.internal.email.resolver;
-
-import java.util.Collection;
-
-import javax.mail.internet.InternetAddress;
-
-import org.jbpm.identity.Group;
-import org.jbpm.identity.User;
-
-public interface AddressResolver {
-
-	public InternetAddress resolveUserAddress(User user);
-	public Collection<InternetAddress> resolveGroupAddresses(Group group);
-	
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/AddressResolver.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/AddressResolver.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/AddressResolver.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/AddressResolver.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,15 @@
+package org.jbpm.pvm.internal.email.resolver;
+
+import java.util.Collection;
+
+import javax.mail.internet.InternetAddress;
+
+import org.jbpm.api.identity.Group;
+import org.jbpm.api.identity.User;
+
+public interface AddressResolver {
+
+	public InternetAddress resolveUserAddress(User user);
+	public Collection<InternetAddress> resolveGroupAddresses(Group group);
+	
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/IdentityAddressResolver.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/IdentityAddressResolver.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/IdentityAddressResolver.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,31 +0,0 @@
-package org.jbpm.pvm.internal.email.resolver;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import javax.mail.internet.InternetAddress;
-
-import org.jbpm.identity.Group;
-import org.jbpm.identity.User;
-
-public class IdentityAddressResolver implements AddressResolver {
-
-	public Collection<InternetAddress> resolveGroupAddresses(Group group) {
-		Collection<InternetAddress> addresses = new HashSet<InternetAddress>();
-		
-		org.jbpm.pvm.internal.identity.spi.IdentitySession session = null;
-		//TODO: Optimize this, or it could be a N+1 select.
-		Collection<User> users = session.findUsersByGroup(group.getId());
-		for(User u : users)
-		{
-			addresses.add(resolveUserAddress(u));
-		}
-		return addresses;
-	}
-
-	public InternetAddress resolveUserAddress(User user) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/IdentityAddressResolver.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/IdentityAddressResolver.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/IdentityAddressResolver.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/resolver/IdentityAddressResolver.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,31 @@
+package org.jbpm.pvm.internal.email.resolver;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.mail.internet.InternetAddress;
+
+import org.jbpm.api.identity.Group;
+import org.jbpm.api.identity.User;
+
+public class IdentityAddressResolver implements AddressResolver {
+
+	public Collection<InternetAddress> resolveGroupAddresses(Group group) {
+		Collection<InternetAddress> addresses = new HashSet<InternetAddress>();
+		
+		org.jbpm.pvm.internal.identity.spi.IdentitySession session = null;
+		//TODO: Optimize this, or it could be a N+1 select.
+		Collection<User> users = session.findUsersByGroup(group.getId());
+		for(User u : users)
+		{
+			addresses.add(resolveUserAddress(u));
+		}
+		return addresses;
+	}
+
+	public InternetAddress resolveUserAddress(User user) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi)

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.email.spi;
-
-import java.util.Collection;
-
-import org.apache.commons.mail.Email;
-import org.jbpm.model.OpenExecution;
-
-/**
- * Pluggable control object for creating emails from templates.
- * 
- * @author Brad Davis
- * @author Alejandro Guizar
- */
-public interface MailProducer {
-
-  Collection<Email> produce(OpenExecution execution);
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.email.spi;
+
+import java.util.Collection;
+
+import org.apache.commons.mail.Email;
+import org.jbpm.api.model.OpenExecution;
+
+/**
+ * Pluggable control object for creating emails from templates.
+ * 
+ * @author Brad Davis
+ * @author Alejandro Guizar
+ */
+public interface MailProducer {
+
+  Collection<Email> produce(OpenExecution execution);
+
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,16 +0,0 @@
-package org.jbpm.pvm.internal.email.spi;
-
-import java.util.Collection;
-
-import org.apache.commons.mail.Email;
-
-/**
- * Pluggable control object for sending emails.
- * 
- * @author Brad Davis
- */
-public interface MailSession {
-
-  void send(Collection<Email> emails);
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,16 @@
+package org.jbpm.pvm.internal.email.spi;
+
+import java.util.Collection;
+
+import org.apache.commons.mail.Email;
+
+/**
+ * Pluggable control object for sending emails.
+ * 
+ * @author Brad Davis
+ */
+public interface MailSession {
+
+  void send(Collection<Email> emails);
+
+}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.email.spi;
-
-import org.jbpm.identity.User;
-
-/**
- * Function to create email recipient names from {@linkplain User user} entities. The following two
- * strategies are representative.
- * <ul>
- * <li>Albert Einstein (given name + ' ' + family name)</li>
- * <li>Einstein, Albert (family name + ", " + given name)</li>
- * </ul>
- * 
- * @author Alejandro Guizar
- */
-public interface RecipientNameBuilder {
-
-	String buildName(User user);
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.email.spi;
+
+import org.jbpm.api.identity.User;
+
+/**
+ * Function to create email recipient names from {@linkplain User user} entities. The following two
+ * strategies are representative.
+ * <ul>
+ * <li>Albert Einstein (given name + ' ' + family name)</li>
+ * <li>Einstein, Albert (family name + ", " + given name)</li>
+ * </ul>
+ * 
+ * @author Alejandro Guizar
+ */
+public interface RecipientNameBuilder {
+
+	String buildName(User user);
+
+}

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -21,6 +21,7 @@
  */
 package org.jbpm.pvm.internal.identity.impl;
 
+import java.util.Collection;
 import java.util.List;
 
 import org.hibernate.Query;
@@ -86,6 +87,12 @@
     return group.getId();
   }
 
+
+  public Collection<User> findUsersByGroup(String groupId) {
+	// TODO Auto-generated method stub
+	return null;
+  }
+  
   public GroupImpl findGroupById(String groupId) {
     GroupImpl group = (GroupImpl) session.createQuery(
       "select group " +
@@ -151,4 +158,5 @@
     this.session = session;
   }
 
+
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -80,7 +80,13 @@
     throw new RuntimeException("Not yet implemented");
     // TODO: create and return user
   }
+  
 
+  public Collection<User> findUsersByGroup(String groupId) {
+  	// TODO Auto-generated method stub
+  	return null;
+  }
+
   public List<User> findUsers() {
     try {
       Collection<Identity> identities = identitySession
@@ -306,4 +312,5 @@
   }
 
 
+
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -37,9 +37,10 @@
   protected int dbversion;
 
   protected String id;
-  protected String password;
   protected String givenName;
   protected String familyName;
+  protected String emailAddress;
+  protected String password;
 
   public UserImpl() {
   }
@@ -59,8 +60,11 @@
   public String getFamilyName() {
     return familyName;
   }
-  
-  public String toString() {
+  public String getEmailAddress() {
+  	return emailAddress;
+	}
+
+	public String toString() {
     if ( (givenName!=null)
          && (familyName!=null)
        ) {
@@ -78,7 +82,10 @@
   public void setFamilyName(String familyName) {
     this.familyName = familyName;
   }
-  public String getPassword() {
+  public void setEmailAddress(String emailAddress) {
+		this.emailAddress = emailAddress;
+	}
+	public String getPassword() {
     return password;
   }
   public void setPassword(String password) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/spi/IdentitySession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/spi/IdentitySession.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/spi/IdentitySession.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -21,6 +21,7 @@
  */
 package org.jbpm.pvm.internal.identity.spi;
 
+import java.util.Collection;
 import java.util.List;
 
 import org.jbpm.api.identity.Group;
@@ -30,7 +31,7 @@
 /**
  * @author Tom Baeyens
  */
-public interface IdentitySession {
+public interface IdentitySession{
 
   /** create a new user */
   String createUser(String userId, String password, String givenName, String familyName);
@@ -51,6 +52,11 @@
    * @return the generated id for this group. */
   String createGroup(String groupName, String groupType, String parentGroupId);
 
+  /**
+   * lookup users with membership in group.
+   * @return the users or null if no users exist */
+  Collection<User> findUsersByGroup(String groupId);
+  
   /** lookup a group.
   * @return the user or null if no such user exists */
   Group findGroupById(String groupId);

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -21,7 +21,6 @@
  */
 package org.jbpm.pvm.internal.util;
 
-import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -34,8 +33,6 @@
 import org.jbpm.pvm.internal.xml.Parse;
 
 import javax.xml.namespace.QName;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
@@ -225,23 +222,15 @@
       return "null";
     }
 
-    Source source = new DOMSource(element);
-
     StringWriter stringWriter = new StringWriter();
-    PrintWriter printWriter = new PrintWriter(stringWriter);
-    Result result = new StreamResult(printWriter);
-
     try {
       TransformerFactory transformerFactory = TransformerFactory.newInstance();
       Transformer transformer = transformerFactory.newTransformer();
-      transformer.transform(source, result);
+      transformer.transform(new DOMSource(element), new StreamResult(stringWriter));
     } catch (Exception e) {
       log.error("couldn't transform dom element into string representation");
       return "<" + element.getTagName() + " ... >...</" + element.getTagName() + ">";
     }
-
-    printWriter.close();
-
     return stringWriter.toString();
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -703,7 +703,7 @@
     if (wireDefinition!=null) {
       String name = wireDefinition.getDescriptorName(type);
       if (name!=null) {
-        return (T) get(name);
+        return type.cast(get(name));
       } 
     }
     return null;

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.email.impl.MailServer;
+import org.jbpm.pvm.internal.email.impl.MailSessionImpl;
+import org.jbpm.pvm.internal.email.impl.AddressFilter;
+import org.jbpm.pvm.internal.email.spi.MailSession;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.PatternDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * Parses a descriptor for creating a {@link MailSession}.
+ * 
+ * @author Alejandro Guizar
+ */
+public class MailSessionBinding extends WireDescriptorBinding {
+
+  private static final PropertiesBinding propertiesBinding = new PropertiesBinding();
+  private static final ObjectBinding objectBinding = new ObjectBinding();
+
+  public MailSessionBinding() {
+    super("mail-session");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    // mail servers
+    List<Descriptor> serverDescriptors = new ArrayList<Descriptor>();
+    for (Element serverElement : XmlUtil.elements(element, "mail-server")) {
+      // mail server
+      ObjectDescriptor serverDescriptor = new ObjectDescriptor(MailServer.class);
+      serverDescriptors.add(serverDescriptor);
+
+      // address filter
+      Element filterElement = XmlUtil.element(serverElement, "address-filter");
+      if (filterElement != null) {
+        // includes
+        List<Descriptor> includeDescriptors = new ArrayList<Descriptor>();
+        for (Element includeElement : XmlUtil.elements(filterElement, "include")) {
+          includeDescriptors.add(parsePattern(includeElement, parse, parser));
+        }
+        ListDescriptor includesDescriptor = new ListDescriptor();
+        includesDescriptor.setValueDescriptors(includeDescriptors);
+
+        // excludes
+        List<Descriptor> excludeDescriptors = new ArrayList<Descriptor>();
+        for (Element excludeElement : XmlUtil.elements(filterElement, "exclude")) {
+          excludeDescriptors.add(parsePattern(excludeElement, parse, parser));
+        }
+        ListDescriptor excludesDescriptor = new ListDescriptor();
+        excludesDescriptor.setValueDescriptors(excludeDescriptors);
+
+        // address filter
+        ObjectDescriptor filterDescriptor = new ObjectDescriptor(AddressFilter.class);
+        filterDescriptor.addInjection("includePatterns", includesDescriptor);
+        filterDescriptor.addInjection("excludePatterns", excludesDescriptor);
+
+        serverDescriptor.addInjection("addressFilter", filterDescriptor);
+      }
+
+      // mail session properties
+      Element propertiesElement = XmlUtil.element(serverElement, "session-properties");
+      if (propertiesElement != null) {
+        Descriptor propertiesDescriptor =
+            (Descriptor) propertiesBinding.parse(propertiesElement, parse, parser);
+        serverDescriptor.addInjection("sessionProperties", propertiesDescriptor);
+      }
+      else {
+        parse.addProblem("missing mail session properties");
+      }
+
+      // authenticator
+      Element authenticatorElement = XmlUtil.element(serverElement, "authenticator");
+      if (authenticatorElement != null) {
+        Descriptor authenticatorDescriptor =
+            (Descriptor) objectBinding.parse(authenticatorElement, parse, parser);
+        serverDescriptor.addInjection("authenticator", authenticatorDescriptor);
+      }
+    }
+
+    // mail servers
+    ListDescriptor serversDescriptor = new ListDescriptor();
+    serversDescriptor.setValueDescriptors(serverDescriptors);
+
+    // mail session
+    ObjectDescriptor sessionDescriptor = new ObjectDescriptor(MailSessionImpl.class);
+    sessionDescriptor.addInjection("mailServers", serversDescriptor);
+    return sessionDescriptor;
+  }
+
+  protected Descriptor parsePattern(Element patternElement, Parse parse, Parser parser) {
+    PatternDescriptor patternDescriptor =
+        new PatternDescriptor(XmlUtil.getContentText(patternElement));
+    // literal
+    String literalAttr = XmlUtil.attribute(patternElement, "literal");
+    if (literalAttr != null) {
+      Boolean literal = XmlUtil.parseBooleanValue(literalAttr);
+      if (literal != null) patternDescriptor.setLiteral(literal);
+    }
+    // canonEq
+    String canonEqAttr = XmlUtil.attribute(patternElement, "canonEq");
+    if (canonEqAttr != null) {
+      Boolean canonEq = XmlUtil.parseBooleanValue(canonEqAttr);
+      if (canonEq != null) patternDescriptor.setCanonEq(canonEq);
+    }
+    return patternDescriptor;
+  }
+
+}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.email.impl.AttachmentTemplate;
+import org.jbpm.pvm.internal.email.impl.MailTemplate;
+import org.jbpm.pvm.internal.email.impl.RecipientTemplate;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+import org.jbpm.pvm.internal.wire.operation.PropertyOperation;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class MailTemplateBinding extends WireDescriptorBinding {
+
+  public MailTemplateBinding() {
+    super("mail-template");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor templateDescriptor = new ObjectDescriptor(MailTemplate.class);
+    // name
+    String name = element.getAttribute("name");
+    if (name != null) {
+      templateDescriptor.addInjection("name", new StringDescriptor(name));
+    }
+    else {
+      parse.addProblem("template has no name");
+    }
+    // language
+    String language = XmlUtil.attribute(element, "language");
+    if (language != null) {
+      templateDescriptor.addInjection("language", new StringDescriptor(language));
+    }
+    // to
+    Element toElement = XmlUtil.element(element, "to");
+    if (toElement != null) {
+      Descriptor toDescriptor = parseRecipientTemplate(toElement, parse, parser);
+      addPropertyInjection(templateDescriptor, "to", toDescriptor);
+    }
+    else {
+      parse.addProblem("template '" + name + "' has no 'to' recipients");
+    }
+    // cc
+    Element ccElement = XmlUtil.element(element, "cc");
+    if (ccElement != null) {
+      Descriptor ccDescriptor = parseRecipientTemplate(ccElement, parse, parser);
+      addPropertyInjection(templateDescriptor, "cc", ccDescriptor);
+    }
+    // bcc
+    Element bccElement = XmlUtil.element(element, "bcc");
+    if (bccElement != null) {
+      Descriptor bccDescriptor = parseRecipientTemplate(bccElement, parse, parser);
+      addPropertyInjection(templateDescriptor, "bcc", bccDescriptor);
+    }
+    // subject
+    Element subjectElement = XmlUtil.element(element, "subject");
+    if (subjectElement != null) {
+      StringDescriptor subjectDescriptor =
+          new StringDescriptor(XmlUtil.getContentText(subjectElement));
+      templateDescriptor.addInjection("subject", subjectDescriptor);
+    }
+    else {
+      parse.addProblem("template '" + name + "' has no subject");
+    }
+    // text
+    Element textElement = XmlUtil.element(element, "text");
+    if (textElement != null) {
+      StringDescriptor textDescriptor = new StringDescriptor(XmlUtil.getContentText(textElement));
+      templateDescriptor.addInjection("text", textDescriptor);
+    }
+    // html
+    Element htmlElement = XmlUtil.element(element, "html");
+    if (htmlElement != null) {
+      StringDescriptor htmlDescriptor = new StringDescriptor(XmlUtil.toString(htmlElement));
+      templateDescriptor.addInjection("html", htmlDescriptor);
+    }
+    // attachments
+    Element attachmentsElement = XmlUtil.element(element, "attachments");
+    if (attachmentsElement != null) {
+      List<Descriptor> attachmentDescriptors = new ArrayList<Descriptor>();
+      for (Element attachmentElement : XmlUtil.elements(attachmentsElement, "attachment")) {
+        ObjectDescriptor attachmentDescriptor = new ObjectDescriptor(AttachmentTemplate.class);
+        attachmentDescriptors.add(attachmentDescriptor);
+        // url
+        String url = XmlUtil.attribute(attachmentElement, "url");
+        if (url != null) attachmentDescriptor.addInjection("url", new StringDescriptor(url));
+        // resource
+        String resource = XmlUtil.attribute(attachmentElement, "resource");
+        if (resource != null)
+          attachmentDescriptor.addInjection("resource", new StringDescriptor(resource));
+        // file
+        String file = XmlUtil.attribute(attachmentElement, "file");
+        if (file != null) attachmentDescriptor.addInjection("file", new StringDescriptor(file));
+      }
+
+      ListDescriptor attachmentsDescriptor = new ListDescriptor();
+      attachmentsDescriptor.setValueDescriptors(attachmentDescriptors);
+      templateDescriptor.addInjection("attachmentTemplates", attachmentsDescriptor);
+    }
+    return templateDescriptor;
+  }
+
+  private static void addPropertyInjection(ObjectDescriptor objectDescriptor, String propertyName,
+      Descriptor valueDescriptor) {
+    PropertyOperation operation = new PropertyOperation();
+    operation.setPropertyName(propertyName);
+    operation.setDescriptor(valueDescriptor);
+    objectDescriptor.addOperation(operation);
+  }
+
+  protected Descriptor parseRecipientTemplate(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor recipientDescriptor = new ObjectDescriptor(RecipientTemplate.class);
+
+    String addresses = XmlUtil.attribute(element, "addresses");
+    if (addresses != null) recipientDescriptor.addInjection("addresses", new StringDescriptor(addresses));
+
+    String actors = XmlUtil.attribute(element, "actors");
+    if (actors != null) recipientDescriptor.addInjection("actors", new StringDescriptor(actors));
+
+    return recipientDescriptor;
+  }
+
+}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/PatternDescriptor.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/PatternDescriptor.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/PatternDescriptor.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/PatternDescriptor.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.util.regex.Pattern;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class PatternDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String regex;
+  protected boolean literal;
+  protected boolean canonEq;
+
+  public PatternDescriptor() {
+  }
+
+  public PatternDescriptor(String regex) {
+    this.regex = regex;
+  }
+
+  public boolean isLiteral() {
+    return literal;
+  }
+
+  public void setLiteral(boolean literal) {
+    this.literal = literal;
+  }
+
+  public boolean isCanonEq() {
+    return canonEq;
+  }
+
+  public void setCanonEq(boolean canonEq) {
+    this.canonEq = canonEq;
+  }
+
+  public Object construct(WireContext wireContext) {
+    int flags = 0;
+    if (literal) flags |= Pattern.LITERAL;
+    if (canonEq) flags |= Pattern.CANON_EQ;
+    return Pattern.compile(regex, flags);
+  }
+
+}

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -29,6 +29,7 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.Text;
+import org.w3c.dom.UserDataHandler;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.Locator;
@@ -41,7 +42,6 @@
 
   public Document document;
   
-  protected String debugNamespace = null;
   protected String lineAttributeName = "line";
   protected String columnAttributeName = null;
 
@@ -315,23 +315,12 @@
         int lineNumber = locator.getLineNumber();
         int columnNumber = locator.getColumnNumber();
 
-        if (debugNamespace==null) {
-          if (lineAttributeName!=null) {
-            elem.setAttribute(lineAttributeName, Integer.toString(lineNumber));
-          }
-          if (columnAttributeName!=null) {
-            elem.setAttribute(columnAttributeName, Integer.toString(columnNumber));
-          }
-          
-        } else {
-          if (lineAttributeName!=null) {
-            elem.setAttributeNS(debugNamespace, lineAttributeName, Integer.toString(lineNumber));
-          }
-          if (columnAttributeName!=null) {
-            elem.setAttributeNS(debugNamespace, columnAttributeName, Integer.toString(columnNumber));
-          }
-          
+        if (lineAttributeName!=null) {
+          elem.setUserData(lineAttributeName, lineNumber, null);
         }
+        if (columnAttributeName!=null) {
+          elem.setUserData(columnAttributeName, columnNumber, null);
+        }
       }
 
 
@@ -824,18 +813,12 @@
     return true;
   }
 
-  public void setDebugNamespace(String debugNamespace) {
-    this.debugNamespace = debugNamespace;
-  }
   public void setLineAttributeName(String lineAttributeName) {
     this.lineAttributeName = lineAttributeName;
   }
   public void setColumnAttributeName(String columnAttributeName) {
     this.columnAttributeName = columnAttributeName;
   }
-  public String getDebugNamespace() {
-    return debugNamespace;
-  }
   public String getLineAttributeName() {
     return lineAttributeName;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -24,15 +24,12 @@
 
 import java.io.File;
 import java.io.InputStream;
-import java.io.Serializable;
 import java.net.URL;
 import java.util.ListIterator;
 import java.util.Stack;
 
 import javax.xml.parsers.DocumentBuilder;
 
-import org.jbpm.api.JbpmException;
-import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.stream.FileStreamInput;
 import org.jbpm.pvm.internal.stream.InputStreamInput;
 import org.jbpm.pvm.internal.stream.ResourceStreamInput;
@@ -49,9 +46,8 @@
  * 
  * @author Tom Baeyens
  */
-public class Parse extends ProblemList implements Serializable, ErrorHandler {
+public class Parse extends ProblemList implements ErrorHandler {
 
-  private static Log log = Log.getLog(Parse.class.getName());
   private static final long serialVersionUID = 1L;
 
   protected Parser parser;
@@ -190,9 +186,7 @@
    * 'warning'. */
   public Parse checkProblems(String description) {
     if (hasProblems()) {
-      JbpmException jbpmException = getJbpmException();
-      log.info("problems during parse of "+description+": "+jbpmException.getMessage());
-      throw  jbpmException;
+      throw getJbpmException();
     }
     return this;
   }
@@ -232,13 +226,10 @@
       ListIterator<Object> listIter = objectStack.listIterator(objectStack.size());
       while (listIter.hasPrevious()) {
         Object object = listIter.previous();
-        if (object!=null) {
-          if (clazz.isAssignableFrom(object.getClass())) {
-            return (T) object;
-          }
+        if (clazz.isInstance(object)) {
+          return clazz.cast(object);
         }
       }
-      return null;
     }
     return null;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -394,6 +394,7 @@
           parseDocument(parse.document, parse);
 
         } catch (Exception e) {
+          e.printStackTrace();
           parse.addProblem("couldn't interpret the dom model: "+e.getMessage(), e);
         }
       }
@@ -437,7 +438,7 @@
       }
 
       DocumentBuilder documentBuilder = createDocumentBuilder(parse);
-      document = documentBuilder.newDocument();
+      document = documentBuilder.getDOMImplementation().createDocument(null, null, null);
       parse.setDocument(document);
 
       DomBuilder domBuilder = new DomBuilder();

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -28,10 +28,8 @@
 
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.Problem;
-import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.repository.DeploymentImpl;
 
-
 /** list of problems.  Base class for {@link Parse} 
  * and {@link DeploymentImpl}.
  * 
@@ -41,16 +39,14 @@
 
   private static final long serialVersionUID = 1L;
 
-  private static final String NEWLINE = System.getProperty("line.separator");
+  static final String NEWLINE = System.getProperty("line.separator");
 
-  private static final Log log = Log.getLog(ProblemList.class.getName());
-
   protected List<ProblemImpl> problems;
 
   /** all problems encountered */
   public List<Problem> getProblems() {
     if (problems==null) {
-      return Collections.EMPTY_LIST;
+      return Collections.emptyList();
     }
     return (List) problems;
   }

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email (from rev 4572, jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/email)

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl (from rev 4572, jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl)

Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl/AddressFilterTest.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl/AddressFilterTest.java	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl/AddressFilterTest.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -1,90 +0,0 @@
-package org.jbpm.pvm.internal.email.impl;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.regex.Pattern;
-
-import javax.mail.internet.InternetAddress;
-
-import junit.framework.TestCase;
-
-public class AddressFilterTest extends TestCase{
-
-	/**
-	 * When no filter is provided, all addresses should be contained in the filtered list.
-	 */
-	public void testWildCardIncludesNoFilters() throws Exception
-	{
-		AddressFilter filter = new AddressFilter();
-		
-		Collection<InternetAddress> addresses = new HashSet<InternetAddress>();
-		addresses.add(new InternetAddress("test at jboss.org"));
-		
-		Collection<InternetAddress> filteredAddresses = filter.filter(addresses);
-		assertTrue(filteredAddresses.contains(new InternetAddress("test at jboss.org")));
-	}
-	
-	/**
-	 * If the includes is provided, no other addresses except those explicitly listed should 
-	 * be included in the filtered list.
-	 */
-	public void testWildCardIncludes() throws Exception
-	{
-		AddressFilter filter = new AddressFilter();
-		
-		Collection<InternetAddress> addresses = new HashSet<InternetAddress>();
-		addresses.add(new InternetAddress("test at jboss.org"));
-		addresses.add(new InternetAddress("test at amentra.com"));
-		
-		filter.addIncludePattern(Pattern.compile(".+ at jboss.org"));
-		
-		Collection<InternetAddress> filteredAddresses = filter.filter(addresses);
-		assertTrue(filteredAddresses.contains(new InternetAddress("test at jboss.org")));
-		assertTrue(!filteredAddresses.contains(new InternetAddress("test at amentra.com")));
-	}
-	
-	/**
-	 * The includes should always override the excludes.
-	 */
-	public void testWildCardIncludesOverridesExcludes() throws Exception
-	{
-		AddressFilter filter = new AddressFilter();
-		
-		Collection<InternetAddress> addresses = new HashSet<InternetAddress>();
-		addresses.add(new InternetAddress("test at jboss.org"));
-		addresses.add(new InternetAddress("test at amentra.com"));
-		
-		filter.addIncludePattern(Pattern.compile(".+ at jboss.org"));
-		filter.addExcludePattern(Pattern.compile(".+ at amentra.com"));
-		
-		Collection<InternetAddress> filteredAddresses = filter.filter(addresses);
-		//Includes jboss
-		assertTrue(filteredAddresses.contains(new InternetAddress("test at jboss.org")));
-		//Does not include amentra.
-		assertTrue(!filteredAddresses.contains(new InternetAddress("test at amentra.com")));
-	}
-	
-	/**
-	 * When the excludes is specified but no includes, all addresses except those explicitly stated
-	 * should be contained in the filtered set.
-	 */
-	public void testWildCardExcludes() throws Exception
-	{
-		AddressFilter filter = new AddressFilter();
-		
-		Collection<InternetAddress> addresses = new HashSet<InternetAddress>();
-		addresses.add(new InternetAddress("test at jboss.org"));
-		addresses.add(new InternetAddress("test at amentra.com"));
-		addresses.add(new InternetAddress("test at redhat.com"));
-		
-		filter.addExcludePattern(Pattern.compile(".+ at jboss.org"));
-		
-		Collection<InternetAddress> filteredAddresses = filter.filter(addresses);
-		//Does not include jboss
-		assertTrue(!filteredAddresses.contains(new InternetAddress("test at jboss.org")));
-		//Does include amentra
-		assertTrue(filteredAddresses.contains(new InternetAddress("test at amentra.com")));
-		//Does include redhat
-		assertTrue(filteredAddresses.contains(new InternetAddress("test at redhat.com")));
-	}
-}

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl/AddressFilterTest.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl/AddressFilterTest.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl/AddressFilterTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/email/impl/AddressFilterTest.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,90 @@
+package org.jbpm.pvm.internal.email.impl;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.regex.Pattern;
+
+import javax.mail.internet.InternetAddress;
+
+import junit.framework.TestCase;
+
+public class AddressFilterTest extends TestCase{
+
+	/**
+	 * When no filter is provided, all addresses should be contained in the filtered list.
+	 */
+	public void testWildCardIncludesNoFilters() throws Exception
+	{
+		AddressFilter filter = new AddressFilter();
+		
+		Collection<InternetAddress> addresses = new HashSet<InternetAddress>();
+		addresses.add(new InternetAddress("test at jboss.org"));
+		
+		Collection<InternetAddress> filteredAddresses = filter.filter(addresses);
+		assertTrue(filteredAddresses.contains(new InternetAddress("test at jboss.org")));
+	}
+	
+	/**
+	 * If the includes is provided, no other addresses except those explicitly listed should 
+	 * be included in the filtered list.
+	 */
+	public void testWildCardIncludes() throws Exception
+	{
+		AddressFilter filter = new AddressFilter();
+		
+		Collection<InternetAddress> addresses = new HashSet<InternetAddress>();
+		addresses.add(new InternetAddress("test at jboss.org"));
+		addresses.add(new InternetAddress("test at amentra.com"));
+		
+		filter.addIncludePattern(Pattern.compile(".+ at jboss.org"));
+		
+		Collection<InternetAddress> filteredAddresses = filter.filter(addresses);
+		assertTrue(filteredAddresses.contains(new InternetAddress("test at jboss.org")));
+		assertTrue(!filteredAddresses.contains(new InternetAddress("test at amentra.com")));
+	}
+	
+	/**
+	 * The includes should always override the excludes.
+	 */
+	public void testWildCardIncludesOverridesExcludes() throws Exception
+	{
+		AddressFilter filter = new AddressFilter();
+		
+		Collection<InternetAddress> addresses = new HashSet<InternetAddress>();
+		addresses.add(new InternetAddress("test at jboss.org"));
+		addresses.add(new InternetAddress("test at amentra.com"));
+		
+		filter.addIncludePattern(Pattern.compile(".+ at jboss.org"));
+		filter.addExcludePattern(Pattern.compile(".+ at amentra.com"));
+		
+		Collection<InternetAddress> filteredAddresses = filter.filter(addresses);
+		//Includes jboss
+		assertTrue(filteredAddresses.contains(new InternetAddress("test at jboss.org")));
+		//Does not include amentra.
+		assertTrue(!filteredAddresses.contains(new InternetAddress("test at amentra.com")));
+	}
+	
+	/**
+	 * When the excludes is specified but no includes, all addresses except those explicitly stated
+	 * should be contained in the filtered set.
+	 */
+	public void testWildCardExcludes() throws Exception
+	{
+		AddressFilter filter = new AddressFilter();
+		
+		Collection<InternetAddress> addresses = new HashSet<InternetAddress>();
+		addresses.add(new InternetAddress("test at jboss.org"));
+		addresses.add(new InternetAddress("test at amentra.com"));
+		addresses.add(new InternetAddress("test at redhat.com"));
+		
+		filter.addExcludePattern(Pattern.compile(".+ at jboss.org"));
+		
+		Collection<InternetAddress> filteredAddresses = filter.filter(addresses);
+		//Does not include jboss
+		assertTrue(!filteredAddresses.contains(new InternetAddress("test at jboss.org")));
+		//Does include amentra
+		assertTrue(filteredAddresses.contains(new InternetAddress("test at amentra.com")));
+		//Does include redhat
+		assertTrue(filteredAddresses.contains(new InternetAddress("test at redhat.com")));
+	}
+}

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+import java.util.Properties;
+import java.util.regex.Pattern;
+
+import javax.mail.Authenticator;
+import javax.mail.PasswordAuthentication;
+
+import org.jbpm.api.JbpmException;
+import org.jbpm.pvm.internal.email.impl.AddressFilter;
+import org.jbpm.pvm.internal.email.impl.MailServer;
+import org.jbpm.pvm.internal.email.impl.MailSessionImpl;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class MailSessionWireTest extends WireTestCase {
+
+  public void testSessionProperties() {
+    WireContext wireContext =
+        createWireContext("<objects>"
+          + "  <mail-session>"
+          + "    <mail-server>"
+          + "      <session-properties>"
+          + "        <property name='mail.host' value='localhost' />"
+          + "        <property name='mail.user' value='aguizar' />"
+          + "        <property name='mail.from' value='noreply at jbpm.org' />"
+          + "      </session-properties>"
+          + "    </mail-server>"
+          + "  </mail-session>"
+          + "</objects>");
+
+    MailSessionImpl mailSession = wireContext.get(MailSessionImpl.class);
+    List<MailServer> mailServers = mailSession.getMailServers();
+    assertEquals(1, mailServers.size());
+
+    MailServer mailServer = mailServers.get(0);
+    Properties properties = mailServer.getSessionProperties();
+    assertEquals(3, properties.size());
+    assertEquals("localhost", properties.getProperty("mail.host"));
+    assertEquals("aguizar", properties.getProperty("mail.user"));
+    assertEquals("noreply at jbpm.org", properties.getProperty("mail.from"));
+  }
+
+  public void testNoSessionProperties() {
+    try {
+      createWireContext("<objects>"
+        + "  <mail-session>"
+        + "    <mail-server />"
+        + "  </mail-session>"
+        + "</objects>");
+      fail("expected wire context creation to puke");
+    }
+    catch (JbpmException e) {
+      // session properties are mandatory
+    }
+  }
+
+  public static class MyAuthenticator extends Authenticator {
+    @Override
+    protected PasswordAuthentication getPasswordAuthentication() {
+      return new PasswordAuthentication("aguizar", "wontsay");
+    }
+  }
+
+  public void testAuthenticator() {
+    WireContext wireContext =
+        createWireContext("<objects>" +
+          "  <mail-session>" +
+          "    <mail-server>" +
+          "      <session-properties />" +
+          "      <authenticator class='" +
+          MyAuthenticator.class.getName() +
+          "' />" +
+          "    </mail-server>" +
+          "  </mail-session>" +
+          "</objects>");
+
+    MailSessionImpl mailSession = wireContext.get(MailSessionImpl.class);
+    List<MailServer> mailServers = mailSession.getMailServers();
+    assertEquals(1, mailServers.size());
+
+    MailServer mailServer = mailServers.get(0);
+    assertSame(MyAuthenticator.class, mailServer.getAuthenticator().getClass());
+  }
+
+  public void testAddressFilter() {
+    WireContext wireContext =
+        createWireContext("<objects>"
+          + "  <mail-session>"
+          + "    <mail-server>"
+          + "      <address-filter>"
+          + "        <include>.+ at jbpm.org</include>"
+          + "        <exclude>.+ at jboss.com</exclude>"
+          + "        <exclude>.+ at redhat.com</exclude>"
+          + "      </address-filter>"
+          + "      <session-properties />"
+          + "    </mail-server>"
+          + "  </mail-session>"
+          + "</objects>");
+
+    MailSessionImpl mailSession = wireContext.get(MailSessionImpl.class);
+    List<MailServer> mailServers = mailSession.getMailServers();
+    assertEquals(1, mailServers.size());
+
+    MailServer mailServer = mailServers.get(0);
+    AddressFilter addressFilter = mailServer.getAddressFilter();
+
+    List<Pattern> includePatterns = addressFilter.getIncludePatterns();
+    assertEquals(1, includePatterns.size());
+    assertEquals(".+ at jbpm.org", includePatterns.get(0).toString());
+
+    List<Pattern> excludePatterns = addressFilter.getExcludePatterns();
+    assertEquals(2, excludePatterns.size());
+    assertEquals(".+ at jboss.com", excludePatterns.get(0).toString());
+    assertEquals(".+ at redhat.com", excludePatterns.get(1).toString());
+
+    assertEquals(0, mailServer.getSessionProperties().size());
+  }
+
+  public void testNoAddressFilter() {
+    WireContext wireContext =
+        createWireContext("<objects>"
+          + "  <mail-session>"
+          + "    <mail-server>"
+          + "      <session-properties />"
+          + "    </mail-server>"
+          + "  </mail-session>"
+          + "</objects>");
+
+    MailSessionImpl mailSession = wireContext.get(MailSessionImpl.class);
+    List<MailServer> mailServers = mailSession.getMailServers();
+    assertEquals(1, mailServers.size());
+
+    MailServer mailServer = mailServers.get(0);
+    assertNull("expected no address filter", mailServer.getAddressFilter());
+    assertEquals(0, mailServer.getSessionProperties().size());
+  }
+
+  public void testMultipleMailServers() {
+    WireContext wireContext =
+        createWireContext("<objects>"
+          + "  <mail-session>"
+          + "    <mail-server>"
+          + "      <session-properties />"
+          + "    </mail-server>"
+          + "    <mail-server>"
+          + "      <session-properties />"
+          + "    </mail-server>"
+          + "    <mail-server>"
+          + "      <session-properties />"
+          + "    </mail-server>"
+          + "  </mail-session>"
+          + "</objects>");
+
+    MailSessionImpl mailSession = wireContext.get(MailSessionImpl.class);
+    List<MailServer> mailServers = mailSession.getMailServers();
+    assertEquals(3, mailServers.size());
+  }
+}

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailTemplateWireTest.java (from rev 4572, jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailTemplateWireTest.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailTemplateWireTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailTemplateWireTest.java	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,171 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.email.impl.AttachmentTemplate;
+import org.jbpm.pvm.internal.email.impl.MailTemplate;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class MailTemplateWireTest extends WireTestCase {
+
+	public void testName() {
+		WireContext wireContext =
+				createWireContext("<objects>"
+						+ "<mail-template name='plate'>"
+						+ "  <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+						+ "  <subject>bureaucracy</subject>"
+						+ "</mail-template>"
+						+ "</objects>");
+
+		MailTemplate template = wireContext.get(MailTemplate.class);
+		assertEquals("plate", template.getName());
+	}
+
+	public void testLanguage() {
+		WireContext wireContext =
+				createWireContext("<objects>"
+						+ "<mail-template name='plate' language='juel'>"
+						+ "  <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+						+ "  <subject>bureaucracy</subject>"
+						+ "</mail-template>"
+						+ "</objects>");
+
+		MailTemplate template = wireContext.get(MailTemplate.class);
+		assertEquals("juel", template.getLanguage());
+	}
+
+	public void testTo() {
+		WireContext wireContext =
+				createWireContext("<objects>"
+						+ "<mail-template name='plate'>"
+						+ "  <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+						+ "  <subject>bureaucracy</subject>"
+						+ "</mail-template>"
+						+ "</objects>");
+
+		MailTemplate template = wireContext.get(MailTemplate.class);
+		assertEquals("dilbert at office, alice at work, dogbert at house", template.getTo().getAddresses());
+	}
+
+	public void testCc() {
+		WireContext wireContext =
+				createWireContext("<objects>"
+						+ "<mail-template name='plate'>"
+						+ "  <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+						+ "  <cc actors='theboss, hrpolicymaker'/>"
+						+ "  <subject>bureaucracy</subject>"
+						+ "</mail-template>"
+						+ "</objects>");
+
+		MailTemplate template = wireContext.get(MailTemplate.class);
+		assertEquals("theboss, hrpolicymaker", template.getCc().getActors());
+	}
+
+	public void testBcc() {
+		WireContext wireContext =
+				createWireContext("<objects>"
+						+ "<mail-template name='plate'>"
+						+ "  <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+						+ "  <bcc actors='thoughtpolice'/>"
+						+ "  <subject>bureaucracy</subject>"
+						+ "</mail-template>"
+						+ "</objects>");
+
+		MailTemplate template = wireContext.get(MailTemplate.class);
+		assertEquals("thoughtpolice", template.getBcc().getActors());
+	}
+
+	public void testSubject() {
+		WireContext wireContext =
+				createWireContext("<objects>"
+						+ "<mail-template name='plate'>"
+						+ "  <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+						+ "  <subject>bureaucracy</subject>"
+						+ "</mail-template>"
+						+ "</objects>");
+
+		MailTemplate template = wireContext.get(MailTemplate.class);
+		assertEquals("bureaucracy", template.getSubject());
+	}
+
+	public void testText() {
+		WireContext wireContext =
+				createWireContext("<objects>"
+						+ "<mail-template name='plate'>"
+						+ "  <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+						+ "  <subject>bureaucracy</subject>"
+						+ "  <text>plain text content</text>"
+						+ "</mail-template>"
+						+ "</objects>");
+
+		MailTemplate template = wireContext.get(MailTemplate.class);
+		assertEquals("plain text content", template.getText());
+	}
+
+	public void testHtml() {
+		WireContext wireContext =
+				createWireContext("<objects>"
+						+ "<mail-template name='plate'>"
+						+ "  <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+						+ "  <subject>bureaucracy</subject>"
+						+ "  <html><strong>rich</strong> content</html>"
+						+ "</mail-template>"
+						+ "</objects>");
+
+		MailTemplate template = wireContext.get(MailTemplate.class);
+		System.out.println(template.getHtml());
+		assertEquals("<html>\n<strong>rich</strong> content</html>\n", template.getHtml());
+	}
+
+	public void testAttachments() {
+		WireContext wireContext =
+				createWireContext("<objects>"
+						+ "<mail-template name='plate'>"
+						+ "  <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+						+ "  <subject>bureaucracy</subject>"
+						+ "  <attachments>"
+						+ "    <attachment url='http://en.wikipedia.org/wiki/File:Dilbert-20050910.png'/>"
+						+ "    <attachment resource='org/example/pic.jpg'/>"
+						+ "    <attachment file='${user.home}/.face'/>"
+						+ "  </attachments>"
+						+ "</mail-template>"
+						+ "</objects>");
+
+		MailTemplate template = wireContext.get(MailTemplate.class);
+		List<AttachmentTemplate> attachmentTemplates = template.getAttachmentTemplates();
+		assertEquals(3, attachmentTemplates.size());
+		// url
+		AttachmentTemplate attachmentTemplate = attachmentTemplates.get(0);
+		assertEquals("http://en.wikipedia.org/wiki/File:Dilbert-20050910.png", attachmentTemplate
+				.getUrl());
+		// resource
+		attachmentTemplate = attachmentTemplates.get(1);
+		assertEquals("org/example/pic.jpg", attachmentTemplate.getResource());
+		// file
+		attachmentTemplate = attachmentTemplates.get(2);
+		assertEquals("${user.home}/.face", attachmentTemplate.getFile());
+	}
+}

Modified: jbpm4/trunk/modules/pvm/src/test/resources/jbpm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/jbpm.wire.bindings.xml	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/pvm/src/test/resources/jbpm.wire.bindings.xml	2009-04-16 22:39:50 UTC (rev 4573)
@@ -39,6 +39,7 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.BusinessCalendarBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.IdGeneratorBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.AuthenticationBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MailTemplateBinding" />
   <!-- hibernate bindings -->
   <binding class="org.jbpm.pvm.internal.wire.binding.HibernateConfigurationBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.SeamHibernateSessionBinding" />
@@ -52,6 +53,7 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionFactoryBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.RepositorySessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MailSessionBinding" />
   
   <!-- db sessions -->
   <binding class="org.jbpm.pvm.internal.wire.binding.PvmDbSessionBinding" />

Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/master.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/master.xml	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/master.xml	2009-04-16 22:39:50 UTC (rev 4573)
@@ -9,7 +9,8 @@
   <!ENTITY ch06-Variables          SYSTEM "modules/ch06-Variables.xml">
   <!ENTITY ch07-Scripting          SYSTEM "modules/ch07-Scripting.xml">
   <!ENTITY ch08-Identity           SYSTEM "modules/ch08-Identity.xml">
-  <!ENTITY ch08-JBossIntegration   SYSTEM "modules/ch09-JBossIntegration.xml">
+  <!ENTITY ch09-JBossIntegration   SYSTEM "modules/ch09-JBossIntegration.xml">
+  <!ENTITY ch10-Emails             SYSTEM "modules/ch10-Emails.xml">
 ]>
 
 <book lang="en">
@@ -28,6 +29,7 @@
   &ch06-Variables;
   &ch07-Scripting;
   &ch08-Identity;
-  &ch08-JBossIntegration;
+  &ch09-JBossIntegration;
+  &ch10-Emails;
 
 </book>
\ No newline at end of file

Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch10-Emails.xml (from rev 4572, jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml)
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch10-Emails.xml	                        (rev 0)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch10-Emails.xml	2009-04-16 22:39:50 UTC (rev 4573)
@@ -0,0 +1,259 @@
+<chapter id="emails">
+  <title>Email Support</title>
+  <para>
+  	This chapter explains Email Support provided within jBPM 4.  
+  </para>
+  
+  
+  <section id="mailinjpdl">
+    <title>Mail in jPDL</title>
+  </section>
+  <section id="scriptableemails">
+    <title>Producers</title>
+    <para>Producers are responsible for creating emails within jBPM. All mail producers implement the <literal>org.jbpm.pvm.internal.email.producer.MailProducer</literal> interface.
+    Several out-of-the-box implementations have been created to address simple email needs.</para>
+    
+	<section id="standardemailformat">
+	  <title>Standard</title>
+	  <para>Used to send non-scripted text emails.</para>
+	  <table><title>Standard Email</title>
+      <tgroup cols="2" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Property</entry>
+            <entry>Description</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><literal>subject</literal></entry>
+            <entry>Email subject.</entry>
+          </row>
+          <row>
+            <entry><literal>text</literal></entry>
+            <entry>The textual body of the email.</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+	</section>
+	<section id="scriptedemailformat">
+	  <title>Scriptable Standard</title>
+	  <para>Used to send scripted text emails for the subject and/or text.</para>
+	  <table><title>Scriptable Email</title>
+      <tgroup cols="2" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Property</entry>
+            <entry>Description</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><literal>language</literal></entry>
+            <entry>The scripting language used to resolve properties within the subject and textual body.  If not provided, the default script language is applied.</entry>
+          </row>
+          <row>
+            <entry><literal>subject</literal></entry>
+            <entry>Email subject.</entry>
+          </row>
+          <row>
+            <entry><literal>text</literal></entry>
+            <entry>The textual body of the email.</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+	</section>
+	<section id="htmlemailformat">
+	  <title>Scriptable HTML</title>
+	  <para>Used to send scripted HTML formatted emails for the subject, text, and html.</para>
+	</section>
+	<table><title>Scriptable HTML Email</title>
+      <tgroup cols="2" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Property</entry>
+            <entry>Description</entry>
+          </row>
+        </thead>
+		<tbody>
+          <row>
+            <entry><literal>language</literal></entry>
+            <entry>The scripting language used to resolve properties within the subject, textual body, and HTML body. If not provided, the default script language is applied.</entry>
+          </row>
+          <row>
+            <entry><literal>subject</literal></entry>
+            <entry>Email subject.</entry>
+          </row>
+          <row>
+            <entry><literal>text</literal></entry>
+            <entry>The textual body of the email.</entry>
+          </row>
+          <row>
+            <entry><literal>html</literal></entry>
+            <entry>The HTML formatted body of the email.</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+    <para>For complex emails or custom generation of attachments, see: <link linkend="customemails">Extension Points: Custom Emails</link>.</para>
+  </section>
+  <section id="emailtemplates">
+    <title>Templates</title>
+    <para>Templates are available to externalize commonly used messages from jPDL definitions.  In jBPM 4, templates can produce either standard or HTML message; also, templates 
+    can support any scripting language supported by the jBPM Script Manager.  As you will see, any <literal>MailProducer</literal> implementation available to jPDL is also available to be templated.
+    </para>
+    <para>The following is an example of a scriptable Email Template.</para>
+    <programlisting>TODO</programlisting>
+    <para>The following is an example of a scriptable HTML Email Template.</para>
+    <programlisting>TODO</programlisting>
+  </section>
+  <section id="emailserverconfiguration">
+    <title>Server Configuration</title>
+    <para>Mail Server configuration is provided within jbpm.cfg.xml  The <literal>mail-server</literal> tag describes an SMTP mail server capable of sending email messages.
+    Because jBPM uses JavaMail to send mail, all properties supported by JavaMail are also exposed to jBPM.  Within the <literal>session-properties</literal> 
+    subtag of <literal>mail-server</literal>, the SMTP properties must be provided as described in the example below.</para>
+    <para>
+    See the Sun JavaMail API for more information on supported properties: <ulink url="http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-summary.html">Sun SMTP Properties</ulink>. 
+    </para>
+    <programlisting>&lt;objects&gt;
+	&lt;mail-session&gt;
+		&lt;mail-server&gt;<emphasis role="bold">
+			&lt;session-properties&gt;
+				&lt;property name='mail.host' value='localhost' /&gt;
+				...
+			&lt;/session-properties&gt;</emphasis>
+		&lt;/mail-server&gt;
+	&lt;/mail-session&gt;
+&lt;/objects&gt;</programlisting>
+    <section id="serverconfigurationmultipl">
+    	<title>Multiple Mail Servers</title>
+    	<para>Multiple SMTP server support has been added to jBPM 4 to support many organizational server structures.  
+    	This is useful for organizations who have both internal and external SMTP servers, for example.</para>
+    	<para>
+    	To setup multiple SMTP mail servers, provide multiple mail servers within the jBPM configuration, as described below.
+    	
+    	Note that the tag <literal>address-filter</literal> has been added to filter which domains are serviced by each mail server.
+    	The mail filter accepts regular expressions to determine if an address is to be sent by a given server.
+    	</para>
+    	<para>See the Sun Pattern API for more information on supported RegEx expressions: <ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html">Sun Regex Patterns</ulink>.
+    	</para>
+    <programlisting>&lt;objects&gt;
+	&lt;mail-session&gt;
+		&lt;mail-server&gt;<emphasis role="bold">
+			&lt;address-filter&gt;
+				&lt;include&gt;.+ at jbpm.org&lt;/include&gt;
+			&lt;/address-filter&gt;</emphasis>
+			&lt;session-properties&gt;
+				&lt;property name='mail.host' value='internal.host.url' /&gt;
+				...
+			&lt;/session-properties&gt;
+		&lt;/mail-server&gt;
+		&lt;mail-server&gt;<emphasis role="bold">
+			&lt;address-filter&gt;
+				&lt;exclude&gt;.+ at jbpm.org&lt;/exclude&gt;
+			&lt;/address-filter&gt;</emphasis>
+			&lt;session-properties&gt;
+				&lt;property name='mail.host' value='external.host.url' /&gt;
+				...
+			&lt;/session-properties&gt;
+		&lt;/mail-server&gt;
+	&lt;/mail-session&gt;
+&lt;/objects&gt;</programlisting>
+		<para>
+			The include/excude logic includes an address if it is <emphasis role="bold">included and not explicitly excluded.</emphasis>
+			
+			The include/exclude logic within the address filter is described below.
+			
+			<table><title>Address Filter</title>
+      <tgroup cols="3" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Property</entry>
+            <entry>Multiple</entry>
+            <entry>Description</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><literal>include</literal></entry>
+            <entry>0</entry>
+            <entry>If no includes are present, the address filter will include all email addresses.</entry>
+          </row>
+          <row>
+            <entry><literal>include</literal></entry>
+            <entry>1..Many</entry>
+            <entry>If one or more includes are present, the address filter will include only email addresses matching the include patterns provided.</entry>
+          </row>
+          <row>
+            <entry><literal>exclude</literal></entry>
+            <entry>0</entry>
+            <entry>If no excludes are present, no addresses are explicitly excluded.</entry>
+          </row>
+		  <row>
+            <entry><literal>exclude</literal></entry>
+            <entry>1..Many</entry>
+            <entry>If one or more excludes are present, the address filter will explicitly exclude only email addresses matching the exclude patterns provided.</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+		</para>
+    </section>
+  </section>
+  <section id="extensibility">
+    <title>Extension Points</title>
+  	<section id="addressresolvers">
+    	<title>Address Resolvers</title>
+    	<para>When implementing a different Identity Management in jBPM [such as LDAP], an Address Resolver is required to resolve Actor and Group email addresses from the Identity Management system.</para>
+    	<para>Address Resolvers must implement the <literal>org.jbpm.pvm.internal.email.resolver.AddressResolver</literal> interface.  Provided with a User or Group Identifier, the should return valid JavaMail <literal>javax.mail.internet.InternetAddress</literal>es for the given identifier.</para>
+    	<para>Plugging in a custom Address Resolver to jBPM is handled within the jBPM Configuration.  The following is an example of providing a custom Address Resolver within <literal>jbpm.cfg.xml</literal>.</para>
+    	<programlisting>TODO</programlisting>
+    	
+  	</section>
+  	<section id="customemails">
+    	<title>Custom Emails</title>
+		<para>jBPM 4 allows the creation of your own Email Producers to address an organization's specific email needs.  
+		To do so, users must implement the <literal>org.jbpm.pvm.internal.email.producer.MailProducer</literal> interface.  The method produce will return one or more Email objects, which jBPM will then send using the jBPM MailSession.
+		<para>Apache Commons Email was choosen to simplify the email interface for jBPM.  All emails returned by the MailProducer implementation must extend the base <literal>org.apache.commons.mail.Email</literal>.</para>
+		<para>See the Apache Commons for more information on supported <literal>Email</literal> types:
+		<ulink url="http://commons.apache.org/email/">Apache Commons Email</ulink>.</para>
+		</para>
+		
+  		<section id="generatedemailattachments">
+    		<title>Attachments</title>
+    		<para>
+    		Generation of custom attachments at runtime can be easily implemented in jBPM 4.  By extending out-of-the-box mail producers, or implementing your own with the <literal>MailProducer</literal> interface, attachments can be generated, attachments can be generated and added to 
+    		emails at runtime.
+    		</para>
+    		<para>The following is an example of how to extend <literal>HtmlScriptMailProducer</literal> to produce HTML emails with custom attachments.</para>
+    		<programlisting>public class CustomAttachmentHtmlScriptMailProducer extends HtmlScriptMailProducer{
+
+	@Override
+	public Collection&lt;Email&gt; produce(Execution exe, MailContext mailContext)
+			throws Exception {
+		//Use the HTML producer to create the body, subject, text.
+		Collection&lt;Email&gt; emails = super.produce(exe, mailContext);
+		
+		//Add custom code to generate attachments here.
+		EmailAttachment attachment = null;
+		
+		for(Email email : emails)
+		{
+			//We know it's a collection of HTML email.
+			HtmlEmail html = (HtmlEmail)email;
+			//Add your custom attachment.
+			html.attach(attachment);
+		}
+			
+		return emails;
+		
+	}
+}</programlisting>
+  		</section>
+  	</section>
+  
+  </section>
+  
+</chapter>
\ No newline at end of file

Modified: jbpm4/trunk/pom.xml
===================================================================
--- jbpm4/trunk/pom.xml	2009-04-16 21:39:27 UTC (rev 4572)
+++ jbpm4/trunk/pom.xml	2009-04-16 22:39:50 UTC (rev 4573)
@@ -47,6 +47,7 @@
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <apache.ant.version>1.7.0</apache.ant.version>
     <cactus.version>13-1.7.1</cactus.version>
+    <commons.email.version>1.2-SNAPSHOT</commons.email.version>
     <gwt.console.version>1.0.0-SNAPSHOT</gwt.console.version>
     <hibernate.version>3.2.6.ga</hibernate.version>
     <hibernate.annotations.version>3.3.1.GA</hibernate.annotations.version>
@@ -315,6 +316,11 @@
         <artifactId>jtds</artifactId>
         <version>${jtds.version}</version>
       </dependency>
+      <dependency>
+      	<groupId>commons-email</groupId>
+      	<artifactId>commons-email</artifactId>
+      	<version>${commons.email.version}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 




More information about the jbpm-commits mailing list