[jbpm-commits] JBoss JBPM SVN: r2401 - in jbpm3/branches/aguizar/modules/core/src/main: resources/org/jbpm and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Sep 26 11:25:42 EDT 2008


Author: alex.guizar at jboss.com
Date: 2008-09-26 11:25:41 -0400 (Fri, 26 Sep 2008)
New Revision: 2401

Modified:
   jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
   jbpm3/branches/aguizar/modules/core/src/main/resources/org/jbpm/bytes/ByteArray.hbm.xml
   jbpm3/branches/aguizar/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
Log:
restored original byte block size (1024)

Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java	2008-09-26 13:55:42 UTC (rev 2400)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java	2008-09-26 15:25:41 UTC (rev 2401)
@@ -23,6 +23,7 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
@@ -44,17 +45,22 @@
 
   public static List chopItUp(byte[] byteArray) {
     List bytes = null;
-    if ( (byteArray!=null)
-         && (byteArray.length>0) ){
-      log.debug("chopping " + byteArray.length + " bytes");
-      bytes = new ArrayList();
+    if (byteArray != null) {
       int blockSize = JbpmConfiguration.Configs.getInt("jbpm.byte.block.size");
-      int offset = 0;
-      while ( (byteArray.length-offset) > blockSize ) {
-        bytes.add(subArray(byteArray, offset, blockSize));
-        offset+=blockSize;
+      int byteCount = byteArray.length;
+      if (byteCount > blockSize) {
+        log.debug("chopping " + byteCount + " bytes");
+        bytes = new ArrayList();
+        int offset;
+        for (offset = 0; byteCount - offset > blockSize; offset += blockSize) {
+          bytes.add(subArray(byteArray, offset, blockSize));
+        }
+        bytes.add(subArray(byteArray, offset, byteCount - offset));
       }
-      bytes.add(subArray(byteArray, offset, byteArray.length-offset));
+      else if (byteCount > 0) {
+        log.debug("no need to chop " + byteCount + " bytes");
+        bytes = Collections.singletonList(byteArray);
+      }
     }
     return bytes;
   }
@@ -66,26 +72,28 @@
     return subArray;
   }
 
-  public static byte[] glueChopsBackTogether(List bytes) {
+  public static byte[] glueChopsBackTogether(List byteBlocks) {
     byte[] byteArray = null;
     
-    if (bytes!=null) {
-      int blockCount = bytes.size();
+    if (byteBlocks != null) {
+      int blockCount = byteBlocks.size();
       switch (blockCount) {
       case 0:
         break;
       case 1:
-        byteArray = (byte[]) bytes.get(0);
+        byteArray = (byte[]) byteBlocks.get(0);
+        log.debug("no need to glue " + byteArray.length + " bytes");
         break;
       default:
         int blockSize = JbpmConfiguration.Configs.getInt("jbpm.byte.block.size");
-        byte[] lastBlock = (byte[]) bytes.get(blockCount - 1);
+        byte[] lastBlock = (byte[]) byteBlocks.get(blockCount - 1);
         int byteCount = blockSize * (blockCount - 1) + lastBlock.length;
         log.debug("gluing " + byteCount + " bytes");
+
         byteArray = new byte[byteCount];
         int offset = 0;
         for (int i = 0, n = blockCount; i < n; i++) {
-          byte[] block = (byte[]) bytes.get(i);
+          byte[] block = (byte[]) byteBlocks.get(i);
           int length = block.length;
           System.arraycopy(block, 0, byteArray, offset, length);
           log.debug("glued " + length + " bytes beggining at " + offset);

Modified: jbpm3/branches/aguizar/modules/core/src/main/resources/org/jbpm/bytes/ByteArray.hbm.xml
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/resources/org/jbpm/bytes/ByteArray.hbm.xml	2008-09-26 13:55:42 UTC (rev 2400)
+++ jbpm3/branches/aguizar/modules/core/src/main/resources/org/jbpm/bytes/ByteArray.hbm.xml	2008-09-26 15:25:41 UTC (rev 2401)
@@ -13,7 +13,7 @@
           cascade="all">
       <key column="PROCESSFILE_" foreign-key="FK_BYTEBLOCK_FILE" />
       <list-index column="INDEX_" />
-      <element type="binary" length="255" column="BYTES_" />
+      <element type="binary" length="1024" column="BYTES_" />
     </list>
   </class>
 </hibernate-mapping>

Modified: jbpm3/branches/aguizar/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml	2008-09-26 13:55:42 UTC (rev 2400)
+++ jbpm3/branches/aguizar/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml	2008-09-26 15:25:41 UTC (rev 2401)
@@ -31,7 +31,7 @@
   <string name="resource.mail.templates" value="jbpm.mail.templates.xml" />
 
   <!-- make sure the block size matches the length in ByteArray.hbm.xml -->
-  <int    name="jbpm.byte.block.size" value="255" singleton="true" />
+  <int    name="jbpm.byte.block.size" value="1024" singleton="true" />
   <bean   name="jbpm.task.instance.factory" class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" />
   <bean   name="jbpm.variable.resolver" class="org.jbpm.jpdl.el.impl.JbpmVariableResolver" singleton="true" />
   <string name="jbpm.mail.smtp.host" value="localhost" />




More information about the jbpm-commits mailing list