[jbpm-commits] JBoss JBPM SVN: r6429 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/email/impl and 5 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jun 22 13:57:46 EDT 2010


Author: alex.guizar at jboss.com
Date: 2010-06-22 13:57:45 -0400 (Tue, 22 Jun 2010)
New Revision: 6429

Modified:
   jbpm4/trunk/modules/pvm/pom.xml
   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/wire/binding/HibernateConfigurationBinding.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/PropertiesBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JndiDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java
   jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml
   jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch09-Configuration.xml
Log:
JBPM-1171: fetch mail session from jndi
document mail configuration in user guide

Modified: jbpm4/trunk/modules/pvm/pom.xml
===================================================================
--- jbpm4/trunk/modules/pvm/pom.xml	2010-06-22 16:55:56 UTC (rev 6428)
+++ jbpm4/trunk/modules/pvm/pom.xml	2010-06-22 17:57:45 UTC (rev 6429)
@@ -159,6 +159,12 @@
       <artifactId>spring</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+    	<groupId>asm</groupId>
+    	<artifactId>asm</artifactId>
+    	<version>1.5.3</version>
+    	<scope>test</scope>
+    </dependency>
   </dependencies>
 
   <!-- Plugins -->

Modified: 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/MailServer.java	2010-06-22 16:55:56 UTC (rev 6428)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java	2010-06-22 17:57:45 UTC (rev 6429)
@@ -43,8 +43,16 @@
 
   public Session getMailSession() {
     if (mailSession == null) {
-      mailSession = Session.getInstance(sessionProperties, authenticator);
+      synchronized (this) {
+        if (mailSession == null) {
+          mailSession = Session.getInstance(sessionProperties, authenticator);
+        }
+      }
     }
     return mailSession;
   }
+
+  protected void setMailSession(Session mailSession) {
+    this.mailSession = mailSession;
+  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateConfigurationBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateConfigurationBinding.java	2010-06-22 16:55:56 UTC (rev 6428)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateConfigurationBinding.java	2010-06-22 17:57:45 UTC (rev 6429)
@@ -22,24 +22,22 @@
 package org.jbpm.pvm.internal.wire.binding;
 
 import java.io.File;
-import java.io.InputStream;
 import java.net.URL;
-import java.util.Enumeration;
 import java.util.List;
 
 import org.hibernate.cfg.Configuration;
+import org.w3c.dom.Element;
+
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.stream.FileStreamInput;
 import org.jbpm.pvm.internal.stream.ResourceStreamInput;
 import org.jbpm.pvm.internal.stream.StreamInput;
 import org.jbpm.pvm.internal.stream.UrlStreamInput;
-import org.jbpm.pvm.internal.util.ReflectUtil;
 import org.jbpm.pvm.internal.util.XmlUtil;
 import org.jbpm.pvm.internal.wire.descriptor.HibernateConfigurationDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.PropertiesDescriptor;
 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 hibernate Configuration.
  * 
@@ -51,8 +49,6 @@
 
   private static final Log log = Log.getLog(HibernateConfigurationBinding.class.getName());
   
-  private static final PropertiesBinding propertiesBinding = new PropertiesBinding();
-
   public HibernateConfigurationBinding() {
     super("hibernate-configuration");
   }
@@ -134,7 +130,7 @@
         }
 
       } else if ("properties".equals(configElement.getLocalName())) {
-        PropertiesDescriptor propertiesDescriptor = (PropertiesDescriptor) propertiesBinding.parse(configElement, parse, parser);
+        PropertiesDescriptor propertiesDescriptor = PropertiesBinding.parseDescriptor(configElement, parse, parser);
         descriptor.setPropertiesDescriptor(propertiesDescriptor);
 
       } else if ("cache-configuration".equals(configElement.getLocalName())) {

Modified: 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/MailSessionBinding.java	2010-06-22 16:55:56 UTC (rev 6428)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java	2010-06-22 17:57:45 UTC (rev 6429)
@@ -24,18 +24,20 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.w3c.dom.Element;
+
+import org.jbpm.pvm.internal.email.impl.AddressFilter;
 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.JndiDescriptor;
 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}.
@@ -44,9 +46,6 @@
  */
 public class MailSessionBinding extends WireDescriptorBinding {
 
-  private static final PropertiesBinding propertiesBinding = new PropertiesBinding();
-  private static final ObjectBinding objectBinding = new ObjectBinding();
-
   public MailSessionBinding() {
     super("mail-session");
   }
@@ -86,23 +85,29 @@
         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);
