[jbpm-commits] JBoss JBPM SVN: r4810 - in jbpm4/trunk: modules/distro/src/main/files/jboss and 10 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu May 14 08:19:13 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-05-14 08:19:13 -0400 (Thu, 14 May 2009)
New Revision: 4810

Added:
   jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml
   jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.mail.properties
   jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.mail.properties
   jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.mail.templates.examples.xml
   jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplateMap.java
Removed:
   jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml
   jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.xml
Modified:
   jbpm4/trunk/modules/distro/src/main/files/examples/build.xml
   jbpm4/trunk/modules/distro/src/main/files/jboss/build.xml
   jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.cfg.xml
   jbpm4/trunk/modules/examples/pom.xml
   jbpm4/trunk/modules/examples/src/test/resources/jbpm.cfg.xml
   jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailTemplateWireTest.java
   jbpm4/trunk/qa/build.xml
Log:
JBPM-2251 separate specific integration test suite deployments

Modified: jbpm4/trunk/modules/distro/src/main/files/examples/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/examples/build.xml	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/modules/distro/src/main/files/examples/build.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -25,10 +25,8 @@
     <echo message="jbpm.version....... ${jbpm.version}" />
     <echo message="jbpm.home.......... ${jbpm.home}" />
   </target>
-  
-  <!-- ### DEPLOY EXAMPLE BUSINESS ARCHIVES ############################### -->
-  <target name="deploy.examples" 
-          description="deploys all the example processes">
+	
+	<target name="jbpm.libs.path">
     <path id="jbpm.libs.incl.dependencies">
       <pathelement location="${jbpm.home}/examples/target/classes" />
       <fileset dir="${jbpm.home}">
@@ -36,15 +34,13 @@
       </fileset>
       <fileset dir="${jbpm.home}/lib" />
     </path>
-    <mkdir dir="${jbpm.home}/examples/target/classes" />
-    <javac srcdir="${jbpm.home}/examples/src"
-           destdir="${jbpm.home}/examples/target/classes"
-           classpathref="jbpm.libs.incl.dependencies" />
-    <copy todir="${jbpm.home}/examples/target/classes">
-      <fileset dir="${jbpm.home}/examples/src">
-        <exclude name="**/*.java" />
-      </fileset>
-    </copy>
+	</target>
+  
+  <!-- ### DEPLOY EXAMPLE BUSINESS ARCHIVES ############################### -->
+  <target name="deploy.examples" 
+          description="deploys all the example processes"
+  	      depends="jbpm.libs.path">
+    <mkdir dir="${jbpm.home}/examples/target" />
   	<copy file="${jbpm.home}/db/hibernate.cfg/${database}.hibernate.cfg.xml"
   	      tofile="${jbpm.home}/examples/target/classes/jbpm.hibernate.cfg.xml" 
   		    overwrite="true">
@@ -76,5 +72,22 @@
            classpathref="jbpm.libs.incl.dependencies" />
     <jbpm-deploy file="${jbpm.home}/examples/target/examples.bar" />
   </target>
+	
+	<target name="examples.jar" depends="jbpm.libs.path">
+    <mkdir dir="${jbpm.home}/examples/target/classes" />
+    <javac srcdir="${jbpm.home}/examples/src"
+           destdir="${jbpm.home}/examples/target/classes"
+           classpathref="jbpm.libs.incl.dependencies" />
+    <copy todir="${jbpm.home}/examples/target/classes">
+      <fileset dir="${jbpm.home}/examples/src">
+        <exclude name="**/*.java" />
+      </fileset>
+    </copy>
+    <jar destfile="${jbpm.home}/examples/target/examples.jar" >
+      <fileset dir="${jbpm.home}/examples/target/classes">
+        <include name="**/*.class" />
+      </fileset>
+    </jar>
+	</target>
 
 </project>

