[jbpm-commits] JBoss JBPM SVN: r4194 - in jbpm4/branches/tbaeyens/modules: pvm/src/main/java/org/jbpm/pvm/internal/model and 6 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Mar 8 08:20:30 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-03-08 08:20:29 -0400 (Sun, 08 Mar 2009)
New Revision: 4194

Added:
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SerializingCommandService.java
Modified:
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CommandServiceBinding.java
   jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.cfg.xml
Log:
work

Modified: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.cfg.xml	2009-03-08 01:18:45 UTC (rev 4193)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.cfg.xml	2009-03-08 12:20:29 UTC (rev 4194)
@@ -11,7 +11,7 @@
     <task-service />
     <identity-service />
 
-    <command-service>
+    <command-service serialize="true">
       <retry-interceptor />
       <environment-interceptor />
       <standard-transaction-interceptor />

Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java	2009-03-08 01:18:45 UTC (rev 4193)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java	2009-03-08 12:20:29 UTC (rev 4194)
@@ -21,6 +21,8 @@
  */
 package org.jbpm.pvm.internal.model;
 
+import java.io.ObjectStreamException;
+
 import javax.transaction.Status;
 import javax.transaction.Synchronization;
 
@@ -61,4 +63,10 @@
     pvmDbSession.deleteProcessInstance(processInstanceId, false);
     return null;
   }
+  
+  protected Object writeReplace() throws ObjectStreamException {
+    this.commandService = null;
+    return this;
+  }
+
 }

Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java	2009-03-08 01:18:45 UTC (rev 4193)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java	2009-03-08 12:20:29 UTC (rev 4194)
@@ -21,6 +21,8 @@
  */
 package org.jbpm.pvm.internal.query;
 
+import java.io.ObjectStreamException;
+
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.jbpm.cmd.Command;
@@ -95,4 +97,9 @@
       orderByClause += ", " + clause;
     }
   }
+  
+  protected Object writeReplace() throws ObjectStreamException {
+    this.commandService = null;
+    return this;
+  }
 }

Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java	2009-03-08 01:18:45 UTC (rev 4193)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java	2009-03-08 12:20:29 UTC (rev 4194)
@@ -23,14 +23,17 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
+import java.io.Serializable;
 
 import org.jbpm.JbpmException;
 
 /**
  * @author Tom Baeyens
  */
-public class ByteArrayStreamInput extends StreamInput {
+public class ByteArrayStreamInput extends StreamInput implements Serializable {
   
+  private static final long serialVersionUID = 1L;
+
   protected byte[] bytes;
   
   /** @throws JbpmException if bytes is null */

Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java	2009-03-08 01:18:45 UTC (rev 4193)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java	2009-03-08 12:20:29 UTC (rev 4194)
@@ -24,6 +24,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.ObjectStreamException;
 import java.io.Serializable;
 import java.net.URL;
 import java.util.ArrayList;
@@ -38,6 +39,7 @@
 import org.jbpm.Deployment;
 import org.jbpm.JbpmException;
 import org.jbpm.ProcessDefinition;
+import org.jbpm.env.Environment;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.stream.ByteArrayStreamInput;
 import org.jbpm.pvm.internal.stream.FileStreamInput;
@@ -405,4 +407,25 @@
     }
     return fileNames;
   }
+  
+  protected Object writeReplace() throws ObjectStreamException {
+    if (files!=null) {
+      Map<String, StreamInput> replacedFiles = new HashMap<String, StreamInput>();
+      for (Map.Entry<String, StreamInput> entry: files.entrySet()) {
+        byte[] bytes = IoUtil.readBytes(entry.getValue().openStream());
+        replacedFiles.put(entry.getKey(), new ByteArrayStreamInput(bytes));
+      }
+      files = replacedFiles;
+    }
+    
+    processServiceImpl = null;
+    
+    return this;
+  }
+  
+  protected Object readResolve() throws ObjectStreamException {
+    processServiceImpl = Environment.getFromCurrent(ProcessServiceImpl.class);
+    return this;
+  }
+
 }

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SerializingCommandService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SerializingCommandService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SerializingCommandService.java	2009-03-08 12:20:29 UTC (rev 4194)
@@ -0,0 +1,61 @@
+/*
+ * 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.svc;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.internal.log.Log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SerializingCommandService extends DefaultCommandService {
+  
+  private static final Log log = Log.getLog(SerializingCommandService.class.getName());
+
+  public <T> T execute(Command<T> command) {
+    log.info("serializing command "+command);
+    Command serializedCommand = (Command) serialize(command);
+    T returnValue = (T) super.execute(serializedCommand);
+    T serializedReturnValue = (T) serialize(returnValue);
+    return serializedReturnValue;
+  }
+
+  public Object serialize(Object o) {
+    try {
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      ObjectOutputStream oos = new ObjectOutputStream(baos);
+      oos.writeObject(o);
+      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+      ObjectInputStream ois = new ObjectInputStream(bais);
+      return ois.readObject();
+    } catch (Exception e) {
+      throw new JbpmException("serialization exception", e);
+    }
+  }
+}

Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java	2009-03-08 01:18:45 UTC (rev 4193)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java	2009-03-08 12:20:29 UTC (rev 4194)
@@ -21,6 +21,7 @@
  */
 package org.jbpm.pvm.internal.task;
 
+import java.io.ObjectStreamException;
 import java.util.List;
 
 import org.hibernate.Query;

Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CommandServiceBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CommandServiceBinding.java	2009-03-08 01:18:45 UTC (rev 4193)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CommandServiceBinding.java	2009-03-08 12:20:29 UTC (rev 4194)
@@ -26,6 +26,7 @@
 import org.jbpm.cmd.CommandService;
 import org.jbpm.pvm.internal.svc.AsyncCommandService;
 import org.jbpm.pvm.internal.svc.DefaultCommandService;
+import org.jbpm.pvm.internal.svc.SerializingCommandService;
 import org.jbpm.pvm.internal.util.XmlUtil;
 import org.jbpm.pvm.internal.wire.Descriptor;
 import org.jbpm.pvm.internal.wire.descriptor.CommandServiceDescriptor;
@@ -66,6 +67,11 @@
   }
 
   protected CommandService getCommandService(Element element, Parse parse, Parser parser) {
+    if ( XmlUtil.attributeBoolean(element, "serialize", false, parse, Boolean.FALSE)) {
+
+      return new SerializingCommandService();
+    }
+
     if ( XmlUtil.attributeBoolean(element, "async", false, parse, Boolean.FALSE)) {
 
       AsyncCommandService asyncCommandService = new AsyncCommandService();

Modified: jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.cfg.xml	2009-03-08 01:18:45 UTC (rev 4193)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.cfg.xml	2009-03-08 12:20:29 UTC (rev 4194)
@@ -11,7 +11,7 @@
     <task-service />
     <identity-service />
 
-    <command-service>
+    <command-service  serialize="true">
       <retry-interceptor />
       <environment-interceptor />
       <standard-transaction-interceptor />




More information about the jbpm-commits mailing list