+      if (serverElement.hasAttribute("session-jndi")) {
+        // session jndi name
+        String jndiName = serverElement.getAttribute("session-jndi");
+        Descriptor jndiDescriptor = new JndiDescriptor(jndiName);
+        serverDescriptor.addInjection("mailSession", jndiDescriptor);
       }
       else {
-        parse.addProblem("missing mail session properties", element);
-      }
+        // session properties
+        Element propertiesElement = XmlUtil.element(serverElement, "session-properties");
+        if (propertiesElement != null) {
+          Descriptor propertiesDescriptor = PropertiesBinding.parseDescriptor(propertiesElement, parse, parser);
+          serverDescriptor.addInjection("sessionProperties", propertiesDescriptor);
+        }
+        else {
+          parse.addProblem("missing mail session properties or jndi name", serverElement);
+        }
 
-      // authenticator
-      Element authenticatorElement = XmlUtil.element(serverElement, "authenticator");
-      if (authenticatorElement != null) {
-        Descriptor authenticatorDescriptor =
-            (Descriptor) objectBinding.parse(authenticatorElement, parse, parser);
-        serverDescriptor.addInjection("authenticator", authenticatorDescriptor);
+        // authenticator
+        Element authenticatorElement = XmlUtil.element(serverElement, "authenticator");
+        if (authenticatorElement != null) {
+          Descriptor authenticatorDescriptor = ObjectBinding.parseObjectDescriptor(authenticatorElement, parse, parser);
+          serverDescriptor.addInjection("authenticator", authenticatorDescriptor);
+        }
       }
     }
 
@@ -116,20 +121,23 @@
     return sessionDescriptor;
   }
 
-  protected Descriptor parsePattern(Element patternElement, Parse parse, Parser parser) {
-    PatternDescriptor patternDescriptor =
-        new PatternDescriptor(XmlUtil.getContentText(patternElement));
+  public static PatternDescriptor parsePattern(Element element, Parse parse, Parser parser) {
+    // content
+    String regex = XmlUtil.getContentText(element);
+    PatternDescriptor patternDescriptor = new PatternDescriptor(regex);
     // literal
-    String literalAttr = XmlUtil.attribute(patternElement, "literal");
+    String literalAttr = XmlUtil.attribute(element, "literal");
     if (literalAttr != null) {
       Boolean literal = XmlUtil.parseBooleanValue(literalAttr);
-      if (literal != null) patternDescriptor.setLiteral(literal);
+      if (literal != null)
+        patternDescriptor.setLiteral(literal);
     }
     // canonEq
-    String canonEqAttr = XmlUtil.attribute(patternElement, "canonEq");
+    String canonEqAttr = XmlUtil.attribute(element, "canonEq");
     if (canonEqAttr != null) {
       Boolean canonEq = XmlUtil.parseBooleanValue(canonEqAttr);
-      if (canonEq != null) patternDescriptor.setCanonEq(canonEq);
+      if (canonEq != null)
+        patternDescriptor.setCanonEq(canonEq);
     }
     return patternDescriptor;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java	2010-06-22 16:55:56 UTC (rev 6428)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java	2010-06-22 17:57:45 UTC (rev 6429)
@@ -45,6 +45,10 @@
   }
 
   public Object parse(Element element, Parse parse, Parser parser) {
+    return parseDescriptor(element, parse, parser);
+  }
+
+  public static PropertiesDescriptor parseDescriptor(Element element, Parse parse, Parser parser) {
     PropertiesDescriptor descriptor = new PropertiesDescriptor();
     
     if (element.hasAttribute("file")) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JndiDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JndiDescriptor.java	2010-06-22 16:55:56 UTC (rev 6428)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JndiDescriptor.java	2010-06-22 17:57:45 UTC (rev 6429)
@@ -21,22 +21,22 @@
  */
 package org.jbpm.pvm.internal.wire.descriptor;
 
+import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
 import org.jbpm.pvm.internal.wire.WireContext;
 import org.jbpm.pvm.internal.wire.WireException;
 
-
 /**
  * @author Tom Baeyens
  */
 public class JndiDescriptor extends AbstractDescriptor {
 
   private static final long serialVersionUID = 1L;
-  
-  String jndiName;
-  
+
+  private String jndiName;
+
   protected JndiDescriptor() {
   }
 
@@ -46,10 +46,16 @@
 
   public Object construct(WireContext wireContext) {
     try {
-      InitialContext initialContext = new InitialContext();
-      return initialContext.lookup(jndiName);
-    } catch (NamingException e) {
-      throw new WireException("couldn't lookup '"+jndiName+"' from the initial context");
+      Context initialContext = new InitialContext();
+      try {
+        return initialContext.lookup(jndiName);
+      }
+      finally {
+        initialContext.close();
+      }
     }
+    catch (NamingException e) {
+      throw new WireException("failed to retrieve named object: " + jndiName, e);
+    }
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml	2010-06-22 16:55:56 UTC (rev 6428)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml	2010-06-22 17:57:45 UTC (rev 6429)
@@ -33,8 +33,7 @@
 Task "${task.name}" has been assigned to you.
 ${task.description}
 
-Sent by JBoss jBPM
-]]></text>
+Sent by jBPM]]></text>
     </mail-template>
   
     <mail-template name='task-reminder'>
