[jboss-svn-commits] JBL Code SVN: r6170 - in labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb: actions command listeners

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Sep 12 09:05:42 EDT 2006


Author: tfennelly
Date: 2006-09-12 09:05:36 -0400 (Tue, 12 Sep 2006)
New Revision: 6170

Added:
   labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinition.java
   labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessor.java
Removed:
   labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionHandler.java
Modified:
   labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinitionFactory.java
   labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessingException.java
   labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/SmooksTransformActionHandler.java
   labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/InMemoryCommandQueue.java
   labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractPoller.java
   labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java
   labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java
Log:
renamed "ActionHandler" to "ActionProcessor" and made appropriate handler/Handler name changes to processor/Processor

Added: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinition.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinition.java	2006-09-12 13:04:54 UTC (rev 6169)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinition.java	2006-09-12 13:05:36 UTC (rev 6170)
@@ -0,0 +1,95 @@
+package org.jboss.soa.esb.actions;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * Action Definition.
+ * <p/>
+ * An Action is defined by "name", an action "processor" instance to perform the processing action, plus 
+ * properties to the processing action to be supplued to the processor instance.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ActionDefinition {
+    
+    String name;
+    String processor;
+    List<KeyValuePair> properties;
+
+    /**
+     * Private constructor.
+     * @param name The action name.
+     * @param processor The action processor runtime class.
+     * @param properties Action properties list.  An empty list for an action with no defined properties.
+     */
+    protected ActionDefinition(String name, String processor, List<KeyValuePair> properties) {
+        this.name = name;
+        this.processor = processor;
+        this.properties = properties;
+    }
+    
+    /**
+     * Get the action name.
+     * @return The action name.
+     */
+    public String getName() {
+        return name;
+    }
+    
+    /**
+     * Get the action processor instance.
+     * @return The Action Processor.
+     */
+    public ActionProcessor getProcessor() {
+        // TODO: Support singleton ActionProcessor instances.  This impl currently only supports prototype.
+        return createActionProcessor();
+    }
+    
+    /**
+     * Get the action properties to be supplied to the action processor.
+     * @return The configured action properties. An empty list for an action with no defined properties.
+     */
+    public List<KeyValuePair> getProperties() {
+        return properties;
+    }
+
+    /**
+     * Create the action processor instance.
+     * <p/>
+     * See the {@link ActionProcessor} regarding reflective construction rules.
+     * @return The action processor instance.
+     */
+    private ActionProcessor createActionProcessor() {
+        Class<? extends ActionProcessor> runtimeClass;
+        Class[] NONDEFAULT_SIG = new Class[] {String.class, List.class};
+        Constructor nonDefaultConstructor;
+        
+        // Get the runtime class...
+        try {
+            runtimeClass = Class.forName(processor).asSubclass(ActionProcessor.class);
+        } catch (ClassNotFoundException e) {
+            throw new IllegalStateException("Action Processor class " + processor + " not found in classpath.", e);
+        } catch (ClassCastException e) {
+            throw new IllegalStateException("Action Processor class " + processor + " does not implement " + ActionProcessor.class.getName(), e);
+        }            
+        
+        // Construct it...
+        try {
+            nonDefaultConstructor = runtimeClass.getConstructor(NONDEFAULT_SIG);
+            return (ActionProcessor) nonDefaultConstructor.newInstance(new Object[] {name, properties});
+        } catch (NoSuchMethodException e1) {
+            try {
+                return runtimeClass.newInstance();
+            } catch (InstantiationException e) {
+                throw new IllegalStateException("No appropriate constructor found on processor class [" + processor + "].  See " + ActionProcessor.class.getName() + " Javadoc.", e);
+            } catch (Exception e) {
+                throw new IllegalStateException("Unexpected exception.  Unable to construct processor class instance [" + processor + "] using default constructor.", e);
+            }
+        } catch (Exception e) {
+            throw new IllegalStateException("Unexpected exception.  Unable to construct processor class instance [" + processor + "] using non-default constructor.", e);
+        }
+    }
+}
\ No newline at end of file

Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinitionFactory.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinitionFactory.java	2006-09-12 13:04:54 UTC (rev 6169)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinitionFactory.java	2006-09-12 13:05:36 UTC (rev 6170)
@@ -22,7 +22,6 @@
 
 package org.jboss.soa.esb.actions;
 
