[jboss-svn-commits] JBL Code SVN: r11332 - in labs/jbossesb/trunk/product: core/rosetta/src/org/jboss/internal/soa/esb/message and 7 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Apr 25 14:45:04 EDT 2007
Author: mark.little at jboss.com
Date: 2007-04-25 14:45:04 -0400 (Wed, 25 Apr 2007)
New Revision: 11332
Added:
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/metadata/
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/metadata/MetaDataFilter.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/filter/
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/filter/FilterManager.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/filter/InputOutputFilter.java
Modified:
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Environment.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/ModulePropertyManager.java
labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java
labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml
Log:
http://jira.jboss.com/jira/browse/JBESB-521
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java 2007-04-25 18:15:52 UTC (rev 11331)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java 2007-04-25 18:45:04 UTC (rev 11332)
@@ -29,6 +29,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Calendar;
import java.util.UUID;
import javax.xml.parsers.ParserConfigurationException;
@@ -44,6 +45,7 @@
import org.jboss.soa.esb.common.ModulePropertyManager;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.couriers.CourierUtil;
+import org.jboss.soa.esb.couriers.filter.FilterManager;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.util.Util;
@@ -204,11 +206,14 @@
try
{
File dir = new File(_url.getFile());
- tmpFile = CourierUtil.messageToLocalFile(dir, message);
-
String name = message.getHeader().getCall().getMessageID()
.toString();
name += _outputSuffix;
+
+ message = FilterManager.getInstance().doOutputWork(message);
+
+ tmpFile = CourierUtil.messageToLocalFile(dir, message);
+
handler.renameFile(tmpFile, new File(dir, name));
return true;
@@ -233,10 +238,13 @@
ModulePropertyManager.TRANSPORTS_MODULE).getProperty(
Environment.FTP_LOCALDIR, DEFAULT_TMP);
File dir = new File(sDir);
+ String name = message.getHeader().getCall().getMessageID().toString();
+
+ name += _outputSuffix;
+
+ message = FilterManager.getInstance().doOutputWork(message);
+
tmpFile = CourierUtil.messageToLocalFile(dir, message);
- String name = message.getHeader().getCall().getMessageID()
- .toString();
- name += _outputSuffix;
File messageFile = new File(dir, name);
tmpFile.renameTo(messageFile);
@@ -295,6 +303,9 @@
handler.deleteFile(work);
else
handler.renameFile(work, done);
+
+ result = FilterManager.getInstance().doInputWork(result);
+
return result;
}
try
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java 2007-04-25 18:15:52 UTC (rev 11331)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java 2007-04-25 18:45:04 UTC (rev 11332)
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.io.Serializable;
import java.net.URISyntaxException;
+import java.util.Calendar;
import java.util.List;
import java.util.Properties;
@@ -48,7 +49,9 @@
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.common.Environment;
import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.couriers.filter.FilterManager;
import org.jboss.soa.esb.helpers.KeyValuePair;
import org.jboss.soa.esb.helpers.NamingContext;
import org.jboss.soa.esb.message.Message;
@@ -147,6 +150,12 @@
throw new CourierException(e);
}
+ /*
+ * Add some message properties.
+ */
+
+ message = FilterManager.getInstance().doOutputWork(message);
+
while (null != _messageProducer)
{
try
@@ -352,7 +361,12 @@
{
Serializable obj = (Serializable) ((ObjectMessage) jmsMessage)
.getObject();
- return Util.deserialize(obj);
+
+ Message msg = Util.deserialize(obj);
+
+ msg = FilterManager.getInstance().doOutputWork(msg);
+
+ return msg;
}
catch (JMSException e1)
{
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java 2007-04-25 18:15:52 UTC (rev 11331)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java 2007-04-25 18:45:04 UTC (rev 11332)
@@ -34,7 +34,9 @@
import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
+import org.jboss.soa.esb.common.Environment;
import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.couriers.filter.FilterManager;
import org.jboss.soa.esb.helpers.persist.JdbcCleanConn;
import org.jboss.soa.esb.helpers.persist.SimpleDataSource;
import org.jboss.soa.esb.message.Message;
@@ -147,6 +149,8 @@
}
}
+ message = FilterManager.getInstance().doOutputWork(message);
+
while (_conn != null)
{
try
@@ -202,6 +206,9 @@
String messageId = RS.getString(1);
if (null == (result = tryToPickup(messageId)))
continue;
+
+ result = FilterManager.getInstance().doInputWork(result);
+
return result;
}
}
Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/metadata/MetaDataFilter.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/metadata/MetaDataFilter.java (rev 0)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/metadata/MetaDataFilter.java 2007-04-25 18:45:04 UTC (rev 11332)
@@ -0,0 +1,131 @@
+/*
+ * 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.internal.soa.esb.message.metadata;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Calendar;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
+import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.ModulePropertyManager;
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.couriers.filter.InputOutputFilter;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * An inputoutput filter is called when the message is being received/sent and after it
+ * has been received from the transport/before it is passed to the transport.
+ * Implementations may augment or modify the message en route. Implementations that
+ * are pure output or pure input can just override the desired operation.
+ *
+ * This one adds some metadata to the message as it flows through the ESB.
+ *
+ * @author marklittle
+ */
+
+public class MetaDataFilter extends InputOutputFilter
+{
+ public Message onOutput (Message msg) throws CourierException
+ {
+ EPR destination = msg.getHeader().getCall().getTo();
+ Environment.Transports type = Environment.Transports.JMS;
+ String name = null;
+
+ if (destination instanceof FTPEpr)
+ {
+ try
+ {
+ type = Environment.Transports.FTP;
+
+ String dir = ModulePropertyManager.getPropertyManager(
+ ModulePropertyManager.TRANSPORTS_MODULE).getProperty(
+ Environment.FTP_LOCALDIR, System.getProperty("java.io.tmpdir"));
+
+ name = dir + File.pathSeparator + msg.getHeader().getCall().getMessageID().toString() +
+ ((FTPEpr) destination).getPostDirectory();
+ }
+ catch (URISyntaxException ex)
+ {
+ throw new CourierException(ex);
+ }
+ }
+ else
+ {
+ if (destination instanceof FileEpr)
+ {
+ try
+ {
+ type = Environment.Transports.File;
+
+ name = ((FileEpr) destination).getURL() + File.pathSeparator +
+ msg.getHeader().getCall().getMessageID().toString() + ((FileEpr) destination).getPostSuffix();
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new CourierException(ex);
+ }
+ catch (URISyntaxException ex)
+ {
+ throw new CourierException(ex);
+ }
+ }
+ else
+ {
+ if (destination instanceof JMSEpr)
+ {
+ type = Environment.Transports.JMS;
+
+ name = destination.getAddr().toString();
+ }
+ else
+ {
+ if (destination instanceof JDBCEpr)
+ {
+ type = Environment.Transports.SQL;
+
+ name = destination.getAddr().toString();
+ }
+ }
+ }
+ }
+
+ msg.getProperties().setProperty(Environment.TRANSPORT_TYPE, type);
+ msg.getProperties().setProperty(Environment.MESSAGE_SOURCE, name);
+ msg.getProperties().setProperty(Environment.MESSAGE_ENTRY_TIME, Calendar.getInstance().getTime().toString());
+
+ return msg;
+ }
+
+ public Message onInput (Message msg) throws CourierException
+ {
+ msg.getProperties().setProperty(Environment.MESSAGE_EXIT_TIME, Calendar.getInstance().getTime().toString());
+
+ return msg;
+ }
+}
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Environment.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Environment.java 2007-04-25 18:15:52 UTC (rev 11331)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Environment.java 2007-04-25 18:45:04 UTC (rev 11332)
@@ -24,6 +24,11 @@
public class Environment
{
+ public enum Transports
+ {
+ File, FTP, JMS, SQL;
+ }
+
public static final String PROPERTIES_FILE = "org.jboss.soa.esb.propertyFile";
/*
@@ -129,5 +134,24 @@
public static final String MSG_STORE_JCR_USERNAME = "org.jboss.soa.esb.persistence.jcr.username";
public static final String MSG_STORE_JCR_PASSWORD = "org.jboss.soa.esb.persistence.jcr.password";
public static final String MSG_STORE_JCR_ROOT_NODE_PATH = "org.jboss.soa.esb.persistence.jcr.root.node.path";
+
+ /*
+ * Some message properties.
+ */
+
+ public static final String TRANSPORT_TYPE = "org.jboss.soa.esb.message.transport.type";
+ public static final String MESSAGE_SOURCE = "org.jboss.soa.esb.message.source";
+ public static final String MESSAGE_ENTRY_TIME = "org.jboss.soa.esb.message.time.dob"; // time born
+ public static final String MESSAGE_EXIT_TIME = "org.jboss.soa.esb.message.time.dod"; // time died
+
+ /*
+ * Filter properties should be identified by:
+ *
+ * org.jboss.soa.esb.courier.filter.<number>
+ *
+ * and will be called in increasing order of <number>. Same <number> may be
+ * called arbitrarily.
+ */
+ public static final String FILTER_NAME = "org.jboss.soa.esb.courier.filter";
}
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/ModulePropertyManager.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/ModulePropertyManager.java 2007-04-25 18:15:52 UTC (rev 11331)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/ModulePropertyManager.java 2007-04-25 18:45:04 UTC (rev 11332)
@@ -92,6 +92,8 @@
public static final String DBSTORE_MODULE = "dbstore";
public static final String ROUTER_MODULE = "messagerouting";
+
+ public static final String FILTER_MODULE = "filters";
/**
* Get the property manager responsible for the module component in the
Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/filter/FilterManager.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/filter/FilterManager.java (rev 0)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/filter/FilterManager.java 2007-04-25 18:45:04 UTC (rev 11332)
@@ -0,0 +1,179 @@
+/*
+ * 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.couriers.filter;
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.TreeMap;
+
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.ModulePropertyManager;
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.util.ClassUtil;
+
+import com.arjuna.common.util.propertyservice.PropertyManager;
+
+/**
+ * The FilterManager process messages through the various input and
+ * output filters that have been registered via the configuration file.
+ * Currently this is the same processing for all services/clients, i.e., there
+ * is no per-process/per-client processing, it is all at the ESB instance
+ * level.
+ *
+ * @author marklittle
+ */
+
+public class FilterManager
+{
+ public static final synchronized FilterManager getInstance ()
+ {
+ if (_instance == null)
+ _instance = new FilterManager();
+
+ return _instance;
+ }
+
+ /**
+ * Iterate through the registered output filters, allowing them to augment/modify
+ * the message. The first error causes the iteration to stop and the send to fail.
+ *
+ * @param msg the original message.
+ * @return the resultant message.
+ * @throws CourierException thrown if there is any error during processing.
+ */
+
+ public Message doOutputWork (Message msg) throws CourierException
+ {
+ if (_filters == null)
+ return msg;
+
+ for (int i = 0; i < _filters.length; i++)
+ {
+ msg = _filters[i].onOutput(msg);
+ }
+
+ return msg;
+ }
+
+ /**
+ * Iterate through the registered input filters, allowing them to augment/modify
+ * the message. The first error causes the iteration to stop and the receive to fail.
+ *
+ * @param msg the original message.
+ * @return the resultant message.
+ * @throws CourierException thrown if there is any error during processing.
+ */
+
+ public Message doInputWork (Message msg) throws CourierException
+ {
+ if (_filters == null)
+ return msg;
+
+ for (int i = 0; i < _filters.length; i++)
+ {
+ msg = _filters[i].onInput(msg);
+ }
+
+ return msg;
+ }
+
+ private FilterManager ()
+ {
+ PropertyManager pm = ModulePropertyManager.getPropertyManager(ModulePropertyManager.FILTER_MODULE);
+ Properties props = pm.getProperties();
+
+ if (props != null)
+ {
+ Enumeration names = props.propertyNames();
+ TreeMap<Integer, String> map = new TreeMap<Integer, String>();
+
+ /*
+ * Go through the list of attributes and pull out those that refer
+ * to filters. Make sure we order them according to their names.
+ */
+
+ while (names.hasMoreElements())
+ {
+ String attrName = (String) names.nextElement();
+
+ if (attrName.startsWith(Environment.FILTER_NAME))
+ {
+ String order = attrName.substring(Environment.FILTER_NAME.length()+1);
+ Integer value;
+
+ try
+ {
+ value = new Integer(order);
+ }
+ catch (NumberFormatException ex)
+ {
+ throw new RuntimeException("Filter name "+order+" is invalid!");
+ }
+
+ map.put(value, props.getProperty(attrName));
+ }
+ }
+
+ if (map.size() > 0)
+ {
+ Collection<String> ordered = map.values();
+ Iterator<String> iter = ordered.iterator();
+ int index = 0;
+
+ _filters = new InputOutputFilter[map.size()];
+
+ while (iter.hasNext())
+ {
+ String filterName = iter.next();
+
+ try
+ {
+ Class c = ClassUtil.forName(filterName, getClass());
+ InputOutputFilter theFilter = (InputOutputFilter) c.newInstance();
+
+ _filters[index++] = theFilter;
+ }
+ catch (ClassNotFoundException ex)
+ {
+ ex.printStackTrace();
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ }
+ catch (InstantiationException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+ private InputOutputFilter[] _filters;
+
+ private static FilterManager _instance = null;
+}
Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/filter/InputOutputFilter.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/filter/InputOutputFilter.java (rev 0)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/filter/InputOutputFilter.java 2007-04-25 18:45:04 UTC (rev 11332)
@@ -0,0 +1,64 @@
+/*
+ * 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.couriers.filter;
+
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * An inputoutput filter is called when the message is being received/sent and after it
+ * has been received from the transport/before it is passed to the transport.
+ * Implementations may augment or modify the message en route. Implementations that
+ * are pure output or pure input can just override the desired operation.
+ *
+ * @author marklittle
+ */
+
+public class InputOutputFilter
+{
+ /**
+ * Called as the message flows towards the transport.
+ *
+ * @param msg the message
+ * @return an augmented message (or the original message)
+ * @throws CourierException thrown if an error occurs.
+ */
+
+ public Message onOutput (Message msg) throws CourierException
+ {
+ return msg;
+ }
+
+ /**
+ * Called immediately after the message is received from the transport.
+ *
+ * @param msg the message
+ * @return an augmented message (or the original message)
+ * @throws CourierException thrown if an error occurs.
+ */
+
+ public Message onInput (Message msg) throws CourierException
+ {
+ return msg;
+ }
+}
Modified: labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java 2007-04-25 18:15:52 UTC (rev 11331)
+++ labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java 2007-04-25 18:45:04 UTC (rev 11332)
@@ -35,6 +35,8 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.addressing.eprs.FileEpr;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.ModulePropertyManager;
import org.jboss.soa.esb.couriers.CourierFactory;
import org.jboss.soa.esb.couriers.CourierUtil;
import org.jboss.soa.esb.couriers.TwoWayCourier;
@@ -101,6 +103,58 @@
}
@Test
+ public void testMessageAttributes() throws Exception
+ {
+ ModulePropertyManager.getPropertyManager(ModulePropertyManager.FILTER_MODULE).setProperty("org.jboss.soa.esb.courier.filter.0", "org.jboss.internal.soa.esb.message.metadata.MetaDataFilter");
+
+ String contents = "This is the text that travels in the Message body";
+
+ // toEpr for files must be a directory
+ FileEpr toEpr = new FileEpr(_tmpDir.toURL());
+ // FileEpr uses the postSuffix as the extension for messages delivered (default = ".esbMessage")
+ toEpr.setPostSuffix(TEST_SUFFIX);
+
+ Message msg = MessageFactory.getInstance().getMessage();
+ msg.getBody().setContents(contents.getBytes());
+
+ Call call = new Call(toEpr);
+ String uid = UUID.randomUUID().toString();
+ call.setMessageID(new URI(uid));
+ msg.getHeader().setCall(call);
+
+ CourierUtil.deliverMessage(msg);
+
+ String timeSent = (String) msg.getProperties().getProperty(Environment.MESSAGE_ENTRY_TIME);
+ String source = (String) msg.getProperties().getProperty(Environment.MESSAGE_SOURCE);
+
+ File theFile = new File(_tmpDir,uid+TEST_SUFFIX);
+ Assert.assertTrue(theFile.exists());
+ _logger.info("Message file "+theFile.toString()+" successfully created");
+
+ FileEpr fromEpr = new FileEpr(toEpr.getURL());
+ fromEpr.setInputSuffix(TEST_SUFFIX);
+ fromEpr.setPostSuffix(DONE_SUFFIX);
+
+ TwoWayCourier pickUp = CourierFactory.getPickupCourier(fromEpr);
+ Message retrieved = pickUp.pickup(1000);
+ Assert.assertFalse("Null message retrieved",null==retrieved);
+
+ String back = new String(retrieved.getBody().getContents());
+ Assert.assertEquals(contents,back);
+ _logger.info("Contents of retrieved msg equal original text <"+back+">");
+
+ theFile = new File(_tmpDir,uid+TEST_SUFFIX+DONE_SUFFIX);
+ Assert.assertTrue(theFile.exists());
+ _logger.info("Retrieved message properly renamed to <"+theFile.toString()+">");
+
+ Assert.assertEquals(timeSent, retrieved.getProperties().getProperty(Environment.MESSAGE_ENTRY_TIME));
+ Assert.assertEquals(source, retrieved.getProperties().getProperty(Environment.MESSAGE_SOURCE));
+ Assert.assertNotNull(retrieved.getProperties().getProperty(Environment.MESSAGE_EXIT_TIME));
+
+ purgeStaleFiles();
+ }
+
+ @Test
public void testStoreRetrieve() throws Exception
{
String contents = "This is the text that travels in the Message body";
Modified: labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml 2007-04-25 18:15:52 UTC (rev 11331)
+++ labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml 2007-04-25 18:45:04 UTC (rev 11332)
@@ -85,4 +85,7 @@
<properties name="messagerouting">
<property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter"/>
</properties>
+ <properties name="filters">
+ <property name="org.jboss.soa.esb.courier.filter.1" value="org.jboss.internal.soa.esb.message.metadata.MetaDataFilter"/>
+ </properties>
</esb>
More information about the jboss-svn-commits
mailing list