[jboss-svn-commits] JBL Code SVN: r32845 - in labs/jbossesb/branches/JBESB_4_7_CP/product: samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1 and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed May 12 11:47:23 EDT 2010


Author: kevin.conner at jboss.com
Date: 2010-05-12 11:47:22 -0400 (Wed, 12 May 2010)
New Revision: 32845

Added:
   labs/jbossesb/branches/JBESB_4_7_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/composer/
   labs/jbossesb/branches/JBESB_4_7_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/composer/GatewayMessageComposer.java
Modified:
   labs/jbossesb/branches/JBESB_4_7_CP/product/samples/quickstarts/bpm_orchestration1/jboss-esb-unfiltered.xml
   labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/AsyncProcessSignal.java
Log:
Handle deletion of our jBPM variables and add composer for bpm_orchestration1: JBESB-3301

Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/samples/quickstarts/bpm_orchestration1/jboss-esb-unfiltered.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/samples/quickstarts/bpm_orchestration1/jboss-esb-unfiltered.xml	2010-05-12 15:44:08 UTC (rev 32844)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/samples/quickstarts/bpm_orchestration1/jboss-esb-unfiltered.xml	2010-05-12 15:47:22 UTC (rev 32845)
@@ -48,7 +48,9 @@
                  description="BPM Orchestration Sample 1: Use this service to start a process instance">
             <listeners>
                 <fs-listener name="Gateway" busidref="startGwChannel"
-                    is-gateway="true" />
+                    is-gateway="true">
+                    <property name="composer-class" value="org.jboss.soa.esb.samples.quickstarts.bpm_orchestration1.composer.GatewayMessageComposer"/>
+                </fs-listener>
                 <fs-listener name="ESB-Listener" busidref="startEsbChannel"/>
             </listeners>
             <actions mep="OneWay">