-import java.lang.reflect.Constructor;
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.List;
@@ -34,6 +33,8 @@
 
 /**
  * Action Definition Factory.
+ * <p/>
+ * Note, much of the logic in this class could easily be replaced through the use of an IoC container.
  * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
  * @since Version 4.0
  */
@@ -58,19 +59,19 @@
             throw new ConfigurationException("No 'Actions' configuration.");
         }
         
-        // Read the handler alias and action def configurations from the XML configuration...
-        DomElement handlerAliasConfig = config.getFirstElementChild("HandlerAliases");
+        // Read the processor alias and action def configurations from the XML configuration...
+        DomElement processorAliasConfig = config.getFirstElementChild("ProcessorAliases");
         DomElement[] actions = config.getElementChildren("Action");
-        if(handlerAliasConfig == null) {
-            throw new ConfigurationException("No 'Actions/HandlerAliases' configuration.");
+        if(processorAliasConfig == null) {
+            throw new ConfigurationException("No 'Actions/ProcessorAliases' configuration.");
         }
         if(actions == null || actions.length == 0) {
             throw new ConfigurationException("No 'Actions/Action' configurations.");
         }
         
         // Initialise the Action Definition table..
-        Hashtable<String, String> handlerClasses = getHandlerClasses(handlerAliasConfig);
-        initialiseActionDefinitions(actions, handlerClasses);
+        Hashtable<String, String> processorClasses = getProcessorClasses(processorAliasConfig);
+        initialiseActionDefinitions(actions, processorClasses);
         logger.info("ActionDefinition Factory initialisation complete.");
     }
     
@@ -90,53 +91,53 @@
     /**
      * Initialise the Action Definitions.
      * @param actions Action Definition configurations.
-     * @param handlerClasses Handler classes keyed by alias name.
+     * @param processorClasses Processor classes keyed by alias name.
      * @throws ConfigurationException 
      */
