[jboss-svn-commits] JBL Code SVN: r6767 - labs/jbossesb/workspace/jokum/product/core/listeners/src/org/jboss/soa/esb/actions/routing

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Oct 12 17:18:23 EDT 2006


Author: jokum
Date: 2006-10-12 17:18:22 -0400 (Thu, 12 Oct 2006)
New Revision: 6767

Added:
   labs/jbossesb/workspace/jokum/product/core/listeners/src/org/jboss/soa/esb/actions/routing/EchoRouter.java
   labs/jbossesb/workspace/jokum/product/core/listeners/src/org/jboss/soa/esb/actions/routing/HttpRouter.java
Log:
Added an EchoRouter handy for debugging orchestrations

Added: labs/jbossesb/workspace/jokum/product/core/listeners/src/org/jboss/soa/esb/actions/routing/EchoRouter.java
===================================================================
--- labs/jbossesb/workspace/jokum/product/core/listeners/src/org/jboss/soa/esb/actions/routing/EchoRouter.java	2006-10-12 20:44:18 UTC (rev 6766)
+++ labs/jbossesb/workspace/jokum/product/core/listeners/src/org/jboss/soa/esb/actions/routing/EchoRouter.java	2006-10-12 21:18:22 UTC (rev 6767)
@@ -0,0 +1,111 @@
+/*
+ * 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.routing;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.jms.JMSException;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.actions.ActionUtils;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * Echo Action Processor. <p/> Sample Action Configuration:
+ * 
+ * <pre>
+ *   &lt;Action name=&quot;Echo&quot; processor=&quot;EchoRouter&quot;&gt;      
+ *   &lt;/Action&gt;
+ * </pre>
+ * 
+ * @author <a href="mailto:johan.kumps at telenet.be">Johan Kumps</a>
+ */
+public class EchoRouter implements ActionProcessor {
+	/**
+	 * Logger.
+	 */
+	private static Logger logger = Logger.getLogger(EchoRouter.class);
+
+	/**
+	 * Public constructor.
+	 * 
+	 * @param actionName
+	 *            Action name.
+	 * @param properties
+	 *            Action properties.
+	 * @throws ConfigurationException
+	 *             Queue name not configured.
+	 * @throws JMSException
+	 *             Unable to configure JMS destination.
+	 * @throws NamingException
+	 *             Unable to configure JMS destination.
+	 */
+	public EchoRouter(String actionName, List<KeyValuePair> properties)
+			throws ConfigurationException, NamingException, JMSException {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+	 */
+	public org.jboss.soa.esb.message.Message process(
+			org.jboss.soa.esb.message.Message message)
+			throws ActionProcessingException {
+
+		if (logger.isInfoEnabled()) {
+			logger.info("EchoRouter currently routing message " + message);
+		}
+
+		return message;
+
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+	 */
+	public Serializable getOkNotification(
+			org.jboss.soa.esb.message.Message message) {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+	 */
+	public Serializable getErrorNotification(
+			org.jboss.soa.esb.message.Message message) {
+		return null;
+	}
+
+}

Added: labs/jbossesb/workspace/jokum/product/core/listeners/src/org/jboss/soa/esb/actions/routing/HttpRouter.java
===================================================================
--- labs/jbossesb/workspace/jokum/product/core/listeners/src/org/jboss/soa/esb/actions/routing/HttpRouter.java	2006-10-12 20:44:18 UTC (rev 6766)
+++ labs/jbossesb/workspace/jokum/product/core/listeners/src/org/jboss/soa/esb/actions/routing/HttpRouter.java	2006-10-12 21:18:22 UTC (rev 6767)
@@ -0,0 +1,130 @@
+/*
+ * 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.routing;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.jms.JMSException;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.actions.ActionUtils;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * Http Action Processor. <p/> Sample Action Configuration:
+ * 
+ * <pre>
+ *  &lt;Action name=&quot;Route-To-Invoicing&quot; processor=&quot;HttpRouter&quot;&gt;
+ *      &lt;property name=&quot;invokeUrl&quot; value=&quot;http://localhost:5400&quot; /&gt; 
+ *  &lt;/Action&gt;
+ * </pre>
+ * 
+ * @author <a href="mailto:johan.kumps at telenet.be">Johan Kumps</a>
+ */
+public class HttpRouter implements ActionProcessor {
+	/**
+	 * Logger.
+	 */
+	private static Logger logger = Logger.getLogger(HttpRouter.class);
+
+	private String invokeUrl = null;
+
+	/**
+	 * Public constructor.
+	 * 
+	 * @param actionName
+	 *            Action name.
+	 * @param properties
+	 *            Action properties.
+	 * @throws ConfigurationException
+	 *             Queue name not configured.
+	 * @throws JMSException
+	 *             Unable to configure JMS destination.
+	 * @throws NamingException
+	 *             Unable to configure JMS destination.
+	 */
+	public HttpRouter(String actionName, List<KeyValuePair> properties)
+			throws ConfigurationException, NamingException, JMSException {
+		this.invokeUrl = KeyValuePair.getValue("invokeUrl", properties);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+	 */
+	public org.jboss.soa.esb.message.Message process(
+			org.jboss.soa.esb.message.Message message)
+			throws ActionProcessingException {
+
+		Object oCurr = ActionUtils.currentFromMessage(message);
+		if (!(oCurr instanceof Serializable)) {
+			throw new ActionProcessingException("Cannot send Object ["
+					+ oCurr.getClass().getName() + "] to destination ["
+					+ this.invokeUrl + "]. Object must be serializable.");
+		}
+
+		try {
+			InvokerLocator locator = new InvokerLocator(this.invokeUrl);
+
+			Client remotingClient = new Client(locator);
+			remotingClient.connect();
+
+			remotingClient.invoke(oCurr, null);
+			return message;
+		} catch (Throwable e) {
+			String errorMessage = "Exception while sending message [" + oCurr
+					+ "] to destination [" + this.invokeUrl + "].";
+			logger.error(errorMessage, e);
+			throw new ActionProcessingException(errorMessage, e);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+	 */
+	public Serializable getOkNotification(
+			org.jboss.soa.esb.message.Message message) {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+	 */
+	public Serializable getErrorNotification(
+			org.jboss.soa.esb.message.Message message) {
+		return null;
+	}
+
+}




More information about the jboss-svn-commits mailing list