Modified: jbpm4/trunk/modules/distro/src/main/files/jboss/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/jboss/build.xml	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/modules/distro/src/main/files/jboss/build.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -43,6 +43,7 @@
       <equals arg1="${jboss.version}" arg2="5.0.0.GA" />
       <equals arg1="${jboss.version}" arg2="5.0.1.GA" />
       <equals arg1="${jboss.version}" arg2="5.1.0.GA" />
+      <equals arg1="${jboss.version}" arg2="5.1.0.CR1" />
     </or>
   </condition>
 
@@ -183,7 +184,18 @@
       </fileset>
     </copy>
   </target>
-  
+	
+  <!-- ### THE JBOSS INTEGRATION TEST SPECIFICS ####################### -->
+  <target name="internal.install.jbpm.into.jboss.integrationtestspecifics">
+    <copy todir="${jboss.server.config.dir}/deploy/jbpm/jbpm-service.sar" overwrite="true">
+       <fileset dir="${jbpm.home}/jboss/jbpm.cfg.integration.tests" />
+    </copy>
+    <ant antfile="${jbpm.home}/examples/build.xml" target="examples.jar" />
+  	<mkdir dir="${jboss.server.config.dir}/deploy/jbpm/userlibs" />
+    <copy file="${jbpm.home}/examples/target/examples.jar"
+    	    todir="${jboss.server.config.dir}/deploy/jbpm/userlibs" />
+	</target>
+
   <!-- ### THE HSQLDB SPECIFIC PART ####################################### -->
   <target name="internal.install.jbpm.into.jboss.db.hsqldb" />
 

Deleted: jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<jbpm-configuration>
-
-  <import resource="jbpm.default.cfg.xml" />
-  <import resource="jbpm.tx.jta.cfg.xml" />
-  <import resource="jbpm.jpdl.cfg.xml" />
-  <import resource="jbpm.identity.cfg.xml" />
-
-</jbpm-configuration>

Added: jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml	                        (rev 0)
+++ jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+  <import resource="jbpm.default.cfg.xml" />
+  <import resource="jbpm.tx.jta.cfg.xml" />
+  <import resource="jbpm.jpdl.cfg.xml" />
+  <import resource="jbpm.identity.cfg.xml" />
+
+  <import resource="jbpm.jobexecutor.cfg.xml" />
+
+</jbpm-configuration>

Added: jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.mail.properties
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.mail.properties	                        (rev 0)
+++ jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.mail.properties	2009-05-14 12:19:13 UTC (rev 4810)
@@ -0,0 +1,3 @@
+mail.smtp.host=localhost
+mail.smtp.port=25
+mail.from=noreply at jbpm.org


Property changes on: jbpm4/trunk/modules/distro/src/main/files/jboss/config.common/deploy/jbpm/jbpm-service.sar/jbpm.mail.properties
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.cfg.xml	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.cfg.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -7,18 +7,10 @@
   <import resource="jbpm.jpdl.cfg.xml" />
   <import resource="jbpm.identity.cfg.xml" />
 
+  <import resource="jbpm.mail.templates.examples.xml" />
+
   <!-- Job executor is excluded for running the example test cases.
        To enable timers and messages in production use, this should be included.
   import resource="jbpm.jobexecutor.cfg.xml" / -->
 
-  <process-engine-context>
-
-    <mail-template name="MemoTemplate">
-      <to addresses='dilbert at office, alice at work, dogbert at house' />
-      <subject>bureaucracy</subject>
-      <text>Order http://example.com/order/#{orderId} is stalled.</text>
-    </mail-template>
-
-  </process-engine-context>
-
 </jbpm-configuration>

Added: jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.mail.properties
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.mail.properties	                        (rev 0)
+++ jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.mail.properties	2009-05-14 12:19:13 UTC (rev 4810)
@@ -0,0 +1,3 @@
+mail.smtp.host	localhost
+mail.smtp.port	2525
+mail.from		noreply at jbpm.org
\ No newline at end of file