@@ -44,8 +43,7 @@
 Do not forget about task "${task.name}".
 ${task.description}
 
-Sent by JBoss jBPM
-]]></text>
+Sent by jBPM]]></text>
     </mail-template>
   
   </process-engine-context>

Modified: 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/MailSessionWireTest.java	2010-06-22 16:55:56 UTC (rev 6428)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java	2010-06-22 17:57:45 UTC (rev 6429)
@@ -27,30 +27,34 @@
 
 import javax.mail.Authenticator;
 import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 
 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;
 
+import com.mockrunner.ejb.JNDIUtil;
+
 /**
  * @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>");
+    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();
@@ -71,55 +75,62 @@
         + "    <mail-server />"
         + "  </mail-session>"
         + "</objects>");
-      fail("expected wire context creation to puke");
+      fail("expected mail session binding to complain");
     }
     catch (JbpmException e) {
       // session properties are mandatory
     }
   }
 
-  public static class MyAuthenticator extends Authenticator {
+  public static class BasicAuthenticator extends Authenticator {
+
+    String userName;
+    String password;
+
     @Override
     protected PasswordAuthentication getPasswordAuthentication() {
-      return new PasswordAuthentication("aguizar", "wontsay");
+      return new PasswordAuthentication(userName, password);
     }
   }
 
   public void testAuthenticator() {
-    WireContext wireContext =
-        createWireContext("<objects>" +
-          "  <mail-session>" +
-          "    <mail-server>" +
-          "      <session-properties />" +
-          "      <authenticator class='" +
-          MyAuthenticator.class.getName() +
-          "' />" +
-          "    </mail-server>" +
-          "  </mail-session>" +
-          "</objects>");
+    WireContext wireContext = createWireContext("<objects>"
+      + "  <mail-session>"
+      + "    <mail-server>"
+      + "      <session-properties />"
+      + "      <authenticator class='"
+      + BasicAuthenticator.class.getName()
+      + "'>"
+      + "        <field name='userName'><string value='aguizar'/></field>"
+      + "        <field name='password'><string value='wontsay'/></field>"
+      + "      </authenticator>"
+      + "    </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());
+    BasicAuthenticator authenticator = (BasicAuthenticator) mailServer.getAuthenticator();
+    assertEquals("aguizar", authenticator.userName);
+    assertEquals("wontsay", authenticator.password);
   }
 
   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>");
+    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();
@@ -141,14 +152,13 @@
   }
 
   public void testNoAddressFilter() {
-    WireContext wireContext =
-        createWireContext("<objects>"
-          + "  <mail-session>"
-          + "    <mail-server>"
-          + "      <session-properties />"
-          + "    </mail-server>"
-          + "  </mail-session>"
-          + "</objects>");
+    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();
@@ -160,23 +170,46 @@
   }
 
   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>");
+    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());
   }
+
+  public void testJndiName() throws NamingException {
+    JNDIUtil.initMockContextFactory();
+    try {
+      Session session = Session.getInstance(new Properties());
+      new InitialContext().bind("java:comp/env/mail/smtp", session);
+
+      WireContext wireContext = createWireContext("<objects>"
+        + "  <mail-session>"
+        + "    <mail-server session-jndi='java:comp/env/mail/smtp' />"
+        + "  </mail-session>"
+        + "</objects>");
+
+      MailSessionImpl mailSession = wireContext.get(MailSessionImpl.class);
+      List<MailServer> mailServers = mailSession.getMailServers();
+      assertEquals(1, mailServers.size());
+
+      MailServer mailServer = mailServers.get(0);
+      assertSame(session, mailServer.getMailSession());
+    }
+    finally {
+      JNDIUtil.resetMockContextFactory();
+    }
+  }
 }

Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml	2010-06-22 16:55:56 UTC (rev 6428)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml	2010-06-22 17:57:45 UTC (rev 6429)
@@ -2640,17 +2640,7 @@
   &lt;/mail&gt;
   &lt;state name=&quot;end&quot;/&gt;
 &lt;/process&gt;</programlisting>
-
-      <para>The default configuration after installation includes a 
-      	<literal>jbpm.mail.properties</literal> file specifying the SMTP host 
-      	that jBPM employs to send mail. To use a mail server other than the
-        local host, set the <literal>mail.smtp.host</literal> property in the
-        mail properties file.</para>
-
-      <para>Refer to the Developers Guide for (unsupported) advanced mail 
-        configuration and usage.</para>
     </section>
-
   </section>
 
   <!-- ##################################################################### -->

Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch09-Configuration.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch09-Configuration.xml	2010-06-22 16:55:56 UTC (rev 6428)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch09-Configuration.xml	2010-06-22 17:57:45 UTC (rev 6429)
@@ -4,12 +4,12 @@
   <section>
     <title>Business calendar</title>
     <para>To customize the business calendar configuration,
-    remove the import of the default business calendar configuration
-    and replace it with your customized calendar configuration. E.g.
+      remove the default business calendar configuration import
+      and replace it with the custom values.
     </para>
     <programlisting>&lt;jbpm-configuration&gt;
     
-  &lt;import resource=&quot;jbpm.default.cfg.xml&quot; /&gt;
+  &lt;import resource=&quot;jbpm.businesscalendar.cfg.xml&quot; /&gt;
   ...
 
   &lt;process-engine-context&gt;
@@ -24,14 +24,12 @@
   &lt;/process-engine-context&gt;
 
 &lt;/jbpm-configuration&gt;</programlisting>
-    
   </section>
   
   <section>
-  
     <title>Console</title>
     <para>By default the server host and port of the console
-    webapplication are respectively <literal>localhost</literal>
+    web app are respectively <literal>localhost</literal>
     and <literal>8080</literal>. It is not hard to imagine 
     situations where it is needed to change those defaults.
     Hence they are made configurable. To customize,
@@ -47,13 +45,47 @@
   &lt;/process-engine-context&gt;
 
 &lt;/jbpm-configuration&gt;</programlisting>
-
   </section>
   
   <section>
     <title>Email</title>
-    <para>TODO document supported config customization 
-    of the jbpm.mail.properties</para>
+    <para>The default configuration looks for a <literal>jbpm.mail.properties</literal>
+      classpath resource containing <ulink 
+      url="http://java.sun.com/products/javamail/javadocs/">JavaMail properties</ulink>.
+      To send mail through a server other than local host, set the 
+      <literal>mail.smtp.host</literal> property in the mail properties file.</para>
+
+    <programlisting><![CDATA[mail.smtp.host=localhost
+mail.smtp.port=25
+mail.from=noreply at jbpm.org]]></programlisting>
+
+    <para>If the SMTP server requires authentication, the application can supply a
+      custom authenticator in the configuration file.</para>
+
+    <programlisting><![CDATA[<mail-session>
+  <mail-server>
+    <session-properties resource="jbpm.mail.properties" />
+    <authenticator class='BasicAuthenticator'>
+      <field name='userName'><string value='aguizar'/></field>
+      <field name='password'><string value='wontsay'/></field>
+    </authenticator>
+  </mail-server>
+</mail-session>]]></programlisting>
+
+    <para>In Java EE environments it is often the case that a mail session is already
+      configured and bound to JNDI. To employ such a session, specify its JNDI name in
+      the configuration file.</para>
+
+    <programlisting><![CDATA[<mail-session>
+  <mail-server session-jndi='java:comp/env/mail/smtp' />
+</mail-session>]]></programlisting>
+
+    <important><para>If present, the session JNDI name has precedence over the session
+      properties and the authenticator. The combined absence of session-properties
+      and session-jndi constitutes an error.</para></important>
+
+    <para>Refer to the <ulink
+      url="http://docs.jboss.com/jbpm/v4/devguide/html_single/#mailsupport">Developer
+      Guide</ulink> for advanced, yet unsupported, email settings.</para>
   </section>  
-
 </chapter>



More information about the jbpm-commits mailing list