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

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Dec 17 12:09:16 EST 2009


Author: tom.baeyens at jboss.com
Date: 2009-12-17 12:09:15 -0500 (Thu, 17 Dec 2009)
New Revision: 5979

Added:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionsBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java
Removed:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java
Modified:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ConfigurationParser.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml
   jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/historysessionchain/jbpm.cfg.xml
Log:
refactoring and fixing history session chaining

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ConfigurationParser.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ConfigurationParser.java	2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ConfigurationParser.java	2009-12-17 17:09:15 UTC (rev 5979)
@@ -86,6 +86,7 @@
         Parse importParse = createParse()
           .setResource(resource)
           .contextStackPush(configuration)
+          .propagateContexMap(parse)
           .execute();
         
         parse.addProblems(importParse.getProblems());

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java	2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java	2009-12-17 17:09:15 UTC (rev 5979)
@@ -22,8 +22,6 @@
 package org.jbpm.pvm.internal.history;
 
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
 
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
@@ -59,23 +57,10 @@
     if (environment!=null) {
       
       HistorySession historySession = environment.get(HistorySession.class);
-      HistorySessionChain historySessionChain = environment.get(HistorySessionChain.class);
-      
-      // Merge default history session (if defined) and the history session chain (if defined)
-      List<HistorySession> historySessions = new ArrayList<HistorySession>();
-      if (historySessionChain != null) {
-        historySessions.addAll(historySessionChain.getHistorySessionDelegates());
-      }
-      if (historySession != null) {
-        historySessions.add(historySession);
-      }
-      
-      // Delegate history event to all defined history sessions
-      for (HistorySession hs : historySessions) {
+      if (historySession!=null) {
         historyEvent.setExecution(execution);
-        hs.process(historyEvent);        
+        historySession.process(historyEvent);        
       }
-      
     }
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java	2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java	2009-12-17 17:09:15 UTC (rev 5979)
@@ -32,20 +32,15 @@
  */
 public class HistorySessionChain implements HistorySession {
 
-  protected List<HistorySession> delegates = new ArrayList<HistorySession>();
+  protected List<HistorySession> historySessions = new ArrayList<HistorySession>();
 
+  public HistorySessionChain(List<HistorySession> historySessions) {
+    this.historySessions = historySessions;
+  }
+
   public void process(HistoryEvent historyEvent) {
-    for (HistorySession delegate: delegates) {
-      delegate.process(historyEvent);
+    for (HistorySession historySession: historySessions) {
+      historySession.process(historyEvent);
     }
   }
-
-  public void addLogSession(HistorySession historySession) {
-    delegates.add(historySession);
-  }
-  
-  public List<HistorySession> getHistorySessionDelegates() {
-    return delegates;
-  }
-  
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java	2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java	2009-12-17 17:09:15 UTC (rev 5979)
@@ -3,8 +3,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.jbpm.api.JbpmException;
-import org.jbpm.pvm.internal.util.ReflectUtil;
 import org.jbpm.pvm.internal.util.XmlUtil;
 import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.descriptor.CollectionDescriptor;

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java	2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java	2009-12-17 17:09:15 UTC (rev 5979)
@@ -1,44 +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.wire.binding;
-
-import org.jbpm.pvm.internal.history.HistorySessionImpl;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HistorySessionBinding extends WireDescriptorBinding {
-
-  public HistorySessionBinding() {
-    super("history-session");
-  }
-
-  public Object parse(Element element, Parse parse, Parser parser) {
-    return new ObjectDescriptor(HistorySessionImpl.class);
-  }
-
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionsBinding.java (from rev 5978, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionsBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionsBinding.java	2009-12-17 17:09:15 UTC (rev 5979)
@@ -0,0 +1,55 @@
+/*
+ * 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 org.jbpm.pvm.internal.wire.descriptor.CollectionDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.HistorySessionDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistorySessionsBinding extends WireDescriptorBinding {
+  
+  private static final String KEY_HISTORY_SESSIONS_DESCRIPTOR = "historySessionsDescriptor";
+  private static final ListBinding LIST_BINDING = new ListBinding();
+
+  public HistorySessionsBinding() {
+    super("history-sessions");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    HistorySessionDescriptor historySessionsDescriptor = (HistorySessionDescriptor) parse.contextMapGet(KEY_HISTORY_SESSIONS_DESCRIPTOR); 
+    if (historySessionsDescriptor==null) {
+      historySessionsDescriptor = new HistorySessionDescriptor();
+      parse.contextMapPut(KEY_HISTORY_SESSIONS_DESCRIPTOR, historySessionsDescriptor);
+    }
+    
+    CollectionDescriptor listDescriptor = (CollectionDescriptor) LIST_BINDING.parse(element, parse, parser);
+    historySessionsDescriptor.add(listDescriptor);
+
+    return historySessionsDescriptor;
+  }
+
+}

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java	2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java	2009-12-17 17:09:15 UTC (rev 5979)
@@ -1,5 +1,6 @@
 package org.jbpm.pvm.internal.wire.descriptor;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -80,6 +81,15 @@
     }
   }
 
+  public void addValueDescriptors(List<Descriptor> otherValueDescriptors) {
+    if (valueDescriptors==null) {
+      valueDescriptors = new ArrayList<Descriptor>();
+    }
+    if (otherValueDescriptors!=null) {
+      valueDescriptors.addAll(otherValueDescriptors);
+    }
+  }
+
   public String getClassName() {
     return className;
   }

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java	2009-12-17 17:09:15 UTC (rev 5979)
@@ -0,0 +1,56 @@
+/*
+ * 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.List;
+
+import org.jbpm.pvm.internal.history.HistorySession;
+import org.jbpm.pvm.internal.history.HistorySessionChain;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistorySessionDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  
+  CollectionDescriptor listDescriptor = new ListDescriptor();
+
+  public Object construct(WireContext wireContext) {
+    List<HistorySession> historySessions = (List<HistorySession>) WireContext.create(listDescriptor);
+    if (historySessions.size()==1) {
+      return historySessions.get(0);
+    } 
+    return new HistorySessionChain(historySessions);
+  }
+
+  public void add(CollectionDescriptor otherListDescriptor) {
+    this.listDescriptor.addValueDescriptors(otherListDescriptor.getValueDescriptors());
+  }
+  
+  public Class<?> getType(WireDefinition wireDefinition) {
+    return HistorySession.class;
+  }
+}


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

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-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java	2009-12-17 17:09:15 UTC (rev 5979)
@@ -215,7 +215,19 @@
     }
     return this;
   }
+  
+  public Parse propagateContexMap(Parse parse) {
+    if (parse.contextMap==null) {
+      parse.contextMap = new HashMap<String, Object>();
+    }
+    if (this.contextMap!=null) {
+      parse.contextMap.putAll(this.contextMap);
+    }
+    this.contextMap = parse.contextMap;
+    return this;
+  }
 
+
   // contex stack /////////////////////////////////////////////////////////////
 
   /** push a contextual object on the stack of this parse. */

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml	2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml	2009-12-17 17:09:15 UTC (rev 5979)
@@ -54,12 +54,17 @@
     
     <message-session />
     <timer-session />
-    <history-session />
+    
+    <history-sessions>
+      <object class="org.jbpm.pvm.internal.history.HistorySessionImpl" />
+    </history-sessions>
+    
     <mail-session>
       <mail-server>
         <session-properties resource="jbpm.mail.properties" />
       </mail-server>
     </mail-session>
+
   </transaction-context>
 
 </jbpm-configuration>

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml	2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml	2009-12-17 17:09:15 UTC (rev 5979)
@@ -49,8 +49,7 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.DbSessionBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.MessageSessionBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.TimerSessionBinding" />
-  <binding class="org.jbpm.pvm.internal.wire.binding.HistorySessionBinding" />
-  <binding class="org.jbpm.pvm.internal.wire.binding.HistorySessionChainBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.HistorySessionsBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.IdentitySessionBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionFactoryBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionBinding" />

Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/historysessionchain/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/historysessionchain/jbpm.cfg.xml	2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/historysessionchain/jbpm.cfg.xml	2009-12-17 17:09:15 UTC (rev 5979)
@@ -10,10 +10,10 @@
   <import resource="jbpm.identity.cfg.xml" />
   
   <transaction-context>
-    <history-session-chain>
+    <history-sessions>
       <object class="org.jbpm.test.historysessionchain.DummyProcessStartListener" />
       <object class="org.jbpm.test.historysessionchain.DummyProcessEndListener" />
-    </history-session-chain>
+    </history-sessions>
   </transaction-context>
 
 </jbpm-configuration>



More information about the jbpm-commits mailing list