[jboss-svn-commits] JBL Code SVN: r16716 - labs/jbossesb/workspace/platform/JBESB_4_2_1_SOA_4_2/product/rosetta/src/org/jboss/soa/esb/actions.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 20 23:52:24 EST 2007
Author: tcunning
Date: 2007-11-20 23:52:23 -0500 (Tue, 20 Nov 2007)
New Revision: 16716
Added:
labs/jbossesb/workspace/platform/JBESB_4_2_1_SOA_4_2/product/rosetta/src/org/jboss/soa/esb/actions/PropertySetter.java
Modified:
labs/jbossesb/workspace/platform/JBESB_4_2_1_SOA_4_2/product/rosetta/src/org/jboss/soa/esb/actions/StoreMessageToFile.java
Log:
bug:JBESB-1154
Add PropertySetter action, which is necessary for CI QS tests, and change
StoreMessageToFile so that it accepts filenames passed in through the
message properties.
Added: labs/jbossesb/workspace/platform/JBESB_4_2_1_SOA_4_2/product/rosetta/src/org/jboss/soa/esb/actions/PropertySetter.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_2_1_SOA_4_2/product/rosetta/src/org/jboss/soa/esb/actions/PropertySetter.java (rev 0)
+++ labs/jbossesb/workspace/platform/JBESB_4_2_1_SOA_4_2/product/rosetta/src/org/jboss/soa/esb/actions/PropertySetter.java 2007-11-21 04:52:23 UTC (rev 16716)
@@ -0,0 +1,83 @@
+package org.jboss.soa.esb.actions;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.apache.log4j.Logger;
+
+/**
+ * <p/>
+ * This action adds all of its attributes to the message as properties. It was created to
+ * help pass in the name of the filename to use for StoreMessageToFile for continuous integration
+ * of quickstarts, but it has a more generalized purpose in that it allows anyone to set
+ * message properties quickly in the jboss-esb.xml.
+ * <p/>
+ * An "Action Processor" performs a processing action on a message payload and returns the processing
+ * result.
+ * <p/>
+ * Here is an example of how to use this within your jboss-esb.xml :
+ * <p/>
+ * <code>
+ * <action name="AddProperty"
+ * class="org.jboss.soa.esb.actions.PropertySetter"><br/>
+ * <property name="jbesbfilename" value="BPMOrchestration1Test.log"/><br/>
+ * </action><br/>
+ * </code>
+ * <p/>
+ * This will insert a property "jbesbfilename" into the message with a value of
+ * "BPMOrchestration1Test.log". There are no checks here on property names, so be careful
+ * when setting properties for JMS that you only set ones with valid names.
+ *
+ * @author <a href="mailto:tcunning at redhat.com">tcunning at redhat.com</a>
+ * @since Version 4.2.1
+ *
+ */
+public class PropertySetter extends AbstractActionLifecycle {
+
+ protected ConfigTree _config;
+ private Logger logger = Logger.getLogger(PropertySetter.class);
+
+ /**
+ * Adds attributes to the message as properties
+ * @param message message
+ * @return message
+ * @throws Exception
+ */
+ public Message process(Message message) throws Exception {
+ try {
+ for (String key : _config.getAttributeNames()) {
+ String value = _config.getAttribute(key);
+ message.getProperties().setProperty(key, value);
+ }
+ } catch (Exception e) {
+ logger.error("", e);
+ throw e;
+ }
+
+ return message;
+ }
+
+ public PropertySetter(ConfigTree config) { _config = config; }
+
+}
Modified: labs/jbossesb/workspace/platform/JBESB_4_2_1_SOA_4_2/product/rosetta/src/org/jboss/soa/esb/actions/StoreMessageToFile.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_2_1_SOA_4_2/product/rosetta/src/org/jboss/soa/esb/actions/StoreMessageToFile.java 2007-11-21 04:50:07 UTC (rev 16715)
+++ labs/jbossesb/workspace/platform/JBESB_4_2_1_SOA_4_2/product/rosetta/src/org/jboss/soa/esb/actions/StoreMessageToFile.java 2007-11-21 04:52:23 UTC (rev 16716)
@@ -104,6 +104,10 @@
raw = Boolean.parseBoolean(config.getAttribute(RAW, "false")) ;
}
+ public void catchesException(Message message, Throwable exception) {
+ message.getBody().add("exception", exception.getMessage());
+ }
+
/**
* Process the message.
*
@@ -116,7 +120,7 @@
final Object contents;
try {
- contents = payloadProxy.getPayload(message);
+ contents = payloadProxy.getPayload(message);
} catch (MessageDeliverException e) {
throw new ActionProcessingException(e);
}
More information about the jboss-svn-commits
mailing list