Added: labs/jbossesb/branches/JBESB_4_7_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/composer/GatewayMessageComposer.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/composer/GatewayMessageComposer.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/composer/GatewayMessageComposer.java	2010-05-12 15:47:22 UTC (rev 32845)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.soa.esb.samples.quickstarts.bpm_orchestration1.composer;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.gateway.LocalFileMessageComposer;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+
+public class GatewayMessageComposer extends LocalFileMessageComposer<File>
+{
+    private static final String DEFAULT_CHARSET = "UTF-8" ;
+    
+    private String charset = DEFAULT_CHARSET ;
+    
+    public void setConfiguration(final ConfigTree config)
+        throws ConfigurationException
+    {
+        super.setConfiguration(config) ;
+        charset = config.getAttribute("encoding", DEFAULT_CHARSET) ;
+    }
+    protected Object getPayload(final File inputFile)
+        throws IOException
+    {
+        final Object contents = super.getPayload(inputFile) ;
+        if (contents instanceof byte[])
+        {
+            final byte[] bytes = (byte[]) contents ;
+            return new String(bytes, charset) ;
+        }
+        else
+        {
+            return contents ;
+        }
+    }
+
+    public Object decompose(final Message message, final File inputFile)
+        throws MessageDeliverException
+    {
+        final Object payload = super.decompose(message, inputFile) ;
+        if (payload instanceof String)
+        {
+            final String result = (String)payload ;
+            try
+            {
+                return result.getBytes(charset) ;
+            }
+            catch (final UnsupportedEncodingException uee)
+            {
+                throw new MessageDeliverException("Unsupported encoding: " + charset, uee) ;
+            }
+        }
+        else
+        {
+            return payload ;
+        }
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossesb/branches/JBESB_4_7_CP/product/samples/quickstarts/bpm_orchestration1/src/org/jboss/soa/esb/samples/quickstarts/bpm_orchestration1/composer/GatewayMessageComposer.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/AsyncProcessSignal.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/AsyncProcessSignal.java	2010-05-12 15:44:08 UTC (rev 32844)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/cmd/AsyncProcessSignal.java	2010-05-12 15:47:22 UTC (rev 32845)
@@ -36,6 +36,8 @@
 import org.jbpm.JbpmException;
 import org.jbpm.command.SignalCommand;
 import org.jbpm.context.exe.ContextInstance;
+import org.jbpm.context.exe.TokenVariableMap;
+import org.jbpm.context.exe.VariableInstance;
 import org.jbpm.graph.def.Action;
 import org.jbpm.graph.def.ActionHandler;
 import org.jbpm.graph.def.ProcessDefinition;
@@ -45,6 +47,7 @@
 import org.jbpm.instantiation.Delegation;
 import org.jbpm.job.ExecuteActionJob;
 import org.jbpm.job.executor.JobExecutor;
+import org.jbpm.logging.LoggingService;
 import org.jbpm.msg.MessageService;
 import org.jbpm.svc.Services;
 
@@ -198,10 +201,6 @@
         {
             contextInstance.setVariableLocally(name, value, token) ;
         }
-        else
-        {
-            contextInstance.deleteVariable(name, token) ;
-        }
     }
     
     /**
@@ -281,16 +280,16 @@
             }
             final ProcessInstance processInstance = token.getProcessInstance() ;
             final ContextInstance contextInstance = processInstance.getContextInstance() ;
-            final String transitionName = (String)contextInstance.getVariableLocally(ESB_ASYNC_SIGNAL_TRANSITION_VARIABLE_NAME, token) ;
-            final String actor = (String)contextInstance.getVariableLocally(ESB_ASYNC_SIGNAL_ACTOR_VARIABLE_NAME, token) ;
             final JbpmContext jbpmContext = executionContext.getJbpmContext() ;
+            final String transitionName = (String)removeVariableLocally(jbpmContext, contextInstance, ESB_ASYNC_SIGNAL_TRANSITION_VARIABLE_NAME, token) ;
+            final String actor = (String)removeVariableLocally(jbpmContext, contextInstance, ESB_ASYNC_SIGNAL_ACTOR_VARIABLE_NAME, token) ;
             final String origActor = jbpmContext.getActorId() ;
             
-            final int variableCount = Integer.parseInt((String)contextInstance.getVariableLocally(ESB_ASYNC_SIGNAL_VARIABLE_COUNT, token)) ;
+            final int variableCount = Integer.parseInt((String)removeVariableLocally(jbpmContext, contextInstance, ESB_ASYNC_SIGNAL_VARIABLE_COUNT, token)) ;
             for(int count = 0 ; count < variableCount ; count++)
             {
-                final String name = (String)contextInstance.getVariableLocally(ESB_ASYNC_SIGNAL_VARIABLE_NAMES + count, token) ;
-                final Object value = contextInstance.getVariableLocally(name, token) ;
+                final String name = (String)removeVariableLocally(jbpmContext, contextInstance, ESB_ASYNC_SIGNAL_VARIABLE_NAMES + count, token) ;
+                final Object value = removeVariableLocally(jbpmContext, contextInstance, name, token) ;
                 contextInstance.setVariable(name, value) ;
             }
             
@@ -313,6 +312,35 @@
                     token.getProcessInstance().getId()) ;
             }
         }
+        
+        private Object removeVariableLocally(final JbpmContext jbpmContext, final ContextInstance contextInstance, final String name, final Token token)
+        {
+            final Object value = contextInstance.getVariableLocally(name, token) ;
+
+            if (value != null)
+            {
+                VariableInstance variableInstance = null ;
+                final TokenVariableMap tokenVariableMap = contextInstance.getTokenVariableMap(token) ;
+                if (tokenVariableMap != null)
+                {
+                    final Map variableInstances = tokenVariableMap.getVariableInstances() ;
+                    if (variableInstances != null)
+                    {
+                        variableInstance = (VariableInstance)variableInstances.get(name) ;
+                    }
+                }
+                contextInstance.deleteVariable(name, token) ;
+                if (variableInstance != null)
+                {
+                    final LoggingService loggingService = jbpmContext.getServices().getLoggingService() ;
+                    if (loggingService == null)
+                    {
+                        jbpmContext.getSession().delete(variableInstance) ;
+                    }
+                }
+            }
+            return value ;
+        }
     }
     
     /**



More information about the jboss-svn-commits mailing list