Property changes on: jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.mail.properties
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.mail.templates.examples.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.mail.templates.examples.xml	                        (rev 0)
+++ jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.mail.templates.examples.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+  <process-engine-context>
+
+    <mail-template name="rectify template">
+      <to addresses="${addressee}" />
+      <cc users="bb" groups="innerparty" />
+      <bcc groups="thinkpol" />
+      <subject>rectify ${newspaper}</subject>
+      <text>${newspaper} ${date} ${details}</text>
+    </mail-template>
+
+  </process-engine-context>
+
+</jbpm-configuration>
\ No newline at end of file


Property changes on: jbpm4/trunk/modules/distro/src/main/files/jboss/jbpm.cfg.integration.tests/jbpm.mail.templates.examples.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: jbpm4/trunk/modules/examples/pom.xml
===================================================================
--- jbpm4/trunk/modules/examples/pom.xml	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/modules/examples/pom.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -177,21 +177,12 @@
                 <!-- https://jira.jboss.org/jira/browse/JBPM-2147 -->
                 <!-- https://jira.jboss.org/jira/browse/JBPM-2200 -->
                 <exclude>org/jbpm/examples/task/swimlane/TaskSwimlaneTest.java</exclude>
-                <exclude>org/jbpm/examples/task/candidates/TaskCandidatesTest.java</exclude>
                 <exclude>org/jbpm/examples/concurrency/graphbased/ConcurrencyGraphBasedTest.java</exclude>
-                <exclude>org/jbpm/examples/timer/repeat/TimerRepeatTest.java</exclude>
+                <exclude>org/jbpm/examples/task/candidates/TaskCandidatesTest.java</exclude>
                 <exclude>org/jbpm/examples/esb/EsbTest.java</exclude>
-                <exclude>org/jbpm/examples/script/text/ScriptTextTest.java</exclude>
-                <exclude>org/jbpm/examples/decision/handler/DecisionHandlerTest.java</exclude>
                 <exclude>org/jbpm/examples/mail/template/TemplateMailTest.java</exclude>
-                <exclude>org/jbpm/examples/script/expression/ScriptExpressionTest.java</exclude>
-                <exclude>org/jbpm/examples/task/assignee/TaskAssigneeTest.java</exclude>
                 <exclude>org/jbpm/examples/mail/inline/InlineMailTest.java</exclude>
-                <exclude>org/jbpm/examples/mail/template/TemplateMailTest.java</exclude>
                 <exclude>org/jbpm/examples/eventlistener/EventListenerTest.java</exclude>
-                <exclude>org/jbpm/examples/timer/event/TimerEventTest.java</exclude>
-                <exclude>org/jbpm/examples/task/assignmenthandler/TaskAssignmentHandlerTest.java</exclude>
-                <exclude>**/JavaInstantiateTest.java</exclude>
               </excludes>
             </configuration>
           </plugin>

Modified: jbpm4/trunk/modules/examples/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/jbpm.cfg.xml	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/modules/examples/src/test/resources/jbpm.cfg.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -13,6 +13,6 @@
   <import resource="jbpm.jobexecutor.cfg.xml" />
   -->
 
-  <import resource="jbpm.mail.templates.xml" />
+  <import resource="jbpm.mail.templates.examples.xml" />
 
 </jbpm-configuration>

Copied: jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml (from rev 4809, jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.xml)
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+  <process-engine-context>
+
+    <mail-template name="rectify template">
+      <to addresses="${addressee}" />
+      <cc users="bb" groups="innerparty" />
+      <bcc groups="thinkpol" />
+      <subject>rectify ${newspaper}</subject>
+      <text>${newspaper} ${date} ${details}</text>
+    </mail-template>
+
+  </process-engine-context>
+
+</jbpm-configuration>
\ No newline at end of file

