[jboss-svn-commits] JBL Code SVN: r6274 - in labs/jbossesb/workspace/tfennelly: product/core/common/src/org/jboss/soa/esb/helpers product/core/common/tests/src/org/jboss/soa/esb/helpers product/core/listeners/src/org/jboss/soa/esb/actions product/core/listeners/src/org/jboss/soa/esb/listeners product/core/listeners/tests/src/org/jboss/soa/esb/actions product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks product/docs/samples/trailblazer/bankloanbrokerdemo/conf product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency qa/junit/src/org/jboss/soa/esb/listeners qa/junit/src/or! g/jboss/soa/esb/util
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Sep 18 11:23:19 EDT 2006
Author: tfennelly
Date: 2006-09-18 11:22:45 -0400 (Mon, 18 Sep 2006)
New Revision: 6274
Added:
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToFileWriter.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ByteArrayToStringUnitTest.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/FileToByteArrayUnitTest.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToCSVStringUnitTest.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToFileWriterUnitTest.java
labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ObjectToXStream.java
labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksResponse.java
labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ToBankQuoteResponse.java
labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteResponse.java
Modified:
labs/jbossesb/workspace/tfennelly/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java
labs/jbossesb/workspace/tfennelly/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractSqlRowAction.java
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/DummyFileAction.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractListener.java
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/DirectoryPoller.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
labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java
labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml.template
labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java
labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java
labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java
labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponseNotification.java
labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java
labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java
Log:
More pipeline cleaning up...
Modified: labs/jbossesb/workspace/tfennelly/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -79,4 +79,85 @@
return null;
}
-} // ____________________________________________________________________________
+
+ /**
+ * Get the value associated with the specified key from the supplied list of Key Value Pairs.
+ * <p/>
+ * Returns the value from the first matching key.
+ * @param key The key to search for.
+ * @param list The list of KeyValuePairs to search.
+ * @param defaultVal The default value to be returned where there's no value available for the specified key.
+ * @return The value associated with the supplied key, or null if key not found.
+ */
+ public static String getValue(String key, List<KeyValuePair> list, String defaultVal) {
+ String value = getValue(key, list);
+
+ if(value == null) {
+ return defaultVal;
+ }
+
+ return value;
+ }
+
+ /**
+ * Get the boolean equivalent value associated with the specified key
+ * from the supplied list of Key Value Pairs.
+ * <p/>
+ * Returns:
+ * <ul>
+ * <li><b><code>true</code></b>: If value equals "true" or "yes" or "y" (ignoring case).</li>
+ * <li><b><code>false</code></b>: If value equals "false" or "no" or "n" (ignoring case).</li>
+ * <li><b><i>defaultVal</i></b>: If none of the above hold true.</li>
+ * </ul>
+ * <p/>
+ * Returns the value from the first matching key.
+ * @param key The key to search for.
+ * @param list The list of KeyValuePairs to search.
+ * @param defaultVal The default value to be returned where the above listed conditions do not hold
+ * for the associated value, or the value is not specified.
+ * @return The boolean equivalent value associated with the specified key according to the above specified
+ * rules, otherwise the <b><i>defaultVal</i></b> is returned.
+ */
+ public static boolean getBooleanValue(String key, List<KeyValuePair> list, boolean defaultVal) {
+ String value = getValue(key, list);
+
+ if(value == null) {
+ return defaultVal;
+ }
+
+ if(value.equalsIgnoreCase("true") || value.equalsIgnoreCase("y") || value.equalsIgnoreCase("yes")) {
+ return true;
+ } else if(value.equalsIgnoreCase("false") || value.equalsIgnoreCase("n") || value.equalsIgnoreCase("no")) {
+ return false;
+ } else {
+ return defaultVal;
+ }
+ }
+
+ /**
+ * Get the numeric <code>double</code> equivalent value associated with the specified key
+ * from the supplied list of Key Value Pairs.
+ * <p/>
+ * Returns the value from the first matching key.
+ * @param key The key to search for.
+ * @param list The list of KeyValuePairs to search.
+ * @param defaultVal The default value to be returned where the value is not found or is non-numeric.
+ * @return The <code>double</code> equivalent value associated with the specified key if the value is found
+ * and is numeric, otherwise the <b><i>defaultVal</i></b> is returned.
+ */
+ public static double getDoubleValue(String key, List<KeyValuePair> list, double defaultVal) {
+ String value = getValue(key, list);
+
+ if(value == null) {
+ return defaultVal;
+ }
+
+ try {
+ return Double.parseDouble(value);
+ } catch(NumberFormatException e) {
+ // return the default...
+ }
+
+ return defaultVal;
+ }
+}
Modified: labs/jbossesb/workspace/tfennelly/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -21,6 +21,9 @@
*/
package org.jboss.soa.esb.helpers;
+import java.util.ArrayList;
+import java.util.List;
+
import junit.framework.TestCase;
/**
@@ -55,4 +58,27 @@
assertEquals("value", kvp.toString());
assertEquals("KVpair[key=value]", kvp.dump());
}
+
+ public void test_list() {
+ List<KeyValuePair> list = new ArrayList<KeyValuePair>();
+
+ list.add(new KeyValuePair("key1", "value1"));
+ list.add(new KeyValuePair("key2", "true"));
+ list.add(new KeyValuePair("key3", "false"));
+ list.add(new KeyValuePair("key4", "2"));
+ list.add(new KeyValuePair("key5", "10.8"));
+
+ assertEquals("value1", KeyValuePair.getValue("key1", list));
+ assertEquals("true", KeyValuePair.getValue("key2", list));
+ assertEquals("false", KeyValuePair.getValue("key3", list));
+ assertEquals("2", KeyValuePair.getValue("key4", list));
+
+ assertEquals(true, KeyValuePair.getBooleanValue("key2", list, false));
+ assertEquals(false, KeyValuePair.getBooleanValue("key3", list, true));
+ assertEquals(true, KeyValuePair.getBooleanValue("key1", list, true));
+
+ assertEquals(2.0, KeyValuePair.getDoubleValue("key4", list, 10.0));
+ assertEquals(10.8, KeyValuePair.getDoubleValue("key5", list, 2.0));
+ assertEquals(100.0, KeyValuePair.getDoubleValue("key1", list, 100.0));
+ }
}
Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -23,8 +23,6 @@
package org.jboss.soa.esb.actions;
import java.io.File;
-import java.io.IOException;
-import java.io.Serializable;
/**
* <p/>
@@ -37,27 +35,6 @@
*/
public abstract class AbstractFileAction implements ActionProcessor {
- public static class Params implements Serializable {
- private static final long serialVersionUID = 1L;
-
- public boolean bPostDelete;
-
- public File oInpF, oWrkF, oErrF, oDoneF;
-
- public String toString() {
- return oInpF.toString();
- }
- } // ________________________________
-
-
- public static boolean renameToError(Params fileParams) {
- return fileParams.oWrkF.renameTo(fileParams.oErrF);
- }
-
- public static boolean renameToDone(Params fileParams) {
- return fileParams.oWrkF.renameTo(fileParams.oDoneF);
- }
-
/**
* Files processed by action classes
* need to be renamed during processing to disable other listeners (or other
@@ -73,27 +50,21 @@
* @throws ActionProcessingException Exception during payload processing.
*/
public final Object process(Object message) throws ActionProcessingException {
- if(!(message instanceof Params)) {
+ if(!(message instanceof File)) {
throw new ActionProcessingException("Message object for processing by " + getClass().getName()
- + " should have been preprocessed and 'normalised' to a " + Params.class.getName() + " instance.");
+ + " should have been preprocessed to a " + File.class.getName() + " instance.");
}
- Params fileParams = (Params)message;
-
// Call the implementing class to process the file message...
- try {
- processFile(fileParams);
- } catch (IOException e) {
- throw new ActionProcessingException("Failed to process file message: " + fileParams, e);
- }
-
- return message;
+ return process((File)message);
}
/**
* Process the file message object.
- * @param fileParams Params re the file to be processed.
+ * @param file The file to be processed.
+ * @return The processing result.
+ * @throws ActionProcessingException Exception while processing file.
*/
- protected abstract void processFile(Params fileParams) throws IOException;
+ protected abstract Object process(File file) throws ActionProcessingException;
} // ____________________________________________________________________________
Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractSqlRowAction.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractSqlRowAction.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractSqlRowAction.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -4,13 +4,12 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.KeyValuePair;
-import org.jboss.soa.esb.listeners.SqlTablePoller.SQLPollResult;
/**
* Abstract SQL Row action.
* <p/>
* Convienience class for processing messages from the {@link org.jboss.soa.esb.listeners.SqlTablePoller} listener.
- * Implementing classes receive a single row resultset through their implementation of the {@link #processResultset(SQLPollResult)}
+ * Implementing classes receive a single row resultset through their implementation of the {@link #process(Map)}
* method.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
@@ -27,23 +26,23 @@
}
public final Object process(Object message) throws ActionProcessingException {
- if (!(message instanceof SQLPollResult)) {
+ if (!(message instanceof Map)) {
throw new ActionProcessingException(
"Message object for processing by "
+ getClass().getName()
+ " should have been preprocessed and supplied as a "
- + SQLPollResult.class.getName() + " instance.");
+ + Map.class.getName() + " instance.");
}
- return processResultset((SQLPollResult)message);
+ return process((Map)message);
} // ________________________________
/**
* Process the SQL poll resultset.
*
- * @param pollResult SQL Poller resultset.
+ * @param resultSet SQL Poller resultset.
* @return Processing result.
*/
- protected abstract Object processResultset(SQLPollResult pollResult) throws ActionProcessingException;
+ protected abstract Object process(Map resultSet) throws ActionProcessingException;
}
Modified: 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-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinition.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -15,9 +15,11 @@
*/
public class ActionDefinition {
- String name;
- String processor;
- List<KeyValuePair> properties;
+ private String name;
+ private String processor;
+ private List<KeyValuePair> properties;
+ private boolean isSingleton = true;
+ private ActionProcessor singletonInstance = null;
/**
* Private constructor.
@@ -29,6 +31,9 @@
this.name = name;
this.processor = processor;
this.properties = properties;
+
+ String isSingletonProp = KeyValuePair.getValue("singleton", properties);
+ isSingleton = (isSingletonProp == null || !isSingletonProp.equals("false"));
}
/**
@@ -44,8 +49,14 @@
* @return The Action Processor.
*/
public ActionProcessor getProcessor() {
- // TODO: Support singleton ActionProcessor instances. This impl currently only supports prototype.
- return createActionProcessor();
+ if(!isSingleton) {
+ return createActionProcessor();
+ } else {
+ if(singletonInstance == null) {
+ singletonInstance = createActionProcessor();
+ }
+ return singletonInstance;
+ }
}
/**
Added: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -0,0 +1,91 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * Byte Array to String processor.
+ * <p/>
+ * Sample Action Configuration:
+ * <pre>
+ * <Action name="Bytes-To-UTF-8-String" processor="ByteArrayToString">
+ * <property name="encoding" value="UTF-8" /> <!-- Default of "UTF-8". -->
+ * </Action>
+ * </pre>
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ByteArrayToString implements ActionProcessor {
+
+ private String encoding;
+
+ /**
+ * Public constructor.
+ * @param actionName Processing action name.
+ * @param properties Action properties.
+ */
+ public ByteArrayToString(String actionName, List<KeyValuePair> properties) {
+ encoding = KeyValuePair.getValue("encoding", properties, "UTF-8");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+ */
+ public Object process(Object message) throws ActionProcessingException {
+ byte[] bytes;
+
+ try {
+ bytes = (byte[])message;
+ } catch(ClassCastException e) {
+ throw new ActionProcessingException("Message must be an array of bytes. Is " + message.getClass().getName());
+ }
+
+ try {
+ return new String(bytes, encoding);
+ } catch (UnsupportedEncodingException e) {
+ throw new ActionProcessingException("Unable to decode byte[] to String. Unsupported character encoding configuration: " + encoding, e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+ */
+ public Serializable getOkNotification(Object message) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+ */
+ public Serializable getErrorNotification(Object message) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/DummyFileAction.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/DummyFileAction.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/DummyFileAction.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -1,5 +1,6 @@
package org.jboss.soa.esb.actions;
+import java.io.File;
import java.io.Serializable;
import java.text.*;
@@ -20,9 +21,10 @@
private static Logger logger = Logger.getLogger(DummyFileAction.class);
@Override
- public void processFile(Params fileParams)
+ public Object process(File file) throws ActionProcessingException
{
- logger.info("processObject was called with <<" + fileParams.toString() + ">>");
+ logger.info("processObject was called with <<" + file.getAbsolutePath() + ">>");
+ return file;
} //________________________________
private SimpleDateFormat s_oTS = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS");
Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -3,10 +3,10 @@
import java.io.Serializable;
import java.text.*;
import java.util.List;
+import java.util.Map;
import java.util.Vector;
import org.jboss.soa.esb.helpers.KeyValuePair;
-import org.jboss.soa.esb.listeners.SqlTablePoller.SQLPollResult;
/**
* Use this class to tune your XML configurations
@@ -21,7 +21,7 @@
public class DummySqlRowAction extends AbstractSqlRowAction
{
- public static List<SQLPollResult> params = new Vector<SQLPollResult>();
+ public static List<Map> params = new Vector<Map>();
public DummySqlRowAction(String actionName, List<KeyValuePair> properties) throws Exception {
super(actionName, properties);
@@ -31,12 +31,12 @@
* @see org.jboss.soa.esb.actions.AbstractSqlRowAction#processSQL()
*/
@Override
- protected Object processResultset(SQLPollResult pollResult) {
+ protected Object process(Map resultSet) {
logger.info("processResultset was called with <<"
- + pollResult.toString()+">>");
- params.add(pollResult);
+ + resultSet.toString()+">>");
+ params.add(resultSet);
- return pollResult;
+ return resultSet;
}
private SimpleDateFormat s_oTS = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS");
Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -31,12 +31,14 @@
import java.net.URISyntaxException;
import java.util.List;
+import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.*;
+import org.jboss.soa.esb.listeners.DirectoryPoller.WorkingFile;
/**
* File copy action.
* <p/>
- * Copy the file specified by the "fileParams" arg in {@link #processFile(Params)} to the location specified by the
+ * Copy the file specified by the "fileParams" arg in {@link #process(File)} to the location specified by the
* action config properties.
* <p/>
* Sample Action Configuration:
@@ -51,6 +53,8 @@
*/
public class FileCopier extends AbstractFileAction {
+ private static Logger logger = Logger.getLogger(FileCopier.class);
+
private static final String TMP_SUFFIX = ".notReady";
private static final String PARMS_OUTDIR = "copyToDirURI";
@@ -67,43 +71,60 @@
copyToSuffix = KeyValuePair.getValue(PARMS_OUTSFX, properties);
} // __________________________________
- public void processFile(Params fileParams) throws IOException {
+ public Object process(File file) throws ActionProcessingException {
+ WorkingFile workingFile;
- String inputFileName = fileParams.oInpF.getName();
- File tempFile = File.createTempFile(inputFileName, TMP_SUFFIX, outputDir);
- File outputFile = new File(outputDir, inputFileName + copyToSuffix);
- FileInputStream inputFileStream = new FileInputStream(fileParams.oWrkF);
- FileOutputStream outputFileStream;
+ try {
+ workingFile = (WorkingFile)file;
+ } catch(ClassCastException e) {
+ throw new ActionProcessingException("File must be an instance of " + WorkingFile.class.getName());
+ }
- outputFileStream = new FileOutputStream(tempFile);
-
- // Perform Copy
- byte[] ba = new byte[50000];
- while (true) {
- int iQ = inputFileStream.read(ba);
+ File outputFile = new File(outputDir, workingFile.getInputFile().getName() + copyToSuffix);
+
+ try {
+ File tempFile = File.createTempFile(workingFile.getName(), TMP_SUFFIX, outputDir);
+ FileInputStream inputFileStream = new FileInputStream(workingFile);
+ FileOutputStream outputFileStream;
- if (iQ < 0) {
- break;
+ outputFileStream = new FileOutputStream(tempFile);
+
+ // Perform Copy
+ byte[] ba = new byte[50000];
+ while (true) {
+ int iQ = inputFileStream.read(ba);
+
+ if (iQ < 0) {
+ break;
+ }
+
+ outputFileStream.write(ba, 0, iQ);
}
-
- outputFileStream.write(ba, 0, iQ);
+ // Close
+ inputFileStream.close();
+ outputFileStream.close();
+
+ // Rename
+ outputFile.delete();
+ tempFile.renameTo(outputFile);
+
+ if(logger.isDebugEnabled()) {
+ logger.debug("Successfully copied file " + workingFile.getAbsolutePath() + " to file " + outputFile.getAbsolutePath());
+ }
+ } catch(IOException e) {
+ throw new ActionProcessingException("IOException copying " + workingFile.getAbsolutePath() + " to " + outputFile.getAbsolutePath(), e);
}
- // Close
- inputFileStream.close();
- outputFileStream.close();
-
- // Rename
- outputFile.delete();
- tempFile.renameTo(outputFile);
+
+ return workingFile;
} // __________________________________
public Serializable getOkNotification(Object message) {
- return "File " + ((Params)message).oInpF
+ return "File " + ((File)message).getAbsolutePath()
+ " successfully copied to all destinations";
}
public Serializable getErrorNotification(Object message) {
- return "Problems copying " + ((Params)message).oInpF
+ return "Problems copying " + ((File)message).getAbsolutePath()
+ " to configured destinations";
}
Added: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -0,0 +1,95 @@
+/*
+ * 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;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.listeners.DirectoryPoller.WorkingFile;
+
+/**
+ * File data to byte array reader {@link org.jboss.soa.esb.actions.ActionProcessor}.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class FileToByteArray extends AbstractFileAction {
+
+ /**
+ * Logger.
+ */
+ private static Logger logger = Logger.getLogger(FileToByteArray.class);
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.AbstractFileAction#process(java.io.File)
+ */
+ @Override
+ protected Object process(File file) throws ActionProcessingException {
+ ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream();
+ FileInputStream fileInputStream = null;
+
+ try {
+ fileInputStream = new FileInputStream(file);
+ } catch (FileNotFoundException e) {
+ throw new ActionProcessingException("IOException reading file contents. File not found.", e);
+ }
+
+ try {
+ byte[] readBuffer = new byte[512];
+ int readCount = 0;
+
+ while((readCount = fileInputStream.read(readBuffer)) != -1) {
+ outputBuffer.write(readBuffer, 0, readCount);
+ }
+ } catch (IOException e) {
+ throw new ActionProcessingException("IOException reading file contents.", e);
+ } finally {
+ try {
+ fileInputStream.close();
+ } catch (IOException e) {
+ logger.warn("Error closing input file.", e);
+ }
+ }
+
+ return outputBuffer.toByteArray();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+ */
+ public Serializable getOkNotification(Object message) {
+ return "Successfully read file contents of " + ((WorkingFile)message).getInputFile() + " into byte array.";
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+ */
+ public Serializable getErrorNotification(Object message) {
+ return "Failed to read file contents of " + ((WorkingFile)message).getInputFile() + " into byte array.";
+ }
+
+}
Added: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -0,0 +1,199 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.common.SystemProperties;
+import org.jboss.soa.esb.helpers.AppServerContext;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * JSM Routing Action Processor.
+ * <p/>
+ * Sample Action Configuration:
+ * <pre>
+ * <Action name="Route-To-Invoicing" processor="JMSRouter">
+ * <property name="jndiName" value="queue/A" />
+ * <property name="message-prop:jms-selector" value="incoming-invoice" />
+ * </Action>
+ * </pre>
+ * Note how properties to be set on the message are prefixed with "message-prop:".
+ * <p/>
+ * TODO: Add support for JMS Topis destinations.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class JMSRouter implements ActionProcessor {
+ /**
+ * Logger.
+ */
+ private static Logger logger = Logger.getLogger(JMSRouter.class);
+ /**
+ * Routing properties.
+ */
+ private List<KeyValuePair> properties;
+ /**
+ * JMS Queue setup.
+ */
+ private JMSSendQueueSetup queueSetup;
+
+ /**
+ * Public constructor.
+ * @param actionName Action name.
+ * @param properties Action properties.
+ * @throws ConfigurationException Queue name not configured.
+ * @throws JMSException
+ * @throws NamingException
+ */
+ public JMSRouter(String actionName, List<KeyValuePair> properties) throws ConfigurationException, NamingException, JMSException {
+ this.properties = properties;
+
+ String queueName = KeyValuePair.getValue("jndiName", properties);
+ if(queueName == null) {
+ throw new ConfigurationException("JMSRouter must specify a 'jndiName' property.");
+ }
+ queueSetup = new JMSSendQueueSetup(queueName);
+ this.properties = properties;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+ */
+ public Object process(Object message) throws ActionProcessingException {
+ if(!(message instanceof Serializable)) {
+ throw new ActionProcessingException("Cannot send Object [" + message.getClass().getName() + "] to destination [" + queueSetup.queueName + "]. Object must be serializable.");
+ }
+
+ try {
+ // Send a Text or Object message to the queue...
+ if (message instanceof String) {
+ TextMessage oMsg = queueSetup.jmsSession.createTextMessage();
+
+ if(logger.isDebugEnabled()) {
+ logger.debug("Sending Text message: [" + message + "] to destination [" + queueSetup.queueName + "].");
+ }
+ oMsg.setText((String)message);
+ setStringProperties(oMsg);
+ queueSetup.jmsProducer.send(oMsg);
+ } else {
+ ObjectMessage oMsg = queueSetup.jmsSession.createObjectMessage();
+
+ if(logger.isDebugEnabled()) {
+ logger.debug("Sending Object message: [" + message + "] to destination [" + queueSetup.queueName + "].");
+ }
+ oMsg.setObject((Serializable) message);
+ setStringProperties(oMsg);
+ queueSetup.jmsProducer.send(oMsg);
+ }
+ } catch(Exception e) {
+ String errorMessage = "Exception while sending message [" + message + "] to destination [" + queueSetup.queueName + "].";
+ logger.error(errorMessage, e);
+ throw new ActionProcessingException(errorMessage, e);
+ }
+
+ return message;
+ }
+
+ private void setStringProperties(Message msg) throws JMSException {
+ String messagePropPrefix = "message-prop:";
+
+ for(KeyValuePair property : properties) {
+ String key = property.getKey();
+
+ if(key.startsWith(messagePropPrefix) && key.length() > messagePropPrefix.length()) {
+ msg.setStringProperty(key.substring(messagePropPrefix.length()), property.getValue());
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+ */
+ public Serializable getOkNotification(Object message) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+ */
+ public Serializable getErrorNotification(Object message) {
+ return null;
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ queueSetup.close();
+ super.finalize();
+ }
+
+ private static class JMSSendQueueSetup {
+ QueueSession jmsSession;
+ Queue jmsQueue;
+ MessageProducer jmsProducer;
+ String queueName;
+
+ // TODO: Modify to support topic destinations too
+
+ private JMSSendQueueSetup(String queueName) throws NamingException, JMSException {
+ Context m_oCtx = AppServerContext.getServerContext(
+ SystemProperties.getJndiServerType(),
+ SystemProperties.getJndiServerURL());
+ QueueConnectionFactory qcf = (QueueConnectionFactory) m_oCtx.lookup("ConnectionFactory");
+ QueueConnection oQconn = qcf.createQueueConnection();
+
+ this.queueName = queueName;
+
+ jmsSession = oQconn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ jmsQueue = (Queue) m_oCtx.lookup(queueName);
+ jmsProducer = jmsSession.createSender(jmsQueue);
+ }
+
+ private void close() {
+ try {
+ jmsProducer.close();
+ jmsSession.close();
+ } catch (Exception e) {
+ logger.error("Unable to close JMS Queue Setup.", e);
+ TestCase.fail("Unable to close JMS Queue Setup: " + e.getMessage());
+ }
+ }
+ }
+}
Added: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -0,0 +1,135 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * Object to CSV String processor.
+ * <p/>
+ * Returns a CSV string based on the message object values of the comma separated bean property names
+ * specified in "bean-properties" action property.
+ * <p/>
+ * Sample Action Configuration:
+ * <pre>
+ * <Action name="Customer-To-CSV" processor="ObjectToCSVString">
+ * <property name="bean-properties" value="name,address1,address2,phone" />
+ * </Action>
+ * </pre>
+ * <p/>
+ * TODO: Add support for arrays ala producing the contents of a CSV file.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ObjectToCSVString implements ActionProcessor {
+
+ public static final String BEAN_PROPERTIES_PROP = "bean-properties";
+ private static Logger logger = Logger.getLogger(ObjectToCSVString.class);
+ private List<String> propertyMethodNames = new ArrayList<String>();
+
+ public ObjectToCSVString(String actionName, List<KeyValuePair> properties) throws ConfigurationException {
+ String objectProps = KeyValuePair.getValue(BEAN_PROPERTIES_PROP, properties);
+
+ if(objectProps == null || objectProps.trim().equals("")) {
+ throw new ConfigurationException("Action [" + actionName + "] must specify a comma seperated object bean property list via a '" + BEAN_PROPERTIES_PROP + "' property setting.");
+ }
+
+ // Construct a bean method name list from the configured property name list...
+ String[] propertyNames = objectProps.split(",");
+ StringBuffer methodNameConstructionBuffer = new StringBuffer();
+ for(String propertyName : propertyNames) {
+ propertyName = propertyName.trim();
+
+ if(propertyName.equals("")) {
+ continue;
+ }
+
+ methodNameConstructionBuffer.setLength(0);
+ methodNameConstructionBuffer.append("get");
+ methodNameConstructionBuffer.append(propertyName);
+
+ // Capitalise the 4th char to make it a proper bean method....
+ methodNameConstructionBuffer.setCharAt(3, Character.toUpperCase(methodNameConstructionBuffer.charAt(3)));
+
+ // Add to the set...
+ propertyMethodNames.add(methodNameConstructionBuffer.toString());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+ */
+ public Object process(Object message) throws ActionProcessingException {
+ StringBuffer csv = new StringBuffer();
+ boolean hasAppendStarted = false; // Have we appended a value yet?
+
+ for(String methodName : propertyMethodNames) {
+ Method method;
+
+ if(hasAppendStarted) {
+ csv.append(",");
+ }
+ hasAppendStarted = true;
+
+ // Get the bean method....
+ try {
+ method = message.getClass().getMethod(methodName, new Class[] {});
+ } catch (Exception e) {
+ logger.error("Bean method: " + methodName + " not found/accessible on message object " + message.getClass().getName(), e);
+ continue;
+ }
+
+ // Call the bean method and add the toString of the return to the CSV string....
+ try {
+ Object value = method.invoke(message, new Object[] {});
+ // TODO: Some sort of encoding is required here to make a proper CSV string...
+ csv.append(value != null?value.toString():"");
+ } catch (Exception e) {
+ logger.error("Exception calling bean method: " + methodName, e);
+ }
+ }
+
+ return csv.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+ */
+ public Serializable getOkNotification(Object message) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+ */
+ public Serializable getErrorNotification(Object message) {
+ return null;
+ }
+}
Added: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToFileWriter.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToFileWriter.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToFileWriter.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -0,0 +1,152 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * Object to file writing processor.
+ * <p/>
+ * Writes an Object to a file based on the "file" property specified by the action configuration. This "file"
+ * property can specify a file or directory. If the file is a directory, the class generates a file name based
+ * on the return from a call to {@link java.util.UUID#randomUUID()} and the file extension value specified in
+ * the "ext" property (default of "obj").
+ * <p/>
+ * Sample Action Configuration:
+ * <pre>
+ * <Action name="Write-To-X-File" processor="ObjectToFileWriter">
+ * <property name="file" value="file:///..." /> <!-- File/Directory name. Supports URI or non-URI based names. -->
+ * <property name="append" value="true/false" /> <!-- Only relevant if the file is not a directory. Default of "false". -->
+ * <property name="ext" value="dat" /> <!-- Only relevant if the file is a directory. Default of "obj". -->
+ * </Action>
+ * </pre>
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ObjectToFileWriter implements ActionProcessor {
+
+ public static final String FILE_NAME = "file";
+ public static final String FILE_APPEND = "append";
+ public static final String FILE_EXT = "ext";
+ private static Logger logger = Logger.getLogger(ObjectToFileWriter.class);
+
+ private String actionName;
+ private File file;
+ private boolean append;
+ private String ext;
+
+ public ObjectToFileWriter(String actionName, List<KeyValuePair> properties) throws ConfigurationException {
+ String fileName = KeyValuePair.getValue(FILE_NAME, properties);
+
+ this.actionName = actionName;
+
+ if(fileName == null || fileName.trim().equals("")) {
+ throw new ConfigurationException("Action [" + actionName + "] must specify a '" + FILE_NAME + "' property specifying the name of the output file.");
+ }
+ try {
+ // try it as a URI first...
+ file = new File(new URI(fileName));
+ } catch (Exception e) {
+ // ok, just interpret it as being relative to the cwd...
+ file = new File(fileName);
+ }
+ append = KeyValuePair.getBooleanValue(FILE_APPEND, properties, false);
+ ext = KeyValuePair.getValue(FILE_EXT, properties, "obj");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+ */
+ public Object process(Object message) throws ActionProcessingException {
+ synchronized(file) {
+ File outputFile = getOutputFile();
+ FileWriter fileWriter = null;
+
+ try {
+ fileWriter = new FileWriter(outputFile, append);
+ } catch (IOException e) {
+ throw new ActionProcessingException("Action " + actionName + " failed. Unable to open output file " + outputFile.getAbsolutePath());
+ }
+
+ try {
+ fileWriter.write(message.toString());
+ fileWriter.flush();
+ } catch (IOException e) {
+ throw new ActionProcessingException("Action " + actionName + " failed. Unable to write to output file " + outputFile.getAbsolutePath());
+ } finally {
+ try {
+ fileWriter.close();
+ } catch (IOException e) {
+ logger.warn("Exception on closing file " + file.getAbsolutePath(), e);
+ }
+ }
+
+ return message;
+ }
+ }
+
+ /**
+ * Get the output file.
+ * @return Output file.
+ */
+ private File getOutputFile() {
+ if(file.isDirectory()) {
+ UUID randomUUID = UUID.randomUUID();
+ File randomFile = new File(file, randomUUID.toString() + "." + ext);
+
+ if(randomFile.exists()) {
+ return getOutputFile();
+ }
+
+ return randomFile;
+ } else {
+ return file;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+ */
+ public Serializable getOkNotification(Object message) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+ */
+ public Serializable getErrorNotification(Object message) {
+ return null;
+ }
+
+}
Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractListener.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractListener.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractListener.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -156,9 +156,6 @@
* <p/>
* Runs the actions in a listeners "actions" config on a message payload message 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
- * overall cleanup of these classes. Lots of duplicate code etc.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
* @since Version 4.0
@@ -191,6 +188,7 @@
// Run the message through each ActionProcessor...
for(String action : m_oActions) {
ActionDefinition actionDefinition;
+ Object processingResult = null;
currentAction = action.trim();
actionDefinition = m_oActionDefinitionFactory.getInstance(currentAction);
@@ -201,7 +199,7 @@
// The processing result of each action feeds into the processing of the next action...
currentProcessor = actionDefinition.getProcessor();
try {
- message = currentProcessor.process(message);
+ processingResult = currentProcessor.process(message);
} catch (Exception e) {
GpListener.notifyError(listenerConfig, e, currentProcessor.getErrorNotification(message));
throw e;
@@ -213,10 +211,13 @@
}
// Notify on all processors. May want to do this differently in the future i.e. more selectively ...
GpListener.notifyOK(listenerConfig, currentProcessor.getOkNotification(message));
+
+ // Setup the message for processing by the next processor...
+ message = processingResult;
}
} catch(Throwable thrown) {
processingError(initialMessage, currentProcessor, thrown);
- logger.error("Premature termination of action processing pipeline [" + Arrays.asList(m_oActions) + "]. Action [" + currentAction + "] thre an exception.", thrown);
+ logger.error("Premature termination of action processing pipeline [" + Arrays.asList(m_oActions) + "]. Action [" + currentAction + "] threw an exception.", thrown);
}
processingComplete(initialMessage);
Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/DirectoryPoller.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/DirectoryPoller.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/DirectoryPoller.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -28,10 +28,8 @@
import java.util.*;
import org.jboss.soa.esb.util.*;
-import org.jboss.soa.esb.actions.AbstractFileAction;
import org.jboss.soa.esb.actions.ActionDefinitionFactory;
import org.jboss.soa.esb.actions.ActionProcessor;
-import org.jboss.soa.esb.actions.AbstractFileAction.Params;
import org.jboss.soa.esb.helpers.*;
public class DirectoryPoller extends AbstractPoller
@@ -59,31 +57,32 @@
/**
*
- * @param p_o Object - Must be a File representing the file that has to be processed
+ * @param inputObject Object - Must be a File representing the file that has to be processed
* @return Object - an array of 3 Files containing:
* <p/>[0] renamed file (workSuffix appended to input file name)
* <p/>[1] target file name in case actionClass is unable to complete successfuly
* <p/>[2] target file name in case actionClass finishes successfuly
*/
@Override
- public Object preProcess(Object p_o)
+ public Object preProcess(Object inputObject)
{
- if (!(p_o instanceof File))
+ if (!(inputObject instanceof File)) {
return null;
- File oF = (File)p_o;
- File oNameWrk = new File (oF.getParentFile(),oF.getName()+m_sWrkSfx);
+ }
+
+ File inputFile = (File)inputObject;
+ WorkingFile workingFile = new WorkingFile(inputFile.getParentFile(), inputFile.getName() + m_sWrkSfx);
-
- if (! oF.renameTo(oNameWrk))
+ if (!inputFile.renameTo(workingFile)) {
return null;
- AbstractFileAction.Params oCurr = new AbstractFileAction.Params();
- oCurr.bPostDelete = m_bPostDel;
- oCurr.oInpF = oF;
- oCurr.oWrkF = oNameWrk;
- oCurr.oErrF = new File (m_oErrorDir ,oF.getName()+m_sErrSfx);
- oCurr.oDoneF = new File (m_oPostDir ,oF.getName()+m_sPostSfx);
+ }
+
+ workingFile.postDelete = m_bPostDel;
+ workingFile.inputFile = inputFile;
+ workingFile.errorFile = new File (m_oErrorDir ,inputFile.getName()+m_sErrSfx);
+ workingFile.outputFile = new File (m_oPostDir ,inputFile.getName()+m_sPostSfx);
- return oCurr;
+ return workingFile;
} //________________________________
@Override
@@ -188,6 +187,9 @@
*/
@Override
protected void processingError(Object initialMessage, ActionProcessor processor, Throwable error) {
+ WorkingFile workingFile = (WorkingFile) initialMessage;
+
+ workingFile.renameToError();
}
/* (non-Javadoc)
@@ -195,14 +197,54 @@
*/
@Override
protected void processingComplete(Object initialMessage) {
- AbstractFileAction.Params fileParams = (Params) initialMessage;
+ WorkingFile workingFile = (WorkingFile) initialMessage;
// Delete or rename the file...
- if (fileParams.bPostDelete) {
- fileParams.oWrkF.delete();
+ if (workingFile.postDelete) {
+ workingFile.delete();
} else {
- AbstractFileAction.renameToDone(fileParams);
+ workingFile.renameToOutputFile();
}
}
-
-} //____________________________________________________________________________
+
+ /**
+ * Working file.
+ * <p/>
+ * Once the directory poller picks up on an input file, it immediately renames it to a working file
+ * in order to avoid a situation where the file gets processed again.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+ public static class WorkingFile extends File {
+ private static final long serialVersionUID = 1L;
+
+ private boolean postDelete;
+
+ private File inputFile, errorFile, outputFile;
+
+ public WorkingFile(String filename) {
+ super(filename);
+ }
+
+ public WorkingFile(File parentFile, String filename) {
+ super(parentFile, filename);
+ }
+
+ private boolean renameToError() {
+ return renameTo(errorFile);
+ }
+
+ private boolean renameToOutputFile() {
+ return renameTo(outputFile);
+ }
+
+ /**
+ * Get the File instance representing the original input file.
+ * @return Original input file.
+ */
+ public File getInputFile() {
+ return inputFile;
+ }
+ }
+}
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-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -561,6 +561,10 @@
* Serializable - Will constitute the body of the notification
*/
public static void notifyOK(DomElement p_oP, Serializable p_oSer) {
+ if(p_oSer == null) {
+ return;
+ }
+
try {
Serializable oNotif = p_oSer;
for (DomElement oCurr : p_oP
@@ -587,8 +591,11 @@
* Serializable - Will be included at the beginning of the body
* of the notification
*/
- public static void notifyError(DomElement p_oP, Exception p_e,
- Serializable p_oSer) {
+ public static void notifyError(DomElement p_oP, Exception p_e, Serializable p_oSer) {
+ if(p_oSer == null) {
+ return;
+ }
+
Serializable oNotif = p_oSer;
ByteArrayOutputStream oBO = new ByteArrayOutputStream();
PrintStream oPS = new PrintStream(oBO);
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-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -26,6 +26,7 @@
import javax.jms.*;
import org.jboss.soa.esb.actions.ActionDefinitionFactory;
+import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.actions.ActionProcessor;
import org.jboss.soa.esb.helpers.*;
@@ -129,8 +130,22 @@
// REVIEW: Can this really happen i.e. the JMS
continue;
}
-
- return new Object[] {jmsMessage};
+
+ if (jmsMessage instanceof ObjectMessage) {
+ try {
+ return new Object[] {((ObjectMessage)jmsMessage).getObject()};
+ } catch (JMSException e) {
+ logger.error("Failed to read Serialized Object from JMS message.", e);
+ }
+ } else if (jmsMessage instanceof TextMessage) {
+ try {
+ return new Object[] {((TextMessage)jmsMessage).getText()};
+ } catch (JMSException e) {
+ logger.error("Failed to read Serialized Object from JMS message.", e);
+ }
+ } else {
+ logger.error("Unsupported JMS message type: " + jmsMessage.getClass().getName());
+ }
}
return null;
Modified: labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -262,7 +262,6 @@
// Set up the parameter object for the SqlRowAction
rowParams.sUpdStates = m_sUpdStates;
- rowParams.saCols = m_saCols;
rowParams.saKeys = m_saKeys;
rowParams.sSel4Upd = sSel4U;
rowParams.sUpdate = sUpdStmt;
@@ -405,12 +404,12 @@
((SQLPollResult)initialMessage).changeStatusToDone();
}
- public class SQLPollResult extends LinkedHashMap implements Serializable {
+ private class SQLPollResult extends LinkedHashMap implements Serializable {
private static final long serialVersionUID = 1L;
private String sUpdStates;
- private String[] saCols, saKeys;
+ private String[] saKeys;
private String sSel4Upd, sUpdate;
Added: labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ByteArrayToStringUnitTest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ByteArrayToStringUnitTest.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ByteArrayToStringUnitTest.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+import junit.framework.TestCase;
+
+/**
+ * ByteArrayToString unit tests.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ByteArrayToStringUnitTest extends TestCase {
+
+ public void test() throws ActionProcessingException {
+ List<KeyValuePair> properties = new ArrayList<KeyValuePair>();
+
+ properties.add(new KeyValuePair("encoding", "UTF-8"));
+ ByteArrayToString byteArrayToString = new ByteArrayToString("actionName", properties);
+
+ String decodedBytes = (String)byteArrayToString.process("TestString".getBytes());
+ assertEquals("TestString", decodedBytes);
+ }
+}
Added: labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/FileToByteArrayUnitTest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/FileToByteArrayUnitTest.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/FileToByteArrayUnitTest.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -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.actions;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+/**
+ * FileToByteArray unit tests.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class FileToByteArrayUnitTest extends TestCase {
+
+ private File testFile = null;
+ private String FILE_CONTENTS = "this is the file contents!";
+
+ @Override
+ protected void setUp() throws Exception {
+ testFile = new File("FileToByteArrayUnitTest.tst");
+
+ FileWriter fileWriter = new FileWriter(testFile);
+
+ fileWriter.write(FILE_CONTENTS);
+ fileWriter.flush();
+ fileWriter.close();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ testFile.delete();
+ }
+
+ public void test() throws IOException, ActionProcessingException {
+ FileToByteArray fileToByteArray = new FileToByteArray();
+ byte[] fileContent = (byte[])fileToByteArray.process(testFile);
+
+ assertEquals(FILE_CONTENTS, new String(fileContent));
+ }
+}
Added: labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToCSVStringUnitTest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToCSVStringUnitTest.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToCSVStringUnitTest.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -0,0 +1,74 @@
+/*
+ * 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;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+import junit.framework.TestCase;
+
+/**
+ * ObjectToCSVString unit tests.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ObjectToCSVStringUnitTest extends TestCase {
+
+ public void test() throws ConfigurationException, ActionProcessingException {
+ List<KeyValuePair> properties = new ArrayList<KeyValuePair>();
+
+ properties.add(new KeyValuePair(ObjectToCSVString.BEAN_PROPERTIES_PROP, "name"));
+ ObjectToCSVString processor = new ObjectToCSVString("ObjectToCSVString", properties);
+ assertEquals("Tom Fennelly", processor.process(new TestBean()));
+
+ properties.clear();
+ properties.add(new KeyValuePair(ObjectToCSVString.BEAN_PROPERTIES_PROP, "name,age"));
+ processor = new ObjectToCSVString("ObjectToCSVString", properties);
+ assertEquals("Tom Fennelly,21", processor.process(new TestBean()));
+
+ properties.clear();
+ properties.add(new KeyValuePair(ObjectToCSVString.BEAN_PROPERTIES_PROP, "id,name,phone,age"));
+ processor = new ObjectToCSVString("ObjectToCSVString", properties);
+ assertEquals(",Tom Fennelly,,21", processor.process(new TestBean()));
+
+ properties.clear();
+ properties.add(new KeyValuePair(ObjectToCSVString.BEAN_PROPERTIES_PROP, "id"));
+ processor = new ObjectToCSVString("ObjectToCSVString", properties);
+ assertEquals("", processor.process(new TestBean()));
+ }
+
+ private class TestBean {
+ private String name = "Tom Fennelly";
+ private int age = 21; // hehehehe
+
+ public int getAge() {
+ return age;
+ }
+ public String getName() {
+ return name;
+ }
+ }
+}
Added: labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToFileWriterUnitTest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToFileWriterUnitTest.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToFileWriterUnitTest.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -0,0 +1,88 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.listeners.DirectoryPoller.WorkingFile;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for ObjectToFileWriter.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ObjectToFileWriterUnitTest extends TestCase {
+
+ private static final String FILE_CONTENTS = "write something to file";
+ private File file = new File("./ObjectToFileWriter.tst");
+ private List<KeyValuePair> properties;
+
+ @Override
+ protected void setUp() throws Exception {
+ properties = new ArrayList<KeyValuePair>();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ file.delete();
+ }
+
+ public void test_writeWithNoAppend() throws ConfigurationException, ActionProcessingException {
+ properties.add(new KeyValuePair("file", file.getPath()));
+
+ // Write something fo file and check it was written..
+ writeAndCheck(FILE_CONTENTS);
+ // And do it all again to make sure the contents are not appended i.e. the file is overwritten...
+ writeAndCheck(FILE_CONTENTS);
+ }
+
+ public void test_writeWithAppend() throws ConfigurationException, ActionProcessingException {
+ properties.add(new KeyValuePair("file", file.getPath()));
+ properties.add(new KeyValuePair("append", "true"));
+
+ // Write something fo file and check it was written..
+ writeAndCheck(FILE_CONTENTS);
+ // And do it all again to make sure the contents are appended i.e. the file is not overwritten...
+ writeAndCheck(FILE_CONTENTS + FILE_CONTENTS);
+ }
+
+
+ private void writeAndCheck(String expected) throws ConfigurationException, ActionProcessingException {
+ // Use the ObjectToFileWriter to write something to file...
+ ObjectToFileWriter fileWriter = new ObjectToFileWriter("ObjectToFileWriter-Test", properties);
+ fileWriter.process(FILE_CONTENTS);
+
+ // Use the FileToByteArray processor to read the file contents back...
+ FileToByteArray fileToByteArray = new FileToByteArray();
+ byte[] fileContent = (byte[])fileToByteArray.process(file);
+
+ // Make sure the contents are ass expected...
+ assertEquals(expected, new String(fileContent));
+ }
+}
Modified: labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -32,7 +32,7 @@
public int historyLength;
public int loanAmount;
public int loanTerm;
- private String customerUID;
+ public String customerUID;
/**
* Gets for the credit score.
Modified: labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml.template
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml.template 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml.template 2006-09-18 15:22:45 UTC (rev 6274)
@@ -18,7 +18,9 @@
<CreditAgencyJMSInput
listenerClass="org.jboss.soa.esb.listeners.JmsQueueListener"
- actionClass="org.jboss.soa.esb.samples.loanbroker.actions.ProcessCreditRequest"
+
+ actions="ProcessCreditCheckRequest, Route-CreditCheckResponse-To-CreditCheckResponseProcessor"
+
maxThreads="3"
queueConnFactoryClass="ConnectionFactory"
listenJndiType="jboss"
@@ -26,18 +28,13 @@
listenQueue="queue/A"
listenMsgSelector="sample_loanbroker_servicecode='creditRequest'"
>
- <NotificationList type="OK">
- <target class="NotifyQueues" >
- <queue jndiName="queue/A">
- <messageProp name="sample_loanbroker_servicecode" value="creditResponse" />
- </queue>
- </target>
- </NotificationList>
</CreditAgencyJMSInput>
<CreditAgencyJMSOutput
- listenerClass="org.jboss.soa.esb.listeners.JmsQueueListener"
- actionClass="org.jboss.soa.esb.samples.loanbroker.actions.ProcessCreditResponse"
+ listenerClass="org.jboss.soa.esb.listeners.JmsQueueListener"
+
+ actions="CreditCheckResponse-To-BankQuote, Route-BankQuote-To-JMSBank-Router, BankQuote-To-CSV, Route-BankQuote-CSV-To-FileBank"
+
maxThreads="1"
queueConnFactoryClass="ConnectionFactory"
listenJndiType="jboss"
@@ -52,9 +49,25 @@
</NotificationList>
</CreditAgencyJMSOutput>
+<ToJMSBankRouter
+ listenerClass="org.jboss.soa.esb.listeners.JmsQueueListener"
+
+ actions="ObjectToXStream, Route-BankQuote-XML-To-JMSBank"
+
+ maxThreads="1"
+ queueConnFactoryClass="ConnectionFactory"
+ listenJndiType="jboss"
+ listenJndiURL="@jndi.host@"
+ listenQueue="queue/A"
+ listenMsgSelector="sample_loanbroker_servicecode='BankQuoteObject'"
+>
+</ToJMSBankRouter>
+
<BanksJMSResponse
- listenerClass="org.jboss.soa.esb.listeners.JmsQueueListener"
- actionClass="org.jboss.soa.esb.samples.loanbroker.actions.ProcessBanksJMSResponse"
+ listenerClass="org.jboss.soa.esb.listeners.JmsQueueListener"
+
+ actions="BankQuoteResponseXML-To-BankQuoteResponse, Process-BankQuote"
+
maxThreads="1"
queueConnFactoryClass="ConnectionFactory"
listenJndiType="jboss"
@@ -69,9 +82,11 @@
</BanksJMSResponse>
<BanksFilePoller
- listenerClass="org.jboss.soa.esb.listeners.DirectoryPoller"
- actionClass="org.jboss.soa.esb.samples.loanbroker.actions.ProcessBanksFileResponse"
- pollLatencySecs="5"
+ listenerClass="org.jboss.soa.esb.listeners.DirectoryPoller"
+
+ actions="FileToByteArray, Bytes-To-UTF-8-String, BankQuoteResponseCSV-To-BankQuoteResponse, Process-BankQuote"
+
+ pollLatencySecs="5"
maxThreads="2"
inputDirURI="@cwd.uri@@trail.runtime.dir@/BankInput/outgoing"
inputSuffix=".dat"
@@ -97,8 +112,63 @@
/>
</target>
</NotificationList>
- </BanksFilePoller>
+</BanksFilePoller>
+ <Actions>
+ <Action name="ProcessCreditCheckRequest" processor="CreditRequestProcessor" />
+
+ <Action name="Route-CreditCheckResponse-To-CreditCheckResponseProcessor" processor="JMSRouter">
+ <property name="jndiName" value="queue/A" />
+ <property name="message-prop:sample_loanbroker_servicecode" value="creditResponse" />
+ </Action>
+
+ <Action name="CreditCheckResponse-To-BankQuote" processor="CreditResponseProcessor" />
+
+ <Action name="Route-BankQuote-To-JMSBank-Router" processor="JMSRouter">
+ <property name="jndiName" value="queue/A" />
+ <property name="message-prop:sample_loanbroker_servicecode" value="BankQuoteObject" />
+ </Action>
+
+ <Action name="Route-BankQuote-XML-To-JMSBank" processor="JMSRouter">
+ <property name="jndiName" value="queue/C" />
+ </Action>
+
+ <Action name="BankQuote-To-CSV" processor="ObjectToCSVString">
+ <property name="bean-properties" value="ssn,creditScore,historyLength,loanAmount,loanTerm,customerUID" />
+ </Action>
+
+ <Action name="Route-BankQuote-CSV-To-FileBank" processor="ObjectToFileWriter">
+ <property name="file" value="./@trail.runtime.dir@/BankInput" />
+ <property name="ext" value="dat" />
+ </Action>
+
+ <Action name="ObjectToXStream" processor="ObjectToXStream" />
+
+ <Action name="FileToByteArray" processor="FileToByteArray" />
+
+ <Action name="Bytes-To-UTF-8-String" processor="ByteArrayToString">
+ <property name="encoding" value="UTF-8" />
+ </Action>
+
+ <Action name="BankQuoteResponseCSV-To-BankQuoteResponse" processor="ToBankQuoteResponse" />
+ <Action name="BankQuoteResponseXML-To-BankQuoteResponse" processor="ToBankQuoteResponse" />
+
+ <Action name="Process-BankQuote" processor="ProcessBanksResponse" />
+
+ <ProcessorAliases>
+ <Alias name="CreditRequestProcessor" class="org.jboss.soa.esb.samples.loanbroker.actions.ProcessCreditRequest" />
+ <Alias name="JMSRouter" class="org.jboss.soa.esb.actions.JMSRouter" />
+ <Alias name="CreditResponseProcessor" class="org.jboss.soa.esb.samples.loanbroker.actions.ProcessCreditResponse" />
+ <Alias name="ObjectToCSVString" class="org.jboss.soa.esb.actions.ObjectToCSVString" />
+ <Alias name="ObjectToFileWriter" class="org.jboss.soa.esb.actions.ObjectToFileWriter" />
+ <Alias name="FileToByteArray" class="org.jboss.soa.esb.actions.FileToByteArray" />
+ <Alias name="ByteArrayToString" class="org.jboss.soa.esb.actions.ByteArrayToString" />
+ <Alias name="ObjectToXStream" class="org.jboss.soa.esb.samples.loanbroker.actions.ObjectToXStream" />
+ <Alias name="ToBankQuoteResponse" class="org.jboss.soa.esb.samples.loanbroker.actions.ToBankQuoteResponse" />
+ <Alias name="ProcessBanksResponse" class="org.jboss.soa.esb.samples.loanbroker.actions.ProcessBanksResponse" />
+ </ProcessorAliases>
+ </Actions>
+
<EmailProperties
org.jboss.soa.esb.mail.smtp.host="@smtp.host@"
org.jboss.soa.esb.mail.smtp.port="@smtp.port@"
Added: labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ObjectToXStream.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ObjectToXStream.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ObjectToXStream.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -0,0 +1,65 @@
+/*
+ * 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.samples.loanbroker.actions;
+
+import java.io.Serializable;
+
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+
+import com.thoughtworks.xstream.XStream;
+
+/**
+ * Object to XML processor.
+ * <p/>
+ * Uses the XStream processor to generate an XML message String from the supplied object.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ObjectToXStream implements ActionProcessor {
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+ */
+ public Object process(Object object) throws ActionProcessingException {
+ XStream xstream = new XStream();
+ xstream.alias(object.getClass().getName(), object.getClass());
+
+ return xstream.toXML(object);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+ */
+ public Serializable getOkNotification(Object message) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+ */
+ public Serializable getErrorNotification(Object message) {
+ return null;
+ }
+}
Added: labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksResponse.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksResponse.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksResponse.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -0,0 +1,100 @@
+/*
+ * 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.samples.loanbroker.actions;
+
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.common.SystemProperties;
+import org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteResponse;
+import org.jboss.soa.esb.samples.loanbroker.domain.Customer;
+import org.jboss.soa.esb.samples.loanbroker.domain.LoanOffer;
+import org.jboss.soa.esb.services.IpersistHandler;
+import org.jboss.soa.esb.services.PersistHandlerFactory;
+
+public class ProcessBanksResponse implements ActionProcessor {
+
+ private static Logger logger = Logger.getLogger(ProcessBanksResponse.class);
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+ */
+ public Object process(Object message) throws ActionProcessingException {
+ BankQuoteResponse bankResponse;
+
+ try {
+ bankResponse = (BankQuoteResponse) message;
+ } catch(ClassCastException e) {
+ throw new ActionProcessingException("Message must be a " + BankQuoteResponse.class.getName() + ". Is " + message.getClass().getName());
+ }
+
+ try {
+ // get handle to the JBossESB Event object store
+ IpersistHandler esbHandler = PersistHandlerFactory.getPersistHandler("remote",
+ SystemProperties.getJndiServerType(),
+ SystemProperties.getJndiServerURL());
+
+ Customer customer = (Customer) esbHandler.getObject(org.jboss.soa.esb.samples.loanbroker.domain.Customer.class, bankResponse.customerUID);
+ logger.info(this.getClass().getSimpleName() + " -- Business Object BEFORE Loan Offer is added: \n" + customer.toDTO().toXml());
+
+ //now update this Customer with a LoanOffer based on the response from the Bank
+ LoanOffer offer = new LoanOffer((String)null);
+ offer.setField(LoanOffer.ATTRIB.interestRate, (bankResponse.interestRate).toString());
+ offer.setField(LoanOffer.ATTRIB.quoteId, bankResponse.quoteId);
+ offer.setField(LoanOffer.ATTRIB.errorCode, Integer.toString(bankResponse.errorCode));
+ //
+ customer.addOffer(offer);
+ esbHandler.rplObject(customer); //update the object store
+ logger.info(this.getClass().getSimpleName() + " -- Business Object AFTER Loan Offer is added: \n" + customer.toDTO().toXml());
+
+
+ if (customer.getOfferCount() >= 2) //no more quotes expected so send an email
+ {
+ // TODO: Break the email sending out into a standalone action...
+ ProcessEmail email = new ProcessEmail(customer);
+ email.sendEmail();
+ }
+ } catch (Exception e) {
+ throw new ActionProcessingException("Exception processing quote.", e);
+ }
+
+ return message;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+ */
+ public Serializable getOkNotification(Object arg0) {
+ return "OK NOTIF: " + this.getClass().getSimpleName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+ */
+ public Serializable getErrorNotification(Object arg0) {
+ return "ERR NOTIFICATION: "+this.getClass().getSimpleName();
+ }
+}
Modified: labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -25,84 +25,48 @@
import java.io.Serializable;
import java.util.Random;
-import javax.jms.ObjectMessage;
-
-import org.jboss.soa.esb.actions.AbstractAction;
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.listeners.GpListener;
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
import org.jboss.soa.esb.samples.loanbroker.creditagency.CreditCheckRequest;
import org.jboss.soa.esb.samples.loanbroker.creditagency.CreditCheckResponseNotification;
-
-
-public class ProcessCreditRequest extends AbstractAction
-{
- public Integer creditScore;
- private CreditCheckResponseNotification creditResponse;
-
- /*
- * the base class sets up the parameter tree being used by this action class
- */
- public ProcessCreditRequest(DomElement p_oP, Object p_oCurr) throws Exception
- {
- super(p_oP, p_oCurr);
- }
-
- public void run()
- {
- try
- {
- processCurrentObject();
- GpListener.notifyOK(m_oParms,getOkNotification());
- }
- catch (Exception e)
- {
- GpListener.notifyError(m_oParms,e,getErrorNotification());
- }
- finally
- { setChanged();
- notifyObservers(new Integer(-1));
- }
- } //________________________________
-
- @Override
- public void processCurrentObject() throws Exception
- {
- m_oLogger.info("processObject was called with <<"
- +m_oCurr.toString()+">>");
+public class ProcessCreditRequest implements ActionProcessor {
+
+ private static Logger logger = Logger.getLogger(ProcessCreditRequest.class);
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+ */
+ public Object process(Object message) throws ActionProcessingException {
+ logger.info("processObject was called with <<" +message.toString()+">>");
- if (! (m_oCurr instanceof ObjectMessage))
- throw new Exception("Message must be a ObjectMessage");
-// System.out.println(m_oCurr);
- CreditCheckRequest creditRequest = (CreditCheckRequest)((ObjectMessage)m_oCurr).getObject();
+ CreditCheckRequest creditRequest;
+ try {
+ creditRequest = (CreditCheckRequest)message;
+ } catch (ClassCastException e) {
+ throw new ActionProcessingException("Message must be of type " + CreditCheckRequest.class.getName(), e);
+ }
- //use the notification framework to send back our response
//use a dummy score between 0 and 10
Random generator = new Random();
- creditScore = new Integer(generator.nextInt(10));
+ Integer creditScore = new Integer(generator.nextInt(10));
//create our Response
- creditResponse = new CreditCheckResponseNotification(creditRequest.requestID, creditScore, creditRequest.customerID);
-
-
- } //________________________________
-
-
- protected void checkParms() throws Exception
- {
+
+ return new CreditCheckResponseNotification(creditRequest.requestID, creditScore, creditRequest.customerID);
}
-
- //this is how the response is sent back, through OK notification
- //you could also send back a special ERROR credit score condition
- public Serializable getOkNotification()
- {
- return creditResponse.toArray();
- }
-
- @Override
- public Serializable getErrorNotification()
- {
- return "ERR NOTIFICATION: "+this.getClass();
- } //________________________________
-
-
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+ */
+ public Serializable getOkNotification(Object message) {
+ return "OK NOTIFICATION: "+this.getClass();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+ */
+ public Serializable getErrorNotification(Object message) {
+ return "ERR NOTIFICATION: "+this.getClass();
+ }
}
Modified: labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -34,14 +34,14 @@
import javax.jms.TextMessage;
import javax.naming.Context;
-import org.jboss.soa.esb.actions.AbstractAction;
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
import org.jboss.soa.esb.common.SystemProperties;
import org.jboss.soa.esb.helpers.AppServerContext;
-import org.jboss.soa.esb.helpers.DomElement;
import org.jboss.soa.esb.jboss.loanbroker.util.FileUtil;
-import org.jboss.soa.esb.listeners.GpListener;
import org.jboss.soa.esb.samples.loanbroker.adapters.CustomerAdapter;
-import org.jboss.soa.esb.samples.loanbroker.banks.BanksQuoteRequest;
+import org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteRequest;
import org.jboss.soa.esb.samples.loanbroker.creditagency.CreditCheckResponseNotification;
import org.jboss.soa.esb.samples.loanbroker.domain.CreditRating;
import org.jboss.soa.esb.samples.loanbroker.domain.Customer;
@@ -51,136 +51,59 @@
import com.thoughtworks.xstream.XStream;
-public class ProcessCreditResponse extends AbstractAction {
-
- IpersistHandler esbHandler;
+public class ProcessCreditResponse implements ActionProcessor {
+
+ private static Logger logger = Logger.getLogger(ProcessCreditRequest.class);
- public ProcessCreditResponse(DomElement p_oP, Object p_oCurr) throws Exception {
- super(p_oP, p_oCurr);
- }
-
- public void processCurrentObject() throws Exception
- {
- m_oLogger.info("processObject was called with <<"
- +m_oCurr.toString()+">>");
-
- if (! (m_oCurr instanceof ObjectMessage))
- throw new Exception("Message must be a ObjectMessage");
-// System.out.println(m_oCurr);
-
- //get the credit response information and send to banks
- String[] msg = (String[])((ObjectMessage)m_oCurr).getObject();
- CreditCheckResponseNotification response = CreditCheckResponseNotification.fromArray(msg);
-
-// get handle to the JBossESB Event object store
- esbHandler = PersistHandlerFactory.getPersistHandler("remote",
- SystemProperties.getJndiServerType(),
- SystemProperties.getJndiServerURL());
+ private IpersistHandler esbHandler;
- Customer customer = (Customer) esbHandler.getObject(org.jboss.soa.esb.samples.loanbroker.domain.Customer.class, response.customerUID);
- m_oLogger.info(this.getClass().getSimpleName() + " -- Business Object BEFORE Credit Rating is added: \n" + customer.toDTO().toXml());
- CreditRating rating = new CreditRating((String)null);
- rating.setScore(response.score);
- customer.setRating(rating);
- esbHandler.rplObject(customer); //update the object store
-// Customer customer2 = (Customer) esbHandler.getObject(org.jboss.soa.esb.samples.loanbroker.domain.Customer.class, response.customerUID);
- m_oLogger.info(this.getClass().getSimpleName() + " -- Business Object AFTER Credit Rating is added: \n" + customer.toDTO().toXml());
-// m_oLogger.info(this.getClass().getSimpleName() + " -- Customer2 TEST DEBUG customer2: \n" + customer2.toDTO().toXml());
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+ */
+ public Object process(Object message) throws ActionProcessingException {
+ logger.info("processObject was called with <<" + message + ">>");
- sendJMSToBank(response.customerUID);
- sendFileToBank(response.customerUID);
-
-
- } //________________________________
-
- public Serializable getOkNotification()
- {
- return "OK NOTIF: " + this.getClass();
- }
-
- @Override
- public Serializable getErrorNotification()
- {
- return "ERR NOTIFICATION: "+this.getClass();
- } //________________________________
-
- public void run()
- {
- try
- {
- processCurrentObject();
- GpListener.notifyOK(m_oParms,getOkNotification());
- }
- catch (Exception e)
- {
- GpListener.notifyError(m_oParms,e,getErrorNotification());
- }
- finally
- { setChanged();
- notifyObservers(new Integer(-1));
- }
- } //________________________________
-
- private void sendJMSToBank(long customerUID) throws Exception{
+ CreditCheckResponseNotification response;
try {
- Customer customer = (Customer) esbHandler.getObject(org.jboss.soa.esb.samples.loanbroker.domain.Customer.class, customerUID);
- Context ctx = AppServerContext.getServerContext(LoanBrokerConstants.getInstance().getJndiType(),
- LoanBrokerConstants.getInstance().getJndiUrl());
- Queue queue = (Queue) ctx.lookup(LoanBrokerConstants.getInstance().getBankJMSRequestQueue());
- QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
- QueueConnection cnn = factory.createQueueConnection();
- QueueSession sess = cnn.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE);
-
- //get a customer in the format required by the JMS Bank
- BanksQuoteRequest quote = CustomerAdapter.bankQuoteFromCustomer(customer);
- XStream xstream = new XStream();
-
- //we do this alias step below to ensure that the xml stream generated uses the package name expected by the Banks JMS process
- //or it will not be able to deserialize the stream back into the object the bank expects
- xstream.alias("org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteRequest", quote.getClass());
- String bankQuoteRequestXml=xstream.toXML(quote);
-
- TextMessage msg = sess.createTextMessage(bankQuoteRequestXml);
- MessageProducer sender = sess.createSender(queue);
- sender = sess.createSender(queue);
- sender.send(msg);
-
- sess.close();
- cnn.close();
-
- }catch(Exception e) {
- e.printStackTrace();
- }
+ response = (CreditCheckResponseNotification)message;
+ } catch(ClassCastException e) {
+ throw new ActionProcessingException("Message must be a " + CreditCheckResponseNotification.class.getName());
+ }
- }
-
- private void sendFileToBank(long customerUID) throws Exception{
- Customer customer = (Customer) esbHandler.getObject(org.jboss.soa.esb.samples.loanbroker.domain.Customer.class, customerUID);
- File writableDir=null;
- //check to see if we can write to destination first
- File tmpDir = new File(LoanBrokerConstants.getInstance().getBankRequestDir());
- if (tmpDir.exists() && tmpDir.canWrite()) {
- writableDir=tmpDir;
- } else {
- m_oLogger.error("error creating Bank request file");
- this.getErrorNotification();
- return;
- }
- File loanRequestFile = new File(writableDir.getAbsolutePath() + "/"+ customer.getUid() + ".dat");
- if (loanRequestFile.exists()) {
- loanRequestFile.delete();
- }
- try {
- loanRequestFile.createNewFile();
- BanksQuoteRequest quote = CustomerAdapter.bankQuoteFromCustomer(customer);
- String msg=quote.ssn+","+quote.creditScore+","+quote.historyLength+","+quote.loanAmount+","+quote.loanTerm+","+quote.customerUID;
- FileUtil.writeTextFile(loanRequestFile, msg);
- }catch (Exception e) {
- m_oLogger.error(e);
- e.printStackTrace();
- }
- }
-
-
+ try {
+ // get handle to the JBossESB Event object store
+ esbHandler = PersistHandlerFactory.getPersistHandler("remote",
+ SystemProperties.getJndiServerType(),
+ SystemProperties.getJndiServerURL());
+
+ Customer customer = (Customer) esbHandler.getObject(org.jboss.soa.esb.samples.loanbroker.domain.Customer.class, response.customerUID);
+ logger.info(this.getClass().getSimpleName() + " -- Business Object BEFORE Credit Rating is added: \n" + customer.toDTO().toXml());
+ CreditRating rating = new CreditRating((String)null);
+ rating.setScore(response.score);
+ customer.setRating(rating);
+ esbHandler.rplObject(customer); //update the object store
+ // Customer customer2 = (Customer) esbHandler.getObject(org.jboss.soa.esb.samples.loanbroker.domain.Customer.class, response.customerUID);
+ logger.info(this.getClass().getSimpleName() + " -- Business Object AFTER Credit Rating is added: \n" + customer.toDTO().toXml());
+ // m_oLogger.info(this.getClass().getSimpleName() + " -- Customer2 TEST DEBUG customer2: \n" + customer2.toDTO().toXml());
+
+ BankQuoteRequest quote = CustomerAdapter.bankQuoteFromCustomer(customer);
+ return quote;
+ } catch(Exception e) {
+ throw new ActionProcessingException("Failed to process credit check response.", e);
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+ */
+ public Serializable getOkNotification(Object message) {
+ return "OK NOTIF: " + this.getClass();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+ */
+ public Serializable getErrorNotification(Object message) {
+ return "ERR NOTIFICATION: "+this.getClass();
+ }
}
Added: labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ToBankQuoteResponse.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ToBankQuoteResponse.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ToBankQuoteResponse.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -0,0 +1,122 @@
+/*
+ * 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.samples.loanbroker.actions;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.helpers.DomElement;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteResponse;
+
+/**
+ * To {@link org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteResponse} processor.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ToBankQuoteResponse implements ActionProcessor {
+
+ public static final String BANK_QUOTE_RESPONSE_CSV_TO_BANK_QUOTE_RESPONSE = "BankQuoteResponseCSV-To-BankQuoteResponse";
+ public static final String BANK_QUOTE_RESPONSE_XML_TO_BANK_QUOTE_RESPONSE = "BankQuoteResponseXML-To-BankQuoteResponse";
+
+ private String actionName;
+
+ public ToBankQuoteResponse(String actionName, List<KeyValuePair> properties) {
+ this.actionName = actionName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+ */
+ public Object process(Object messageIn) throws ActionProcessingException {
+ BankQuoteResponse bankResponse;
+ String message;
+
+ try {
+ message = (String)messageIn;
+ } catch(ClassCastException e) {
+ throw new ActionProcessingException("Message must be a " + String.class.getName() + ". Is " + messageIn.getClass().getName());
+ }
+
+ if(actionName.equalsIgnoreCase(BANK_QUOTE_RESPONSE_XML_TO_BANK_QUOTE_RESPONSE)) {
+ bankResponse = fromXML(message);
+ } else if(actionName.equalsIgnoreCase(BANK_QUOTE_RESPONSE_CSV_TO_BANK_QUOTE_RESPONSE)) {
+ bankResponse = fromCSV(message);
+ } else {
+ throw new ActionProcessingException("Unsupported Transformation: " + actionName);
+ }
+
+ return bankResponse;
+ }
+
+ private BankQuoteResponse fromXML(String message) throws ActionProcessingException {
+ DomElement oEl=null;
+ BankQuoteResponse response = new BankQuoteResponse();
+
+ try {
+ oEl = DomElement.fromXml(message);
+
+ response.interestRate = BigDecimal.valueOf(Double.parseDouble(oEl.getTextChildren("interestRate")[0]));
+ response.quoteId = oEl.getTextChildren("quoteId")[0];
+ response.errorCode = Integer.parseInt(oEl.getTextChildren("errorCode")[0]);
+ response.customerUID = Long.parseLong(oEl.getTextChildren("customerUID")[0]);
+ } catch (Exception e) {
+ throw new ActionProcessingException("Failed to parse BankQuoteResponse XML:\n" + message, e);
+ }
+
+ return response;
+ }
+
+ private BankQuoteResponse fromCSV(String message) {
+ BankQuoteResponse response = new BankQuoteResponse();
+ String[] csvParts = message.split(","); // TODO: This is obviously very dodgy - there should a decoding step!!
+
+ response.interestRate = BigDecimal.valueOf(Double.parseDouble(csvParts[0]));
+ response.quoteId = csvParts[1];
+ response.errorCode = Integer.parseInt(csvParts[2]);
+ response.customerUID = Long.parseLong(csvParts[3]);
+
+ return response;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+ */
+ public Serializable getOkNotification(Object message) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+ */
+ public Serializable getErrorNotification(Object message) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Modified: labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -30,8 +30,8 @@
import org.jboss.soa.esb.common.bizclasses.OneValue;
import org.jboss.soa.esb.common.bizclasses.Person;
import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.samples.loanbroker.banks.BanksQuoteRequest;
-import org.jboss.soa.esb.samples.loanbroker.banks.BanksQuoteResponse;
+import org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteRequest;
+import org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteResponse;
import org.jboss.soa.esb.samples.loanbroker.domain.CreditRating;
import org.jboss.soa.esb.samples.loanbroker.domain.Customer;
import org.jboss.soa.esb.samples.loanbroker.web.WebCustomer;
@@ -103,23 +103,23 @@
return new WebCustomer(sName,sAddr,sEmployer,dSalary,iLoanDur,dAmount,ssn,email);
}//_________________________________________
- public static BanksQuoteRequest bankQuoteFromCustomer(Customer p_o) {
- BanksQuoteRequest bankRequest = new BanksQuoteRequest();
+ public static BankQuoteRequest bankQuoteFromCustomer(Customer p_o) {
+ BankQuoteRequest bankRequest = new BankQuoteRequest();
CreditRating rating = p_o.getRating();
bankRequest.creditScore = rating.getScore();
String sVal = new DecimalFormat("########0").format(Double.parseDouble(p_o.getField(Customer.ATTRIB.loanAmt)));
bankRequest.loanAmount = Integer.parseInt(sVal);
bankRequest.loanTerm = Integer.parseInt(p_o.getField(Customer.ATTRIB.loanDur));
bankRequest.ssn = Integer.parseInt(p_o.getField(Customer.ATTRIB.ssn));
- bankRequest.customerUID = p_o.getUid();
+ bankRequest.customerUID = Long.toString(p_o.getUid());
return bankRequest;
}
//convert from the XMLStream object into a quote object
- public static BanksQuoteResponse bankQuoteFromXML(String xml) {
+ public static BankQuoteResponse bankQuoteFromXML(String xml) {
DomElement oEl=null;
- BanksQuoteResponse response = new BanksQuoteResponse();
+ BankQuoteResponse response = new BankQuoteResponse();
try {
oEl = DomElement.fromXml(xml);
Added: labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteResponse.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteResponse.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteResponse.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -0,0 +1,18 @@
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+public class BankQuoteResponse implements Serializable{
+
+ private static final long serialVersionUID = 1L;
+ public BigDecimal interestRate;
+ public String quoteId;
+ public int errorCode;
+ public long customerUID;
+
+ public BankQuoteResponse() {
+ super();
+ }
+
+}
\ No newline at end of file
Modified: labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponseNotification.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponseNotification.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponseNotification.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -24,7 +24,7 @@
import java.io.Serializable;
-public class CreditCheckResponseNotification implements Serializable{
+public class CreditCheckResponseNotification implements Serializable {
private static final long serialVersionUID = 1L;
public long customerUID;
Modified: labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -23,10 +23,10 @@
import java.io.File;
import java.sql.SQLException;
+import java.util.Map;
import org.jboss.soa.esb.actions.DummySqlRowAction;
import org.jboss.soa.esb.helpers.KeyValuePair;
-import org.jboss.soa.esb.listeners.SqlTablePoller.SQLPollResult;
import org.jboss.soa.esb.util.ClassUtils;
import org.jboss.soa.esb.util.DbUtils;
import org.jboss.soa.esb.util.FileUtils;
@@ -70,7 +70,7 @@
// Check did the messagebox recevive the message from the JMSListener...
MessageBox.assertMessageCount(1, 10000);
assertEquals(1, DummySqlRowAction.params.size());
- SQLPollResult pollResult = DummySqlRowAction.params.get(0);
+ Map pollResult = DummySqlRowAction.params.get(0);
// Check the rowset values...
assertEquals("ref1", pollResult.get("ref"));
Modified: labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java 2006-09-18 14:52:52 UTC (rev 6273)
+++ labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java 2006-09-18 15:22:45 UTC (rev 6274)
@@ -87,7 +87,7 @@
fileStream.flush();
fileStream.close();
} catch (IOException e) {
- TestCaseUtils.logAndFail("Error flushing/closing file: " + file.getAbsolutePath(), logger, null);
+ TestCaseUtils.logAndFail("Error flushing/closing file: " + file.getAbsolutePath(), logger, new Exception());
}
}
}
@@ -111,7 +111,7 @@
logger.error("Thread interupt...", e);
}
}
- TestCaseUtils.logAndFail("File [" + file.getAbsolutePath() + "] doesn't exist. Waited for " + maxWait + "ms.", logger, null);
+ TestCaseUtils.logAndFail("File [" + file.getAbsolutePath() + "] doesn't exist. Waited for " + maxWait + "ms.", logger, new Exception());
}
/**
@@ -138,7 +138,7 @@
}
}
TestCaseUtils.logAndFail("Files matching the pattern [" + pattern + "] not found in directory ["
- + dir.getAbsolutePath() + "]. Waited for " + maxWait + "ms.", logger, null);
+ + dir.getAbsolutePath() + "]. Waited for " + maxWait + "ms.", logger, new Exception());
}
/**
@@ -178,7 +178,7 @@
logger.error("Thread interupt...", e);
}
}
- TestCaseUtils.logAndFail("File [" + file.getAbsolutePath() + "] exists. Waited for " + maxWait + "ms.", logger, null);
+ TestCaseUtils.logAndFail("File [" + file.getAbsolutePath() + "] exists. Waited for " + maxWait + "ms.", logger, new Exception());
}
/**
@@ -213,6 +213,6 @@
logger.error("Thread interupt...", e);
}
}
- TestCaseUtils.logAndFail("File [" + file.getAbsolutePath() + "] can't be deleted - a handle on it (or one of its children) may be open. Waited " + maxWait + "ms", logger, null);
+ TestCaseUtils.logAndFail("File [" + file.getAbsolutePath() + "] can't be deleted - a handle on it (or one of its children) may be open. Waited " + maxWait + "ms", logger, new Exception());
}
}
More information about the jboss-svn-commits
mailing list