-    private void initialiseActionDefinitions(DomElement[] actions, Hashtable<String, String> handlerClasses) throws ConfigurationException {
-        if(handlerClasses == null || handlerClasses.isEmpty()) {
-            throw new ConfigurationException("No action handler classes defined.");
+    private void initialiseActionDefinitions(DomElement[] actions, Hashtable<String, String> processorClasses) throws ConfigurationException {
+        if(processorClasses == null || processorClasses.isEmpty()) {
+            throw new ConfigurationException("No action processor classes defined.");
         }
         
         for(DomElement action : actions) {
             String name = action.getAttr("name");
-            String handlerAlias = action.getAttr("handler");
-            String handlerClass;
+            String processorAlias = action.getAttr("processor");
+            String processorClass;
             List<KeyValuePair> properties;
 
             // Check the required attributes...
             if(name == null || name.trim().equals("")) {
                 throw new ConfigurationException("Actions/Action has no 'name' defined.");
             }
-            if(handlerAlias == null || handlerAlias.trim().equals("")) {
-                throw new ConfigurationException("Actions/Action [" + name + "] has no 'handler' defined.");
+            if(processorAlias == null || processorAlias.trim().equals("")) {
+                throw new ConfigurationException("Actions/Action [" + name + "] has no 'processor' defined.");
             }
-            handlerClass = handlerClasses.get(handlerAlias);
-            if(handlerClass == null) {
-                throw new ConfigurationException("No action handler class defined for handler alias [" + handlerAlias + "] set on action [" + name + "].");
+            processorClass = processorClasses.get(processorAlias);
+            if(processorClass == null) {
+                throw new ConfigurationException("No action processor class defined for processor alias [" + processorAlias + "] set on action [" + name + "].");
             }
 
             // Get any properties defined on the action...
             properties = getProperties(action);
             
             // Create the action definition and store it against it's name...
-            actionDefinitions.put(name, new ActionDefinition(name, handlerClass, properties));
-            logger.info("Added ActionDefinition [" + name + "] for handler [" + handlerAlias + ":" + handlerClass + "]. Num properties: " + properties.size());
+            actionDefinitions.put(name, new ActionDefinition(name, processorClass, properties));
+            logger.info("Added ActionDefinition [" + name + "] for processor [" + processorAlias + ":" + processorClass + "]. Num properties: " + properties.size());
         }
     }
 
     /**
-     * Get the handler runtime classes.
-     * @param handlerAliasConfig Alias configs.
-     * @return Handler runtime classs 
+     * Get the processor runtime classes.
+     * @param processorAliasConfig Alias configs.
+     * @return Processor runtime classs 
      * @throws ConfigurationException Bad configuration.
      */
-    private Hashtable<String, String> getHandlerClasses(DomElement handlerAliasConfig) throws ConfigurationException {
-        DomElement[] aliases = handlerAliasConfig.getElementChildren("Alias");
-        Hashtable<String, String> handlerClasses = new Hashtable<String, String>();
+    private Hashtable<String, String> getProcessorClasses(DomElement processorAliasConfig) throws ConfigurationException {
+        DomElement[] aliases = processorAliasConfig.getElementChildren("Alias");
+        Hashtable<String, String> processorClasses = new Hashtable<String, String>();
         
         if(aliases == null) {
-            throw new ConfigurationException("No 'Actions/HandlerAliases/Alias' configurations.");
+            throw new ConfigurationException("No 'Actions/ProcessorAliases/Alias' configurations.");
         }
         
         for(DomElement alias : aliases) {
@@ -145,16 +146,16 @@
     
             // Check the required attributes...
             if(name == null || name.trim().equals("")) {
-                throw new ConfigurationException("Actions/HandlerAliases/Alias has no 'name' defined.");
+                throw new ConfigurationException("Actions/ProcessorAliases/Alias has no 'name' defined.");
             }
             if(className == null || className.trim().equals("")) {
-                throw new ConfigurationException("Actions/HandlerAliases/Alias [" + name + "] has no 'class' defined.");
+                throw new ConfigurationException("Actions/ProcessorAliases/Alias [" + name + "] has no 'class' defined.");
             }
-            handlerClasses.put(name, className);
-            logger.info("Added alias [" + name + "] for ActionHandler class [" + className + "].");
+            processorClasses.put(name, className);
+            logger.info("Added alias [" + name + "] for ActionProcessor class [" + className + "].");
         }
         
-        return handlerClasses;
+        return processorClasses;
     }
 
     /**
@@ -185,92 +186,4 @@
 
         return propertyList;
     }
-
-    /**
-     * Action Definition.
-     * <p/>
-     * An Action is defined by name, a handler instance to carry out the action, plus properties to the action
-     * to be supplued to the handler instance.
-     * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
-     * @since Version 4.0
-     */
-    public class ActionDefinition {
-        
-        private String name;
-        private String handler;
-        private List<KeyValuePair> properties;
-
-        /**
-         * Private constructor.
-         * @param name The action name.
-         * @param handler The action handler runtime class.
-         * @param properties Action properties list.  An empty list for an action with no defined properties.
-         */
-        private ActionDefinition(String name, String handler, List<KeyValuePair> properties) {
-            this.name = name;
-            this.handler = handler;
-            this.properties = properties;
-        }
-        
-        /**
-         * Get the action name.
-         * @return The action name.
-         */
-        public String getName() {
-            return name;
-        }
-        
-        /**
-         * Get the action handler instance.
-         * @return The Action Handler.
-         */
-        public ActionHandler getHandler() {
-            // TODO: Support singleton ActionHandler instances.  This impl currently only supports prototype.
-            return createActionHandler();
-        }
-        
-        /**
-         * Get the action properties to be supplied to the action handler.
-         * @return The configured action properties. An empty list for an action with no defined properties.
-         */
-        public List<KeyValuePair> getProperties() {
-            return properties;
-        }
-
-        /**
-         * Create the handler instance.
-         * Handler instance.
-         * @return
-         */
-        private ActionHandler createActionHandler() {
-            Class<? extends ActionHandler> runtimeClass;
-            Class[] NONDEFAULT_SIG = new Class[] {String.class, List.class};
-            Constructor nonDefaultConstructor;
-            
-            // Get the runtime class...
-            try {
-                runtimeClass = Class.forName(handler).asSubclass(ActionHandler.class);
-            } catch (ClassNotFoundException e) {
-                throw new IllegalStateException("Action Handler class " + handler + " not found in classpath.", e);
-            } catch (ClassCastException e) {
-                throw new IllegalStateException("Action Handler class " + handler + " does not implement " + ActionHandler.class.getName(), e);
-            }            
-            
-            // Construct it...
-            try {
-                nonDefaultConstructor = runtimeClass.getConstructor(NONDEFAULT_SIG);
-                return (ActionHandler) nonDefaultConstructor.newInstance(new Object[] {name, properties});
-            } catch (NoSuchMethodException e1) {
-                try {
-                    return runtimeClass.newInstance();
-                } catch (InstantiationException e) {
-                    throw new IllegalStateException("No appropriate constructor found on handler class [" + handler + "].  See " + ActionHandler.class.getName() + " Javadoc.", e);
-                } catch (Exception e) {
-                    throw new IllegalStateException("Unexpected exception.  Unable to construct handler class instance [" + handler + "] using default constructor.", e);
-                }
-            } catch (Exception e) {
-                throw new IllegalStateException("Unexpected exception.  Unable to construct handler class instance [" + handler + "] using non-default constructor.", e);
-            }
-        }
-    }
 }

Deleted: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionHandler.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionHandler.java	2006-09-12 13:04:54 UTC (rev 6169)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionHandler.java	2006-09-12 13:05:36 UTC (rev 6170)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, 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.jboss.soa.esb.actions;
-
-/**
- * Action Handler Interface Definition.
- * <p/>
- * Implementations are constructed based on the following public constructor order precedence:
- * <ol>
- *  <li><b>(String actionName, List&lt;{@link org.jboss.soa.esb.helpers.KeyValuePair}&gt; properties)</b></li>
- *  <li><b>default constructor</b>.</li>
- * </ol>
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public interface ActionHandler {
-    
-    /**
-     * Process the Action "payload" and return the result.
-     * @param payload The action payload to be processed.
-     * @return The processing result.
-     * @throws ActionProcessingException Exception during payload processing.
-     */
-    public Object processAction(Object payload) throws ActionProcessingException;
-}

Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessingException.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessingException.java	2006-09-12 13:04:54 UTC (rev 6169)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessingException.java	2006-09-12 13:05:36 UTC (rev 6170)
@@ -31,6 +31,8 @@
  */
 public class ActionProcessingException extends BaseException {
 
+    private static final long serialVersionUID = 1L;
+
     /**
      * Public constructor.
      * @param message Exception message.

Added: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessor.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessor.java	2006-09-12 13:04:54 UTC (rev 6169)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessor.java	2006-09-12 13:05:36 UTC (rev 6170)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.jboss.soa.esb.actions;
+
+/**
+ * Action Processor Interface Definition.
+ * <p/>
+ * An "Action Processor" performs a processing action on a message payload and returns the processing
+ * result.
+ * <p/>
+ * Implementations are constructed based on the following public constructor order precedence:
+ * <ol>
+ *  <li><b>(String actionName, List&lt;{@link org.jboss.soa.esb.helpers.KeyValuePair}&gt; properties)</b></li>
+ *  <li><b>default constructor</b>.</li>
+ * </ol>
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public interface ActionProcessor {
+    
+    /**
+     * Perform the processing action on the message "payload" and return the result.
+     * @param message The message payload to be processed.
+     * @return The processing result.
+     * @throws ActionProcessingException Exception during payload processing.
+     */
+    public Object process(Object message) throws ActionProcessingException;
+}

Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/SmooksTransformActionHandler.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/SmooksTransformActionHandler.java	2006-09-12 13:04:54 UTC (rev 6169)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/SmooksTransformActionHandler.java	2006-09-12 13:05:36 UTC (rev 6170)
@@ -32,16 +32,16 @@
  * @since Version 4.0
  */
 
-public class SmooksTransformActionHandler implements ActionHandler {
+public class SmooksTransformActionHandler implements ActionProcessor {
 
 	public SmooksTransformActionHandler(String name, List<KeyValuePair> properties) {
 		System.out.println("Instantiate action handler: " + name);
 	}
 
     /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionHandler#processAction(java.lang.Object)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#processAction(java.lang.Object)
      */
-    public Object processAction(Object payload) {
+    public Object process(Object payload) {
         System.out.println("processAction: " + payload);
         return payload;
     }

Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/InMemoryCommandQueue.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/InMemoryCommandQueue.java	2006-09-12 13:04:54 UTC (rev 6169)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/InMemoryCommandQueue.java	2006-09-12 13:05:36 UTC (rev 6170)
@@ -2,7 +2,7 @@
 
 import java.util.Hashtable;
 import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.SynchronousQueue;
 
 import org.jboss.soa.esb.helpers.DomElement;
 
@@ -28,7 +28,7 @@
 	private static Hashtable<String, InMemoryCommandQueue> commandQueues = new Hashtable<String, InMemoryCommandQueue>();
 	
 	private String name;
-	private BlockingQueue<String> queue = new LinkedBlockingQueue<String>();
+	private BlockingQueue<String> queue = new SynchronousQueue<String>();
 	
 	public void open(DomElement config) throws CommandQueueException {
 		if(config == null) {
@@ -44,6 +44,8 @@
 
 	/**
 	 * Add a command to the in-memory command queue.
+     * <p/>
+     * Blocks until the command has been consumed. 
 	 * @param command The command string.
 	 */
 	public void addCommand(String command) {

Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractPoller.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractPoller.java	2006-09-12 13:04:54 UTC (rev 6169)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractPoller.java	2006-09-12 13:05:36 UTC (rev 6170)
@@ -27,9 +27,9 @@
 import org.apache.log4j.*;
 
 import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionDefinition;
 import org.jboss.soa.esb.actions.ActionDefinitionFactory;
-import org.jboss.soa.esb.actions.ActionHandler;
-import org.jboss.soa.esb.actions.ActionDefinitionFactory.ActionDefinition;
+import org.jboss.soa.esb.actions.ActionProcessor;
 import org.jboss.soa.esb.helpers.*;
 
 public abstract class AbstractPoller implements Runnable {
@@ -156,7 +156,7 @@
                     continue;
                 }
 
-                ActionExecutionRunner runner = new ActionExecutionRunner(oProcess);
+                ActionProcessingPipeline runner = new ActionProcessingPipeline(oProcess);
                 new Thread(runner).start();
             }
         }
@@ -164,9 +164,9 @@
 
     
     /**
-     * Action Execution Runner.
+     * Action Processing Pipeline.
      * <p/>
-     * Runs the actions in a listeners "actions" config in a message payload object received
+     * Runs the actions in a listeners "actions" config on a message payload object received
      * by the listener implementation.
      * <p/>
      * TODO: This class is duplicated in both the AbstractPoller and JmsQueueListener classes.  Needs to be sorted out as an
@@ -175,7 +175,7 @@
      * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
      * @since Version 4.0
      */
-    private class ActionExecutionRunner implements Runnable {
+    private class ActionProcessingPipeline implements Runnable {
         
         private Object object;
              
@@ -183,7 +183,7 @@
          * Private constructor.
          * @param initialObject The inital processing target object.
          */
-        private ActionExecutionRunner(Object initialObject) {
+        private ActionProcessingPipeline(Object initialObject) {
             this.object = initialObject;
         }
 
@@ -197,7 +197,7 @@
             incThreads();
             
             try {
-                // Run the object through each ActionHandler...
+                // Run the object through each ActionProcessor...
                 for(String action : m_oActions) {
                     ActionDefinition actionDefinition;
 
@@ -208,10 +208,11 @@
                     }
                     
                     // The processing result of each action feeds into the processing of the next action...
-                    ActionHandler handler = actionDefinition.getHandler();
-                    object = handler.processAction(object);
-                    if(object == null) {
-                        m_oLogger.warn("Premature termination of action processing chain [" + Arrays.asList(m_oActions) + "].  ActionHandler [" + handler.getClass().getName() + "] returned a null object result on processing of action [" + currentAction + "].");
+                    ActionProcessor processor = actionDefinition.getProcessor();
+                    object = processor.process(object);
+                    
+                    if(object == null && action != m_oActions[m_oActions.length - 1]) {
+                        m_oLogger.warn("Premature termination of action processing chain [" + Arrays.asList(m_oActions) + "].  ActionProcessor [" + processor.getClass().getName() + "] returned a null object result on processing of action [" + currentAction + "].");
                         break;
                     }
                 }

Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java	2006-09-12 13:04:54 UTC (rev 6169)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java	2006-09-12 13:05:36 UTC (rev 6170)
@@ -552,47 +552,7 @@
 		return (null != sVal) ? sVal : p_sDefault;
 	} // ________________________________
 
-	private static Class[] s_oaActionConstr = { DomElement.class, Object.class };
-
-	public static Class[] getActionClassArgs() {
-		return s_oaActionConstr;
-	}
-
 	/**
-	 * Check to see if an object of the class (arg 0) can be instantiated in
-	 * this context
-	 * 
-	 * @param p_sName
-	 *            String - class name to instantiate - Must implement
-	 *            org.jboss.soa.esb.listeners.AbstractActionClass
-	 * @return Class -
-	 * @throws Exception -
-	 *             if class not found in path or no appropriate constructor
-	 */
-	protected static Class checkActionClass(String p_sName) throws Exception {
-		Class oCls;
-		try {
-			oCls = Class.forName(p_sName);
-		} catch (ClassNotFoundException e) {
-			throw new Exception("Class " + p_sName + " not found in classpath");
-		}
-
-		try {
-			oCls.getConstructor(s_oaActionConstr);
-		} catch (NoSuchMethodException eN) {
-			throw new Exception("No appropriate constructor " + p_sName
-					+ "(DomElement,Object) found for class ");
-		}
-		try {
-			oCls.asSubclass(AbstractAction.class);
-		} catch (ClassCastException eCC) {
-			throw new Exception("class " + p_sName + " does not extend "
-					+ AbstractAction.class.getName());
-		}
-		return oCls;
-	} // _________________________________________
-
-	/**
 	 * Find child nodes named "NotificationList" that contain an attribute
 	 * 'type' that starts with "ok" (case insensitive)
 	 * 

Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java	2006-09-12 13:04:54 UTC (rev 6169)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java	2006-09-12 13:05:36 UTC (rev 6170)
@@ -30,9 +30,9 @@
 import javax.jms.*;
 
 import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionDefinition;
 import org.jboss.soa.esb.actions.ActionDefinitionFactory;
-import org.jboss.soa.esb.actions.ActionHandler;
-import org.jboss.soa.esb.actions.ActionDefinitionFactory.ActionDefinition;
+import org.jboss.soa.esb.actions.ActionProcessor;
 import org.jboss.soa.esb.helpers.*;
 
 public class JmsQueueListener implements Runnable {
@@ -177,7 +177,7 @@
             if (null == oM)
                 continue;
 
-            ActionExecutionRunner runner = new ActionExecutionRunner(oM);
+            ActionProcessingPipeline runner = new ActionProcessingPipeline(oM);
             new Thread(runner).start();
         }
         if (null != m_oQsess)
@@ -207,9 +207,9 @@
     }
 
     /**
-     * Action Execution Runner.
+     * Action Processing Pipeline.
      * <p/>
-     * Runs the actions in a listeners "actions" config in a message payload object received
+     * Runs the actions in a listeners "actions" config on a message payload object received
      * by the listener implementation.
      * <p/>
      * TODO: This class is duplicated in both the AbstractPoller and JmsQueueListener classes.  Needs to be sorted out as an
@@ -218,7 +218,7 @@
      * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
      * @since Version 4.0
      */
-    private class ActionExecutionRunner implements Runnable {
+    private class ActionProcessingPipeline implements Runnable {
         
         private Object object;
              
@@ -226,7 +226,7 @@
          * Private constructor.
          * @param initialObject The inital processing target object.
          */
-        private ActionExecutionRunner(Object initialObject) {
+        private ActionProcessingPipeline(Object initialObject) {
             this.object = initialObject;
         }
 
@@ -240,7 +240,7 @@
             incThreads();
             
             try {
-                // Run the object through each ActionHandler...
+                // Run the object through each ActionProcessor...
                 for(String action : m_oActions) {
                     ActionDefinition actionDefinition;
 
@@ -251,15 +251,16 @@
                     }
                     
                     // The processing result of each action feeds into the processing of the next action...
-                    ActionHandler handler = actionDefinition.getHandler();
-                    object = handler.processAction(object);
-                    if(object == null) {
-                        m_oLogger.warn("Premature termination of action processing chain [" + Arrays.asList(m_oActions) + "].  ActionHandler [" + handler.getClass().getName() + "] returned a null object result on processing of action [" + currentAction + "].");
+                    ActionProcessor processor = actionDefinition.getProcessor();
+                    object = processor.process(object);
+                    
+                    if(object == null && action != m_oActions[m_oActions.length - 1]) {
+                        m_oLogger.warn("Premature termination of action processing chain [" + Arrays.asList(m_oActions) + "].  ActionProcessor [" + processor.getClass().getName() + "] returned a null object result on processing of action [" + currentAction + "].");
                         break;
                     }
                 }
             } catch(Throwable thrown) {
-                m_oLogger.error("Premature termination of action processing chain [" + Arrays.asList(m_oActions) + "].  Action [" + currentAction + "] thre an exception.", thrown);
+                m_oLogger.error("Premature termination of action processing chain [" + Arrays.asList(m_oActions) + "].  Action [" + currentAction + "] threw an exception.", thrown);
             }
             
             // Decrement the active thread count for the listener on completion...




More information about the jboss-svn-commits mailing list