Deleted: jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.xml	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<jbpm-configuration>
-
-  <process-engine-context>
-
-    <mail-template name="rectify template">
-      <to addresses="${addressee}" />
-      <cc users="bb" groups="innerparty" />
-      <bcc groups="thinkpol" />
-      <subject>rectify ${newspaper}</subject>
-      <text>${newspaper} ${date} ${details}</text>
-    </mail-template>
-
-  </process-engine-context>
-
-</jbpm-configuration>
\ No newline at end of file

Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java	2009-05-14 12:19:13 UTC (rev 4810)
@@ -24,12 +24,14 @@
 import org.jbpm.api.env.Environment;
 import org.jbpm.pvm.internal.email.impl.MailProducerImpl;
 import org.jbpm.pvm.internal.email.impl.MailTemplate;
+import org.jbpm.pvm.internal.email.impl.MailTemplateMap;
 import org.jbpm.pvm.internal.email.spi.MailProducer;
 import org.jbpm.pvm.internal.util.XmlUtil;
 import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.WireContext;
 import org.jbpm.pvm.internal.wire.binding.MailTemplateBinding;
 import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
 import org.w3c.dom.Element;
@@ -69,19 +71,18 @@
     String templateName = XmlUtil.attribute(element, "template");
     if (templateName != null) {
       // load template from configuration
-      Object template = Environment.getCurrent().get(templateName);
-      if (template instanceof MailTemplate) {
-        return (MailTemplate) template;
+      MailTemplateMap mailTemplateMap = Environment.getFromCurrent(MailTemplateMap.class);
+      MailTemplate template = mailTemplateMap.getTemplate(templateName);
+      if (template==null) {
+        parse.addProblem("mail-template "+templateName+" is not configured", element);
       }
-      else {
-        parse.addProblem("mail template not found: " + templateName);
-      }
-    }
-    else {
-      // parse inline template
-      Descriptor templateDescriptor = (Descriptor) templateBinding.parse(element, parse, parser);
-      return (MailTemplate) WireContext.create(templateDescriptor);
-    }
-    return null;
+      return template;
+    } 
+
+    // parse inline template
+    ProvidedObjectDescriptor templateDescriptor = (ProvidedObjectDescriptor) templateBinding.parse(element, parse, parser);
+    MailTemplateMap mailTemplateMap = (MailTemplateMap) templateDescriptor.getProvidedObject();
+    String name = XmlUtil.attribute(element, "name");
+    return mailTemplateMap.getTemplate(name);
   }
 }

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplateMap.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplateMap.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplateMap.java	2009-05-14 12:19:13 UTC (rev 4810)
@@ -0,0 +1,44 @@
+/*
+ * 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.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Tom Baeyens
+ */
+public class MailTemplateMap implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  Map<String, MailTemplate> templates = new HashMap<String, MailTemplate>();
+  
+  public void addTemplate(String templateName, MailTemplate template) {
+    templates.put(templateName, template);
+  }
+  
+  public MailTemplate getTemplate(String templateName) {
+    return templates.get(templateName);
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplateMap.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: 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/binding/MailTemplateBinding.java	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java	2009-05-14 12:19:13 UTC (rev 4810)
@@ -24,14 +24,13 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.jbpm.pvm.internal.email.impl.AddressTemplate;
 import org.jbpm.pvm.internal.email.impl.AttachmentTemplate;
 import org.jbpm.pvm.internal.email.impl.MailTemplate;
-import org.jbpm.pvm.internal.email.impl.AddressTemplate;
+import org.jbpm.pvm.internal.email.impl.MailTemplateMap;
 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.WireDefinition;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
 import org.w3c.dom.DocumentFragment;
@@ -48,115 +47,84 @@
   }
 
   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.setName(name);
+    
+    // MailTemplateMap is added to the WireDescriptor with a ProvidedObjectDescriptor
+    // The MailTemplateMap descriptor is lazy initialized by this binding 
+    // mail-templates will add a MailTemplate to the MailTemplateMap 
+    
+    ProvidedObjectDescriptor mailTemplateMapDescriptor = null; 
+    MailTemplateMap mailTemplateMap = null;
+    
+    WireDefinition wireDefinition = parse.findObject(WireDefinition.class);
+    String templateMapDescriptorName = (wireDefinition!=null ? wireDefinition.getDescriptorName(MailTemplateMap.class) : null);
+    if (templateMapDescriptorName!=null) {
+      mailTemplateMapDescriptor = (ProvidedObjectDescriptor) wireDefinition.getDescriptor(templateMapDescriptorName);
+      mailTemplateMap = (MailTemplateMap) mailTemplateMapDescriptor.getProvidedObject();
+      mailTemplateMapDescriptor = null; // setting it to null so that the wire parser won't be add it to the wiredefinition a second time 
+    } else {
+      mailTemplateMap = new MailTemplateMap();
+      mailTemplateMapDescriptor = new ProvidedObjectDescriptor(mailTemplateMap, true);
     }
-    else {
-      parse.addProblem("template has no name");
-    }
-    // language
-    String language = XmlUtil.attribute(element, "language");
-    if (language != null) {
-      templateDescriptor.addInjection("language", new StringDescriptor(language));
-    }
-    // from
-    Element fromElement = XmlUtil.element(element, "from");
-    if (fromElement != null) {
-      Descriptor fromDescriptor = parseRecipientTemplate(fromElement, parse, parser);
-      templateDescriptor.addInjection("from", fromDescriptor);
-    }
-    // to
-    Element toElement = XmlUtil.element(element, "to");
-    if (toElement != null) {
-      Descriptor toDescriptor = parseRecipientTemplate(toElement, parse, parser);
-      templateDescriptor.addPropertyInjection("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);
-      templateDescriptor.addPropertyInjection("cc", ccDescriptor);
-    }
-    // bcc
-    Element bccElement = XmlUtil.element(element, "bcc");
-    if (bccElement != null) {
-      Descriptor bccDescriptor = parseRecipientTemplate(bccElement, parse, parser);
-      templateDescriptor.addPropertyInjection("bcc", bccDescriptor);
-    }
-    // subject
+
+    // create the mail template and add it to the mailTemplateMap
+    MailTemplate mailTemplate = new MailTemplate();
+    String templateName = XmlUtil.attribute(element, "name", true, parse);
+    mailTemplateMap.addTemplate(templateName, mailTemplate);
+    
+    mailTemplate.setLanguage(XmlUtil.attribute(element, "language"));
+    mailTemplate.setFrom(parseRecipientTemplate(element, "from", parse, parser));
+    mailTemplate.setTo(parseRecipientTemplate(element, "to", parse, parser));
+    mailTemplate.setCc(parseRecipientTemplate(element, "cc", parse, parser));
+    mailTemplate.setBcc(parseRecipientTemplate(element, "bcc", parse, parser));
+
     Element subjectElement = XmlUtil.element(element, "subject");
-    if (subjectElement != null) {
-      StringDescriptor subjectDescriptor =
-          new StringDescriptor(XmlUtil.getContentText(subjectElement));
-      templateDescriptor.addInjection("subject", subjectDescriptor);
+    if (subjectElement!=null) {
+      mailTemplate.setSubject(XmlUtil.getContentText(subjectElement));
     }
-    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);
+    if (textElement!=null) {
+      mailTemplate.setText(XmlUtil.getContentText(textElement));
     }
-    // html
+    
     Element htmlElement = XmlUtil.element(element, "html");
-    if (htmlElement != null) {
+    if (htmlElement!=null) {
       // extract child nodes from html element
       DocumentFragment fragment = htmlElement.getOwnerDocument().createDocumentFragment();
       for (Node child = htmlElement.getFirstChild(), next; child != null; child = next) {
         next = child.getNextSibling();
         fragment.appendChild(child);
       }
-      StringDescriptor htmlDescriptor = new StringDescriptor(XmlUtil.toString(fragment));
-      templateDescriptor.addInjection("html", htmlDescriptor);
+      mailTemplate.setHtml(XmlUtil.toString(fragment));
     }
+    
     // attachments
     Element attachmentsElement = XmlUtil.element(element, "attachments");
     if (attachmentsElement != null) {
-      List<Descriptor> attachmentDescriptors = new ArrayList<Descriptor>();
+      List<AttachmentTemplate> attachmentTemplates = new ArrayList<AttachmentTemplate>();
       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));
+        AttachmentTemplate attachmentTemplate = new AttachmentTemplate();
+        mailTemplate.addAttachmentTemplate(attachmentTemplate);
+        
+        attachmentTemplate.setUrl(XmlUtil.attribute(attachmentElement, "url"));
+        attachmentTemplate.setResource(XmlUtil.attribute(attachmentElement, "resource"));
+        attachmentTemplate.setFile(XmlUtil.attribute(attachmentElement, "file"));
       }
-
-      ListDescriptor attachmentsDescriptor = new ListDescriptor();
-      attachmentsDescriptor.setValueDescriptors(attachmentDescriptors);
-      templateDescriptor.addInjection("attachmentTemplates", attachmentsDescriptor);
     }
-    return templateDescriptor;
+    return mailTemplateMapDescriptor;
   }
 
-  protected Descriptor parseRecipientTemplate(Element element, Parse parse, Parser parser) {
-    ObjectDescriptor recipientDescriptor = new ObjectDescriptor(AddressTemplate.class);
-
-    String addresses = XmlUtil.attribute(element, "addresses");
-    if (addresses != null)
-      recipientDescriptor.addInjection("addresses", new StringDescriptor(addresses));
-
-    String users = XmlUtil.attribute(element, "users");
-    if (users != null) recipientDescriptor.addInjection("users", new StringDescriptor(users));
-
-    String groups = XmlUtil.attribute(element, "groups");
-    if (groups != null) recipientDescriptor.addInjection("groups", new StringDescriptor(groups));
-
-    return recipientDescriptor;
+  protected AddressTemplate parseRecipientTemplate(Element element, String tagName, Parse parse, Parser parser) {
+    AddressTemplate addressTemplate = null;
+    
+    Element recipientElement = XmlUtil.element(element, tagName);
+    if (recipientElement!=null) {
+      addressTemplate = new AddressTemplate();
+      
+      addressTemplate.setAddresses(XmlUtil.attribute(recipientElement, "addresses"));
+      addressTemplate.setUsers(XmlUtil.attribute(recipientElement, "users"));
+      addressTemplate.setGroups(XmlUtil.attribute(recipientElement, "groups"));
+    }
+    return addressTemplate;
   }
-
 }

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -40,6 +40,11 @@
       <friday    hours="9:00-12:00 and 12:30-17:00"/>
       <holiday period="01/07/2008 - 31/08/2008"/>
     </business-calendar>
+    
+    <!--mail-template name="TaskNotification"
+    -->
+    <!--mail-template name="TaskReminder"
+    -->
   
   </process-engine-context>
 

Modified: jbpm4/trunk/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	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailTemplateWireTest.java	2009-05-14 12:19:13 UTC (rev 4810)
@@ -25,6 +25,7 @@
 
 import org.jbpm.pvm.internal.email.impl.AttachmentTemplate;
 import org.jbpm.pvm.internal.email.impl.MailTemplate;
+import org.jbpm.pvm.internal.email.impl.MailTemplateMap;
 
 /**
  * @author Alejandro Guizar
@@ -40,8 +41,9 @@
             + "</mail-template>"
             + "</objects>");
 
-    Object template = wireContext.get("memo");
-    assertTrue(template instanceof MailTemplate);
+    MailTemplateMap mailTemplateMap = wireContext.get(MailTemplateMap.class);
+    assertNotNull(mailTemplateMap);
+    assertNotNull(mailTemplateMap.getTemplate("memo"));
   }
 
   public void testLanguage() {
@@ -53,7 +55,7 @@
             + "</mail-template>"
             + "</objects>");
 
-    MailTemplate template = wireContext.get(MailTemplate.class);
+    MailTemplate template = wireContext.get(MailTemplateMap.class).getTemplate("memo");
     assertEquals("juel", template.getLanguage());
   }
 
@@ -67,7 +69,7 @@
             + "</mail-template>"
             + "</objects>");
 
-    MailTemplate template = wireContext.get(MailTemplate.class);
+    MailTemplate template = wireContext.get(MailTemplateMap.class).getTemplate("memo");
     assertEquals("wacko at jbpm.org", template.getFrom().getAddresses());
   }
 
@@ -80,7 +82,7 @@
             + "</mail-template>"
             + "</objects>");
 
-    MailTemplate template = wireContext.get(MailTemplate.class);
+    MailTemplate template = wireContext.get(MailTemplateMap.class).getTemplate("memo");
     assertEquals("dilbert at office, alice at work, dogbert at house", template.getTo().getAddresses());
   }
 
@@ -94,7 +96,7 @@
             + "</mail-template>"
             + "</objects>");
 
-    MailTemplate template = wireContext.get(MailTemplate.class);
+    MailTemplate template = wireContext.get(MailTemplateMap.class).getTemplate("memo");
     assertEquals("theboss, hrpolicymaker", template.getCc().getUsers());
   }
 
@@ -108,7 +110,7 @@
             + "</mail-template>"
             + "</objects>");
 
-    MailTemplate template = wireContext.get(MailTemplate.class);
+    MailTemplate template = wireContext.get(MailTemplateMap.class).getTemplate("memo");
     assertEquals("thoughtpolice", template.getBcc().getGroups());
   }
 
@@ -121,7 +123,7 @@
             + "</mail-template>"
             + "</objects>");
 
-    MailTemplate template = wireContext.get(MailTemplate.class);
+    MailTemplate template = wireContext.get(MailTemplateMap.class).getTemplate("memo");
     assertEquals("bureaucracy", template.getSubject());
   }
 
@@ -135,7 +137,7 @@
             + "</mail-template>"
             + "</objects>");
 
-    MailTemplate template = wireContext.get(MailTemplate.class);
+    MailTemplate template = wireContext.get(MailTemplateMap.class).getTemplate("memo");
     assertEquals("plain text content", template.getText());
   }
 
@@ -149,7 +151,7 @@
             + "</mail-template>"
             + "</objects>");
 
-    MailTemplate template = wireContext.get(MailTemplate.class);
+    MailTemplate template = wireContext.get(MailTemplateMap.class).getTemplate("memo");
     assertEquals("<strong>rich</strong> content", template.getHtml());
   }
 
@@ -167,7 +169,7 @@
             + "</mail-template>"
             + "</objects>");
 
-    MailTemplate template = wireContext.get(MailTemplate.class);
+    MailTemplate template = wireContext.get(MailTemplateMap.class).getTemplate("memo");
     List<AttachmentTemplate> attachmentTemplates = template.getAttachmentTemplates();
     assertEquals(3, attachmentTemplates.size());
     // url

Modified: jbpm4/trunk/qa/build.xml
===================================================================
--- jbpm4/trunk/qa/build.xml	2009-05-13 20:34:25 UTC (rev 4809)
+++ jbpm4/trunk/qa/build.xml	2009-05-14 12:19:13 UTC (rev 4810)
@@ -49,6 +49,7 @@
 		      description="reinstalls jbpm, reinstalls jboss, installs jbpm into jboss, starts jboss and then creates the jbpm schema">
     <ant antfile="${jbpm.home}/jboss/build.xml" target="reinstall.jboss" />
     <ant antfile="${jbpm.home}/jboss/build.xml" target="install.jbpm.into.jboss" />
+    <ant antfile="${jbpm.home}/jboss/build.xml" target="internal.install.jbpm.into.jboss.integrationtestspecifics" />
     <ant antfile="${jbpm.home}/jboss/build.xml" target="start.jboss" />
     <ant antfile="${jbpm.home}/db/build.xml" target="create.jbpm.schema" />
 	</target>




More information about the jbpm-commits mailing list