[jboss-svn-commits] JBL Code SVN: r6289 - in labs/jbossesb/trunk: product/core/common/src/org/jboss/soa/esb product/core/common/src/org/jboss/soa/esb/helpers product/core/common/src/org/jboss/soa/esb/helpers/persist product/core/common/src/org/jboss/soa/esb/notification product/core/common/tests/src/org/jboss/soa/esb/helpers product/core/listeners/src/org/jboss/soa/esb product/core/listeners/src/org/jboss/soa/esb/actions product/core/listeners/src/org/jboss/soa/esb/command product/core/listeners/src/org/jboss/soa/esb/listeners product/core/listeners/tests/src/org/jboss/soa/esb product/core/listeners/tests/src/org/jboss/soa/esb/actions product/core/listeners/tests/src/org/jboss/soa/esb/command product/core/listeners/tests/src/org/jboss/soa/esb/listeners product/core/listeners/tests/src/org/jboss/soa/esb/util product/docs/samples/TestJBossESB/paramsDir product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks product/docs/samples/trailblaze! r/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/org/jboss/soa/esb/util
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Sep 19 06:41:18 EDT 2006
Author: tfennelly
Date: 2006-09-19 06:39:35 -0400 (Tue, 19 Sep 2006)
New Revision: 6289
Added:
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/ConfigurationException.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinition.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinitionFactory.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessingException.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessor.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToFileWriter.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/SmooksTransformActionHandler.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueue.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueueException.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/InMemoryCommandQueue.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/JmsCommandQueue.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractListener.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-01.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-02.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-03.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-04.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-05.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-06.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-07.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-08.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-09.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-10.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-11.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinitionFactoryUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/BaseTestActionProcessor.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ByteArrayToStringUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/FileToByteArrayUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/LongToDateConverter.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToCSVStringUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToFileWriterUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformAction-Config-01.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionFuncTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/StringToLongConverter.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor1.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor2.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor3.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ToNowhereRouter.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/command/
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/command/InMemoryCommandQueueUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/GpListener-Config-01.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/ListenersManagerExecThread.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockNotificationTarget.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockPoller.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ObjectToXStream.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksResponse.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ToBankQuoteResponse.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteResponse.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/MessageBox.java
Removed:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractAction.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueue.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueueException.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/InMemoryCommandQueue.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/JmsCommandQueue.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-01.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-02.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-03.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-04.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-05.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-06.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-07.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-08.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-09.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-10.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-11.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinitionFactoryUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/BaseTestActionProcessor.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ByteArrayToStringUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/FileToByteArrayUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/LongToDateConverter.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToCSVStringUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToFileWriterUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformAction-Config-01.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionFuncTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/StringToLongConverter.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor1.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor2.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor3.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ToNowhereRouter.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/command/InMemoryCommandQueueUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/ListenersManagerExecThread.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockNotificationTarget.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockPoller.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksFileResponse.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksJMSResponse.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BanksQuoteRequest.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BanksQuoteResponse.java
Modified:
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractSqlRowAction.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyAction.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyFileAction.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractPoller.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/DirectoryPoller.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/DirectoryPollerUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/GpListenerUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/SqlTablePollerUnitTest.java
labs/jbossesb/trunk/product/docs/samples/TestJBossESB/paramsDir/FileMoverConfigExample.xml
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml.template
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponseNotification.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig1.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig2.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig3.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig4.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig5.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig6.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/DirectoryPollerConfig1.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/JmsQueueListenerConfig.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/JmsQueueListenerTest.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/ListenerManagerTest.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerConfig1.xml
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java
Log:
Merged "Action Piplining" code from the "workspace/tfennelly" branch.
Copied: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/ConfigurationException.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/common/src/org/jboss/soa/esb/ConfigurationException.java)
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -23,6 +23,7 @@
package org.jboss.soa.esb.helpers;
import java.io.Serializable;
+import java.util.List;
public class KeyValuePair implements Serializable {
private static final long serialVersionUID = 1L;
@@ -53,4 +54,110 @@
public String dump() {
return "KVpair[" + mKey + "=" + mVal + "]";
}
-} // ____________________________________________________________________________
+
+ /**
+ * 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.
+ * @return The value associated with the supplied key, or null if key not found.
+ */
+ public static String getValue(String key, List<KeyValuePair> list) {
+ if(key == null) {
+ throw new IllegalArgumentException("null 'key' arg in call.");
+ }
+ if(list == null) {
+ throw new IllegalArgumentException("null 'list' arg in call.");
+ }
+
+ for(KeyValuePair kvp : list) {
+ if(kvp.mKey.equals(key)) {
+ return kvp.mVal;
+ }
+ }
+
+ 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/trunk/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -47,15 +47,17 @@
}
public void commit() throws Exception {
- if (null != m_conn)
+ if (null != m_conn) {
m_conn.commit();
+ }
}
public void rollback() throws Exception {
- if (null != m_conn)
+ if (null != m_conn) {
m_conn.rollback();
+ }
}
-
+
public void release() {
if (null != m_conn) {
try {
@@ -79,23 +81,29 @@
public PreparedStatement prepareStatement(String p_sSt, int p_i1, int p_i2)
throws Exception {
- if (null == m_conn)
- connect();
+ if (null == m_conn) {
+ connect();
+ }
PreparedStatement PS = m_conn.prepareStatement(p_sSt, p_i1, p_i2);
m_olPrepSt.add(PS);
return PS;
} // __________________________________
public PreparedStatement prepareStatement(String p_sSt) throws Exception {
- if (null == m_conn)
+ if (null == m_conn) {
connect();
+ }
+
PreparedStatement PS = m_conn.prepareStatement(p_sSt);
m_olPrepSt.add(PS);
return PS;
} // __________________________________
- public ResultSet execQueryWait(PreparedStatement p_PS, int p_iQtry)
- throws Exception {
+ public ResultSet execQueryWait(PreparedStatement p_PS, int p_iQtry) throws Exception {
+ if (null == m_conn) {
+ connect();
+ }
+
Exception eRet = null;
int iQtry = (p_iQtry < 1) ? 1 : (p_iQtry < 50) ? p_iQtry : 50;
for (int i1 = 0; i1 < iQtry; i1++) {
@@ -113,8 +121,11 @@
throw eRet;
} // __________________________________
- public void execUpdWait(PreparedStatement p_PS, int p_iQtry)
- throws Exception {
+ public void execUpdWait(PreparedStatement p_PS, int p_iQtry) throws Exception {
+ if (null == m_conn) {
+ connect();
+ }
+
Exception eRet = null;
int iQtry = (p_iQtry < 1) ? 1 : (p_iQtry < 50) ? p_iQtry : 50;
for (int i1 = 0; i1 < iQtry; i1++) {
@@ -134,6 +145,10 @@
} // __________________________________
private void connect() throws Exception {
+ if(m_conn != null) {
+ return;
+ }
+
Exception eRet = null;
for (int i1 = 0; i1 < 5; i1++) {
try {
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -102,7 +102,12 @@
if (null == fileURI) {
throw new IllegalArgumentException("Bad File Notification Configuration: Missing file URI attribute.");
}
- m_oaOutF[i] = new NotificationFile(new URI(fileURI), Boolean.valueOf(append));
+
+ try {
+ m_oaOutF[i] = new NotificationFile(new URI(fileURI), Boolean.valueOf(append));
+ } catch(Exception e) {
+ m_oaOutF[i] = new NotificationFile(fileURI, Boolean.valueOf(append));
+ }
// Make sure the parent folder exists...
if(!m_oaOutF[i].getParentFile().exists()) {
@@ -111,7 +116,7 @@
}
} // __________________________________
- /**
+ /**
* Writes the result of p_o into each one of the File objects contained in
* the m_oaOutF array
*
@@ -178,5 +183,14 @@
super(fileURI);
this.append = append;
}
+
+ /**
+ * @param file
+ * @param append2
+ */
+ public NotificationFile(String file, boolean append) {
+ super(file);
+ this.append = append;
+ }
}
} // ____________________________________________________________________________
Modified: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -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));
+ }
}
Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractAction.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractAction.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,43 +0,0 @@
-package org.jboss.soa.esb.actions;
-
-import java.io.Serializable;
-import java.util.Observable;
-import org.apache.log4j.Logger;
-
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.listeners.GpListener;
-
-public abstract class AbstractAction extends Observable
- implements Runnable
-{
- public abstract void processCurrentObject() throws Exception;
- public abstract Serializable getOkNotification();
- public abstract Serializable getErrorNotification();
-
- protected DomElement m_oParms;
- protected Object m_oCurr;
- protected Logger m_oLogger = Logger.getLogger(this.getClass());
-
- protected AbstractAction(DomElement p_oP, Object p_oCurr)
- { m_oParms = p_oP;
- m_oCurr = 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));
- }
- } //________________________________
-
-} //____________________________________________________________________________
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,97 +1,70 @@
/*
-* 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.
-*/
+ * 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 org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.listeners.GpListener;
-
-public abstract class AbstractFileAction extends AbstractAction
-{
/**
- * Extend this class if you need to implement an action class intended to
- * process one file at a time
- * <br/>See FileCopier as an example
- * @param p_oP DomElement - Parameter tree passed by controlling listener
- * @param p_oCurr Object - This is the object that's going to get processed
- * <br/>All classes that extend AbstractFileAction receive an instance of the internal
- * <br/>class Params containing info needed to rename the file in different stages
- * <br/>of processing
+ * <p/>
+ * Extend this class if you need to implement an action class intended to process one file at a time.
+ * <p/>
+ * See {@link org.jboss.soa.esb.actions.FileCopier} as an example.
+ * <p/>
+ * This class are stateful.
+ * @author Esteban.
*/
- protected AbstractFileAction(DomElement p_oP, Object p_oCurr)
- { super(p_oP,p_oCurr);
- } //________________________________
+public abstract class AbstractFileAction implements ActionProcessor {
+
+ /**
+ * Files processed by action classes
+ * need to be renamed during processing to disable other listeners (or other
+ * threads launched by the same listener that started this thread) to pick
+ * up the same file <br/>Once processing ends a suffix will be added to the
+ * name of the original file that has been processed. The suffix will be
+ * different according to the result of processing (OK or Exception). Files
+ * could be moved to different directories as well <br/> Parameters for
+ * these options can be provided at run time in the DomElement (arg 0 in
+ * constructor)
+ * @param message The message payload to be processed.
+ * @return The processing result.
+ * @throws ActionProcessingException Exception during payload processing.
+ */
+ public final Object process(Object message) throws ActionProcessingException {
+ if(!(message instanceof File)) {
+ throw new ActionProcessingException("Message object for processing by " + getClass().getName()
+ + " should have been preprocessed to a " + File.class.getName() + " instance.");
+ }
+
+ // Call the implementing class to process the file message...
+ return process((File)message);
+ }
- public static class Params
- {
- public boolean bPostDelete;
- public File oInpF ,oWrkF ,oErrF ,oDoneF;
- public String toString() { return oInpF.toString(); }
- } //________________________________
+ /**
+ * Process the file message object.
+ * @param file The file to be processed.
+ * @return The processing result.
+ * @throws ActionProcessingException Exception while processing file.
+ */
+ protected abstract Object process(File file) throws ActionProcessingException;
- public boolean isPostDelete() { return ((Params)m_oCurr).bPostDelete; }
- public File getInputFile() { return ((Params)m_oCurr).oInpF; }
- public File getWorkFile() { return ((Params)m_oCurr).oWrkF; }
- public File getErrorFile() { return ((Params)m_oCurr).oErrF; }
- public File getDoneOkFile(){ return ((Params)m_oCurr).oDoneF; }
-
- public boolean renameToError() { return getWorkFile().renameTo(getErrorFile()); }
- public boolean renameToDone () { return getWorkFile().renameTo(getDoneOkFile()); }
-
-/**
- * Overrides run() in AbstractAction
- * <p/>Files processed by action classes need to be renamed during processing to
- * disable other listeners (or other threads launched by the same listener that
- * started this thread) to pick up the same file
- * <br/>Once processing ends a suffix will be added to the name of the original
- * file that has been processed. The suffix will be different according to the
- * result of processing (OK or Exception). Files could be moved to different
- * directories as well
- * <br/> Parameters for these options can be provided at run time in the
- * DomElement (arg 0 in constructor)
- */
- public void run()
- {
- try
- {
- processCurrentObject();
- if (isPostDelete())
- getWorkFile().delete();
- else
- renameToDone();
- GpListener.notifyOK(m_oParms,getOkNotification());
- }
- catch (Exception e)
- {
- renameToError();
- GpListener.notifyError(m_oParms,e,getErrorNotification());
- }
- finally
- { setChanged();
- notifyObservers(new Integer(-1));
- }
- } //________________________________
-
-} //____________________________________________________________________________
+} // ____________________________________________________________________________
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractSqlRowAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractSqlRowAction.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractSqlRowAction.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -2,138 +2,47 @@
import java.util.*;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.helpers.KeyValuePair;
-import javax.sql.DataSource;
+/**
+ * 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 #process(Map)}
+ * method.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public abstract class AbstractSqlRowAction implements ActionProcessor {
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.helpers.persist.JdbcCleanConn;
-import org.jboss.soa.esb.helpers.persist.SimpleDataSource;
-import org.jboss.soa.esb.listeners.GpListener;
-import org.jboss.soa.esb.listeners.SqlTablePoller.ROW_STATE;
+ protected Logger logger;
-public abstract class AbstractSqlRowAction extends AbstractAction
-{
- protected JdbcCleanConn m_oConn;
- protected PreparedStatement m_PSsel4U ,m_PSupd;
+ protected AbstractSqlRowAction(String actionName,
+ List<KeyValuePair> properties) throws Exception {
- protected AbstractSqlRowAction(DomElement p_oP, Object p_oCurr) throws Exception
- {
- super(p_oP,p_oCurr);
- DataSource oDS = new SimpleDataSource(m_oParms);
- m_oConn = new JdbcCleanConn(oDS);
- m_PSsel4U = m_oConn.prepareStatement(getSel4Upd());
- m_PSupd = m_oConn.prepareStatement(getUpdStmt());
+ logger = Logger.getLogger(getClass());
+ }
- int iParm=1;
- for (String sColName : getKeys())
- {
- Object oVal = getColumnValue(sColName);
- m_PSsel4U.setObject (iParm ,oVal);
- // parameters are +1 in update statement
- // autoincrement leaves things ready for next SQL parameter
- m_PSupd.setObject (++iParm,oVal);
- }
- } //________________________________
-
- public static class Params
- {
- public String sUpdStates;
- public String[] saCols ,saKeys;
- public String sSel4Upd,sUpdate;
- public Map<String,Object> omVals;
- public String toString() { return omVals.toString(); }
- } //________________________________
+ public final Object process(Object message) throws ActionProcessingException {
+ if (!(message instanceof Map)) {
+ throw new ActionProcessingException(
+ "Message object for processing by "
+ + getClass().getName()
+ + " should have been preprocessed and supplied as a "
+ + Map.class.getName() + " instance.");
+ }
- protected String getSel4Upd()
- { return ((Params)m_oCurr).sSel4Upd;
- } //________________________________
+ return process((Map)message);
+ } // ________________________________
- protected String getUpdStmt()
- { return ((Params)m_oCurr).sUpdate;
- } //________________________________
+ /**
+ * Process the SQL poll resultset.
+ *
+ * @param resultSet SQL Poller resultset.
+ * @return Processing result.
+ */
+ protected abstract Object process(Map resultSet) throws ActionProcessingException;
- protected String getStatus(ROW_STATE p_oState)
- { int iPos = p_oState.ordinal();
- return ((Params)m_oCurr).sUpdStates.substring(iPos,++iPos);
- } //________________________________
-
- protected Object getColumnValue(String p_sKey)
- { return ((Params)m_oCurr).omVals.get(p_sKey);
- } //________________________________
-
- protected String[] getKeys()
- { return ((Params)m_oCurr).saKeys;
- } //________________________________
-
- private boolean changeStatus (ROW_STATE pFrom, ROW_STATE pTo) throws Exception
- { ResultSet RS = m_oConn.execQueryWait(m_PSsel4U,5);
- if (! RS.next())
- return false;
- if (null!=pFrom)
- { String sOldStatus = RS.getString(1).substring(0,1);
- if (!sOldStatus.equalsIgnoreCase(getStatus(pFrom)))
- { m_oConn.rollback();
- return false;
- }
- }
- m_PSupd.setString(1,getStatus(pTo));
- m_oConn.execUpdWait(m_PSupd,5);
- m_oConn.commit();
-
- return true;
- } //______________________________
-
- public void run()
- {
- // will only continue if it can change status to "Working"
- try
- {
- if (! changeStatus(ROW_STATE.Pending,ROW_STATE.Working))
- { m_oLogger.warn("Unable to change status to Working");
- m_oConn.rollback();
- cleanup();
- return;
- }
- m_oConn.commit();
- }
- catch(Exception e)
- { m_oLogger.error("Unable to change status to Working",e);
- cleanup();
- return;
- }
-
- try
- {
- processCurrentObject();
- changeStatus(ROW_STATE.Working,ROW_STATE.Done);
- m_oConn.commit();
- GpListener.notifyOK(m_oParms,getOkNotification());
- }
- catch (Exception e)
- {
- try
- { changeStatus(ROW_STATE.Working,ROW_STATE.Error);
- m_oConn.commit();
- }
- catch (Exception eErr)
- {
- m_oLogger.error("Unable to change status to ERROR - Really weird - shouldn't happen");
- }
- GpListener.notifyError(m_oParms,e,getErrorNotification());
- }
- finally { cleanup(); }
- } //________________________________
-
- private void cleanup()
- { setChanged();
- notifyObservers(new Integer(-1));
- if (null!=m_oConn)
- { try { m_oConn.rollback(); }
- catch(Exception e) { /* OK just continue */ }
- m_oConn.release();
- }
- } //________________________________
-
-} //____________________________________________________________________________
+}
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinition.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinition.java)
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinitionFactory.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionDefinitionFactory.java)
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessingException.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessingException.java)
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessor.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ActionProcessor.java)
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java)
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyAction.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyAction.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -3,56 +3,43 @@
import java.io.Serializable;
import java.text.*;
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.listeners.GpListener;
+import org.apache.log4j.Logger;
+
+
/**
- * Use this class to tune your XML configurations
- * <p/>Once your config works with this dummy class, you can
- * switch to your own action class
- * <p/>You will have to implement these three methods
- * in your own action class
+ * Use this class to tune your XML configurations <p/>Once your config works
+ * with this dummy class, you can switch to your own action class <p/>You will
+ * have to implement these three methods in your own action class
*
* @author Esteban
- *
+ *
*/
-public class DummyAction extends AbstractAction
-{
-/**
- * Constructor must always have the configuration tree and the object
- * that the run() method will process
- * @param p_oP
- * @param p_oCurr
- */
- public DummyAction(DomElement p_oP, Object p_oCurr) throws Exception
- {
- super(p_oP,p_oCurr);
- }
-
- @Override
- public void processCurrentObject() throws Exception
- {
- m_oLogger.info("processObject was called with <<"
- +m_oCurr.toString()+">>");
- } //________________________________
-
- private SimpleDateFormat s_oTS = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS");
- private String getStamp()
- { return s_oTS.format(new java.util.Date(System.currentTimeMillis())); }
+public class DummyAction implements ActionProcessor {
+ /**
+ * Class Logger.
+ */
+ private static Logger logger = Logger.getLogger(DummyAction.class);
- @Override
- public Serializable getOkNotification()
- {
- return getStamp()+" Notif OK - <"
- +((null==m_oCurr)?"null":m_oCurr.toString())
- +">";
- } //________________________________
+ public Object process(Object message) {
+ logger.info("process was called with <<" + message.toString() + ">>");
+ return message;
+ } // ________________________________
- @Override
- public Serializable getErrorNotification()
- {
- return getStamp()+" Notif ERROR - <"
- +((null==m_oCurr)?"null":m_oCurr.toString())
- +">";
- } //________________________________
-
-} //____________________________________________________________________________
+ private SimpleDateFormat s_oTS = new SimpleDateFormat(
+ "yyyy/MM/dd hh:mm:ss.SSS");
+
+ private String getStamp() {
+ return s_oTS.format(new java.util.Date(System.currentTimeMillis()));
+ }
+
+ public Serializable getOkNotification(Object message) {
+ return getStamp() + " Notif OK - <"
+ + ((null == message) ? "null" : message.toString()) + ">";
+ } // ________________________________
+
+ public Serializable getErrorNotification(Object message) {
+ return getStamp() + " Notif ERROR - <"
+ + ((null == message) ? "null" : message.toString()) + ">";
+ } // ________________________________
+
+} // ____________________________________________________________________________
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyFileAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyFileAction.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyFileAction.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,9 +1,11 @@
package org.jboss.soa.esb.actions;
+import java.io.File;
import java.io.Serializable;
import java.text.*;
-import org.jboss.soa.esb.helpers.DomElement;
+import org.apache.log4j.Logger;
+
/**
* Use this class to tune your XML configurations
* <p/>Once your config works with this dummy class, you can
@@ -16,41 +18,30 @@
*/
public class DummyFileAction extends AbstractFileAction
{
-/**
- * Constructor must always have the configuration tree and the object
- * that the run() method will process
- * @param p_oP
- * @param p_oCurr
- */
- public DummyFileAction(DomElement p_oP, Object p_oCurr) throws Exception
- {
- super(p_oP,p_oCurr);
- }
+ private static Logger logger = Logger.getLogger(DummyFileAction.class);
@Override
- public void processCurrentObject() throws Exception
+ public Object process(File file) throws ActionProcessingException
{
- m_oLogger.info("processObject was called with <<"
- +m_oCurr.toString()+">>");
+ logger.info("processObject was called with <<" + file.getAbsolutePath() + ">>");
+ return file;
} //________________________________
private SimpleDateFormat s_oTS = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS");
private String getStamp()
{ return s_oTS.format(new java.util.Date(System.currentTimeMillis())); }
- @Override
- public Serializable getOkNotification()
+ public Serializable getOkNotification(Object message)
{
return getStamp()+" Notif OK - <"
- +((null==m_oCurr)?"null":m_oCurr.toString())
+ +((null==message)?"null":message.toString())
+">";
} //________________________________
- @Override
- public Serializable getErrorNotification()
+ public Serializable getErrorNotification(Object message)
{
return getStamp()+" Notif ERROR - <"
- +((null==m_oCurr)?"null":m_oCurr.toString())
+ +((null==message)?"null":message.toString())
+">";
} //________________________________
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -2,8 +2,12 @@
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.DomElement;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
/**
* Use this class to tune your XML configurations
* <p/>Once your config works with this dummy class, you can
@@ -16,42 +20,40 @@
*/
public class DummySqlRowAction extends AbstractSqlRowAction
{
-/**
- * Constructor must always have the configuration tree and the object
- * that the run() method will process
- * @param p_oP
- * @param p_oCurr
- */
- public DummySqlRowAction(DomElement p_oP, Object p_oCurr) throws Exception
- {
- super(p_oP,p_oCurr);
- }
+
+ public static List<Map> params = new Vector<Map>();
+
+ public DummySqlRowAction(String actionName, List<KeyValuePair> properties) throws Exception {
+ super(actionName, properties);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.actions.AbstractSqlRowAction#processSQL()
+ */
+ @Override
+ protected Object process(Map resultSet) {
+ logger.info("processResultset was called with <<"
+ + resultSet.toString()+">>");
+ params.add(resultSet);
+
+ return resultSet;
+ }
- @Override
- public void processCurrentObject() throws Exception
- {
- m_oLogger.info("processObject was called with <<"
- +m_oCurr.toString()+">>");
- } //________________________________
-
private SimpleDateFormat s_oTS = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS");
private String getStamp()
{ return s_oTS.format(new java.util.Date(System.currentTimeMillis())); }
- @Override
- public Serializable getOkNotification()
+ public Serializable getOkNotification(Object message)
{
return getStamp()+" Notif OK - <"
- +((null==m_oCurr)?"null":m_oCurr.toString())
+ +((null==message)?"null":message.toString())
+">";
} //________________________________
- @Override
- public Serializable getErrorNotification()
+ public Serializable getErrorNotification(Object message)
{
return getStamp()+" Notif ERROR - <"
- +((null==m_oCurr)?"null":m_oCurr.toString())
+ +((null==message)?"null":message.toString())
+">";
} //________________________________
-
} //____________________________________________________________________________
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,107 +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.
-*/
+ * 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.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.Serializable;
import java.net.URI;
+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;
-public class FileCopier extends AbstractFileAction
-{
- private static final String TMP_SUFFIX = ".notReady";
- private static final String PARMS_COPY_TO = "CopyTo";
- private static final String PARMS_OUTDIR = "copyToDirURI";
- private static final String PARMS_OUTSFX = "copyToSuffix";
+/**
+ * File copy action.
+ * <p/>
+ * 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:
+ * <pre>
+ * <Action name="Copy-To-XXX" processor="FileCopier">
+ * <property name="copyToDirURI" value="file:///..." />
+ * <property name="copyToSuffix" value=".fileCopierOutput" />
+ * </Action>
+ * </pre>
+ *
+ * @author Esteban
+ */
+public class FileCopier extends AbstractFileAction {
+
+ private static Logger logger = Logger.getLogger(FileCopier.class);
+
+ private static final String TMP_SUFFIX = ".notReady";
- private File [] m_oaTmpFile;
- private File [] m_oaOutFile;
+ private static final String PARMS_OUTDIR = "copyToDirURI";
- public FileCopier(DomElement p_oP, Object p_oCurr) throws Exception
- { super(p_oP,p_oCurr);
- checkMyParms();
- } //__________________________________
+ private static final String PARMS_OUTSFX = "copyToSuffix";
- public void processCurrentObject() throws Exception
- {
- // Open & create temp files
- FileInputStream oFI = new FileInputStream(getWorkFile());
- FileOutputStream []oaFO = new FileOutputStream[m_oaTmpFile.length];
- for (int i1=0; i1<oaFO.length;i1++)
- oaFO[i1] = new FileOutputStream(m_oaTmpFile[i1]);
+ private File outputDir;
+ private String copyToSuffix;
- // Perform Copy
- byte[] ba = new byte[50000];
- while (true)
- { int iQ = oFI.read(ba);
- if (iQ < 0) break;
- for (int i1=0; i1<oaFO.length; i1++)
- oaFO[i1].write(ba,0,iQ);
- }
- // Close
- oFI.close();
- for (int i1=0; i1<oaFO.length; i1++) oaFO[i1].close();
+ public FileCopier(String actionName, List<KeyValuePair> properties) throws URISyntaxException {
+ String outputDirParam = KeyValuePair.getValue(PARMS_OUTDIR, properties);
+
+ try {
+ outputDir = new File(new URI(outputDirParam));
+ } catch(Exception e) {
+ outputDir = new File(outputDirParam);
+ }
+ copyToSuffix = KeyValuePair.getValue(PARMS_OUTSFX, properties, ".copy");
+ } // __________________________________
- // Rename
- for (int i1=0; i1<m_oaTmpFile.length;i1++)
- { m_oaOutFile[i1].delete();
- m_oaTmpFile[i1].renameTo(m_oaOutFile[i1]);
- }
- } //__________________________________
+ public Object process(File file) throws ActionProcessingException {
+ WorkingFile workingFile;
+
+ try {
+ workingFile = (WorkingFile)file;
+ } catch(ClassCastException e) {
+ throw new ActionProcessingException("File must be an instance of " + WorkingFile.class.getName());
+ }
+
+ 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;
+
+ outputFileStream = new FileOutputStream(tempFile);
+
+ // Perform Copy
+ byte[] ba = new byte[1024];
+ while (true) {
+ int iQ = inputFileStream.read(ba);
+
+ if (iQ < 0) {
+ break;
+ }
+
+ 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);
+ }
+
+ return workingFile;
+ } // __________________________________
- protected void checkMyParms() throws Exception
- { DomElement[] oaPout = m_oParms.getElementChildren(PARMS_COPY_TO);
- m_oaTmpFile = new File[oaPout.length];
- m_oaOutFile = new File[oaPout.length];
-
- if (oaPout.length<1)
- { m_oLogger.warn("No output files specified for FileCopier");
- return;
+ public Serializable getOkNotification(Object message) {
+ return "File " + ((WorkingFile)message).getInputFile().getAbsolutePath()
+ + " successfully copied to all destination";
}
- String sFile = getInputFile().getName();
- for (int i1=0; i1<m_oaTmpFile.length;i1++)
- { File oDir = new File(new URI(oaPout[i1].getAttr(PARMS_OUTDIR)));
- m_oaTmpFile[i1] = File.createTempFile(sFile, TMP_SUFFIX, oDir);
- String sCpySuffix = oaPout[i1].getAttr(PARMS_OUTSFX);
- m_oaOutFile[i1] = new File(oDir,getInputFile().getName()+sCpySuffix);
+ public Serializable getErrorNotification(Object message) {
+ return "Problems copying " + ((WorkingFile)message).getInputFile().getAbsolutePath()
+ + " to configured destination";
}
- return;
- } //__________________________________
- @Override
- public Serializable getOkNotification()
- {
- return "File "+getInputFile()+" successfully copied to all destinations";
- } //__________________________________
-
- @Override
- public Serializable getErrorNotification()
- {
- return "Problems copying "+getInputFile()+" to configured destinations";
- } //__________________________________
-
-} //____________________________________________________________________________
+} // ____________________________________________________________________________
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java)
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java)
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java (from rev 6281, 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 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -0,0 +1,141 @@
+/*
+ * 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 supplied message object and a comma-separated "bean-properties"
+ * action property that specifies a list of bean property names.
+ * <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 constructor.
+ * @param actionName Action name.
+ * @param properties Action Properties.
+ * @throws ConfigurationException Action not properly configured.
+ */
+ 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;
+ }
+}
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToFileWriter.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToFileWriter.java)
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/SmooksTransformActionHandler.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/actions/SmooksTransformActionHandler.java)
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command)
Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueue.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueue.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueue.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,34 +0,0 @@
-package org.jboss.soa.esb.command;
-
-import org.jboss.soa.esb.helpers.DomElement;
-
-/**
- * Command queue abstraction.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public interface CommandQueue {
-
- /**
- * Open the command queue.
- * @param config Command queue configuration.
- * @throws CommandQueueException Queue exception. Check for probable chained cause exceptions.
- */
- public void open(DomElement config) throws CommandQueueException;
-
- /**
- * Receive a message from the underlying queue implementation.
- * <p/>
- * Performs a blocking receive on the command queue, controled by the receive timeout.
- * @param timeout The receive block timeout. Zero to block indefinitely.
- * @return The command message from the queue.
- * @throws CommandQueueException Queue exception. Check for probable chained cause exceptions.
- */
- public String receiveCommand(long timeout) throws CommandQueueException;
-
- /**
- * Close the command queue.
- * @throws CommandQueueException Queue exception. Check for probable chained cause exceptions.
- */
- public void close() throws CommandQueueException;
-}
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueue.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueue.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueueException.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueueException.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueueException.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,29 +0,0 @@
-package org.jboss.soa.esb.command;
-
-import org.jboss.soa.esb.BaseException;
-
-/**
- * Command queue exception.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class CommandQueueException extends BaseException {
-
- private static final long serialVersionUID = 1L;
-
- public CommandQueueException() {
- super();
- }
-
- public CommandQueueException(String message) {
- super(message);
- }
-
- public CommandQueueException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public CommandQueueException(Throwable cause) {
- super(cause);
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueueException.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/CommandQueueException.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/InMemoryCommandQueue.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/InMemoryCommandQueue.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/InMemoryCommandQueue.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,86 +0,0 @@
-package org.jboss.soa.esb.command;
-
-import java.util.Hashtable;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import org.jboss.soa.esb.helpers.DomElement;
-
-/**
- * In Memory Blocking Command Queue.
- * <p/>
- * Suitable for testing or any other purpose.
- * <p/>
- * The command queue's configuration needs to specify the
- * queue name via a "command-queue-name" attribute supplied in the configuration to the
- * {@link #open(DomElement)} method. The queues are stored statically and can be accessed via the
- * {@link #getQueue(String)} method using the queue name.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class InMemoryCommandQueue implements CommandQueue {
-
- /**
- * Command queue name attribute name.
- */
- public static final String COMMAND_QUEUE_NAME = "command-queue-name";
-
- private static Hashtable<String, InMemoryCommandQueue> commandQueues = new Hashtable<String, InMemoryCommandQueue>();
-
- private String name;
- private BlockingQueue<String> queue = new LinkedBlockingQueue<String>();
-
- public void open(DomElement config) throws CommandQueueException {
- if(config == null) {
- throw new IllegalArgumentException("null 'config' arg in method call.");
- }
-
- name = config.getAttr(COMMAND_QUEUE_NAME);
- if(name == null) {
- throw new CommandQueueException("Attribute 'command-queue-name' must be specified on the command queue configuration.");
- }
- commandQueues.put(name, this);
- }
-
- /**
- * Add a command to the in-memory command queue.
- * <p/>
- * Blocks until the command has been consumed.
- * @param command The command string.
- */
- public void addCommand(String command) {
- queue.add(command);
- while(!queue.isEmpty()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-
- public String receiveCommand(long timeout) throws CommandQueueException {
- if(name == null || !commandQueues.containsKey(name)) {
- throw new CommandQueueException("Sorry. Invalid call to 'receiveCommand' method. Queue is not open!");
- }
-
- try {
- return queue.take();
- } catch (InterruptedException e) {
- throw new CommandQueueException("Error taking command message from command queue.", e);
- }
- }
-
- public void close() throws CommandQueueException {
- commandQueues.remove(name);
- }
-
- /**
- * Get the command queue based on the name supplied in the configuration ("command-queue-name").
- * @param name The name of the queue ala the "command-queue-name" attribute on the queue configuration.
- * @return The MockCommandQueue instance, or null if no such queue exists.
- */
- public static InMemoryCommandQueue getQueue(String name) {
- return commandQueues.get(name);
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/InMemoryCommandQueue.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/InMemoryCommandQueue.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/JmsCommandQueue.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/JmsCommandQueue.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/JmsCommandQueue.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,149 +0,0 @@
-package org.jboss.soa.esb.command;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicConnectionFactory;
-import javax.jms.TopicSession;
-import javax.naming.Context;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.helpers.AppServerContext;
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.listeners.GpListener;
-import org.jboss.soa.esb.util.Util;
-
-/**
- * JMS based Command Queue implementation.
- * <p/>
- * This code was simply pulled from the GpListener.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class JmsCommandQueue implements CommandQueue {
-
- private static Logger logger = Logger.getLogger(JmsCommandQueue.class);
-
- public static final String COMMAND_CONN_FACTORY = "commandConnFactoryClass";
-
- public static final String COMMAND_JNDI_TYPE = "commandJndiType";
-
- public static final String COMMAND_JNDI_URL = "commandJndiURL";
-
- public static final String COMMAND_IS_TOPIC = "commandIsTopic";
-
- public static final String COMMAND_JNDI_NAME = "commandJndiName";
-
- public static final String COMMAND_MSG_SELECTOR = "messageSelector";
-
- private MessageConsumer m_oCmdSrc;
-
- private Session m_oJmsSess;
-
- private Connection m_oJmsConn;
-
- public void open(DomElement config) throws CommandQueueException {
- try {
- initialiseJMS(config);
- } catch (Exception e) {
- throw new CommandQueueException("Failed to initialise JMS Command Queue.", e);
- }
- }
-
- public void close() throws CommandQueueException {
- if (null != m_oJmsSess) {
- try {
- m_oJmsSess.close();
- } catch (JMSException eS) {/* Tried my best - Just continue */
- }
- }
- if (null != m_oJmsConn) {
- try {
- m_oJmsConn.close();
- } catch (JMSException eC) {/* Tried my best - Just continue */
- }
- }
- }
-
- public String receiveCommand(long timeout) throws CommandQueueException {
- try {
- Message jmsMessage = m_oCmdSrc.receive(timeout);
-
- if (null == jmsMessage)
- return null;
- if (jmsMessage instanceof TextMessage) {
- return ((TextMessage)jmsMessage).getText();
- } else {
- logger.warn("Message in command queue IGNORED - should be instanceof TextMessage");
- }
- } catch(Exception e) {
- throw new CommandQueueException("Exception receiving message from JMS Command Queue.", e);
- }
-
- return null;
- }
-
- private void initialiseJMS(DomElement p_oP) throws Exception {
- // Only check for JMS attributes if a queue JNDI name was specified
- String sJndiName = p_oP.getAttr(COMMAND_JNDI_NAME);
- if (!Util.isNullString(sJndiName)) {
- Map<String, Object> oNewAtts = new HashMap<String, Object>();
-
- oNewAtts.put(COMMAND_JNDI_NAME, sJndiName);
-
- String sJndiType = GpListener.obtainAtt(p_oP, COMMAND_JNDI_TYPE, "jboss");
- oNewAtts.put(COMMAND_JNDI_TYPE, sJndiType);
- String sJndiURL = GpListener.obtainAtt(p_oP, COMMAND_JNDI_URL, "localhost");
- oNewAtts.put(COMMAND_JNDI_URL, sJndiURL);
- Context oJndiCtx = AppServerContext.getServerContext(sJndiType,
- sJndiURL);
-
- String sFactClass = GpListener.obtainAtt(p_oP, COMMAND_CONN_FACTORY,
- "ConnectionFactory");
- oNewAtts.put(COMMAND_CONN_FACTORY, sFactClass);
- if (Util.isNullString(sFactClass))
- sFactClass = "ConnectionFactory";
- Object oFactCls = oJndiCtx.lookup(sFactClass);
-
- String sMsgSelector = p_oP.getAttr(COMMAND_MSG_SELECTOR);
- if (null != sMsgSelector)
- oNewAtts.put(COMMAND_MSG_SELECTOR, sMsgSelector);
-
- boolean bIsTopic = Boolean.parseBoolean(GpListener.obtainAtt(p_oP,
- COMMAND_IS_TOPIC, "false"));
- if (bIsTopic) {
- TopicConnectionFactory tcf = (TopicConnectionFactory) oFactCls;
- TopicConnection oTC = tcf.createTopicConnection();
- Topic oTopic = (Topic) oJndiCtx.lookup(sJndiName);
- TopicSession oSess = oTC.createTopicSession(false,
- TopicSession.AUTO_ACKNOWLEDGE);
- m_oJmsConn = oTC;
- m_oJmsSess = oSess;
- oTC.start();
- m_oCmdSrc = oSess.createSubscriber(oTopic, sMsgSelector, true);
- } else {
- QueueConnectionFactory qcf = (QueueConnectionFactory) oFactCls;
- QueueConnection oQC = qcf.createQueueConnection();
- javax.jms.Queue oQ = (javax.jms.Queue) oJndiCtx
- .lookup(sJndiName);
- QueueSession oSess = oQC.createQueueSession(false,
- TopicSession.AUTO_ACKNOWLEDGE);
- oQC.start();
- m_oJmsConn = oQC;
- m_oJmsSess = oSess;
- m_oCmdSrc = oSess.createReceiver(oQ, sMsgSelector);
- }
- }
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/command/JmsCommandQueue.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/command/JmsCommandQueue.java)
Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractListener.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractListener.java)
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractPoller.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractPoller.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/AbstractPoller.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,161 +1,111 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * 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.listeners;
import java.util.*;
-import java.lang.reflect.Constructor;
-import org.apache.log4j.*;
-
-import org.jboss.soa.esb.actions.AbstractAction;
+import org.jboss.soa.esb.actions.ActionDefinitionFactory;
import org.jboss.soa.esb.helpers.*;
-public abstract class AbstractPoller implements Runnable, Observer
-{
- protected abstract List<Object> pollForCandidates();
- protected abstract Object preProcess (Object p_o) throws Exception;
-
- // You can override these values at constructor time of your
- // derived class after calling super(GpListener,DomElement)
- protected int m_iMinPollMillis = 3000 // minimum polling interval
- ,m_iDfltPollMillis = 20000 // default polling interval
- ,m_iSleepForThreads = 3000 // default sleep if no threads available
- ,m_iUpperThreadLimit = 10 // just in case - override if you wish
- ;
-
- public static final String PARM_POLL_LTCY = "pollLatencySecs";
-
- protected int m_iQthr = 0, m_iMaxThr;
- protected int m_iPollMillis;
-
- protected ThreadGroup m_oThrGrp = null;
-
- protected Logger m_oLogger;
-
- protected GpListener m_oDad;
- protected DomElement m_oParms;
- protected Class m_oExecClass;
-
- protected AbstractPoller(GpListener p_oDad, DomElement p_oParms) throws Exception
- {
- m_oLogger = Logger.getLogger(this.getClass());
- m_oDad = p_oDad;
- m_oParms = p_oParms.cloneObj();
- checkParms();
- } //__________________________________
/**
- * Check for mandatory and optional attributes in parameter tree
+ * Abstract Polling Listener.
+ * <p/>
+ * Polling listeners are listener implementations that periodically poll for message objects
+ * that require processing. This type of listener implementation is required where the underlying
+ * message channel doesn't support a blocking receive operation.
*
- * @throws Exception - if actionClass not specified or not in classpath
- * or invalid int values for maxThreads or pollLatencySecs
- */
- protected void checkParms() throws Exception
- {
- String sAtt = GpListener.obtainAtt(m_oParms
- ,GpListener.PARM_ACTION_CLASS,null);
- m_oExecClass = GpListener.checkActionClass(sAtt);
-
- sAtt = GpListener.obtainAtt(m_oParms
- ,GpListener.PARM_MAX_THREADS,"1");
- int iMax = Integer.parseInt(sAtt);
- m_iMaxThr = Math.min(iMax,m_iUpperThreadLimit);
+ * @author Esteban
+ */
+public abstract class AbstractPoller extends AbstractListener {
- sAtt = m_oParms.getAttr(PARM_POLL_LTCY);
- m_iPollMillis = (null==sAtt) ? m_iDfltPollMillis
- : 1000 * Integer.parseInt(sAtt);
- if (m_iPollMillis < m_iMinPollMillis)
- m_iPollMillis = m_iMinPollMillis;
- } //________________________________
+ // You can override these values at constructor time of your
+ // derived class after calling super(GpListener,DomElement)
+ protected int m_iMinPollMillis = 3000 // minimum polling interval
+ , m_iDfltPollMillis = 20000 // default polling interval
+ ;
- /**
- * Implementation of Observer interface
- * <p/> Just count the number of active child threads
- *
- */
- public void update(Observable p_oObs, Object p_oUsrObj)
- {
- if (p_oUsrObj instanceof Integer)
- m_iQthr += ((Integer) p_oUsrObj).intValue();
- } //________________________________
+ public static final String PARM_POLL_LTCY = "pollLatencySecs";
- /**
- * Implement run method for this Runnable
- * <p/> Will continue to run until controlling class (ref in m_oDad) indicates
- * no more looping allowed for all child classes
- * <p/> This condition will not prevent child processes to finish normally
- */
- public void run()
- {
- m_oThrGrp = new ThreadGroup(m_oParms.getName());
- while (m_oDad.continueLooping())
- {
- List <Object> olPending = pollForCandidates();
- if (olPending.size() < 1)
- { try { Thread.sleep(m_iPollMillis); }
- catch (InterruptedException e) { return; }
- continue;
- }
+ protected int m_iPollMillis;
- for (Object oCurr : olPending)
- {
- if (m_iQthr >= m_iMaxThr)
- { m_oLogger.info("Waiting for available threads...(max="
- +m_iMaxThr+")");
- try { Thread.sleep(m_iSleepForThreads); }
- catch (InterruptedException e) {return; }
- break;
- }
+ /**
+ * Construct an abstract polling listener.
+ * @param commandListener The command listener.
+ * @param listenerConfig The configuration for this polling listener.
+ * @param actionDefinitionFactory The action definition factory for the bus.
+ * @throws Exception
+ */
+ protected AbstractPoller(GpListener commandListener, DomElement listenerConfig, ActionDefinitionFactory actionDefinitionFactory) throws Exception {
+ super(commandListener, listenerConfig, actionDefinitionFactory);
- // give the derived class an opportunity to do something
- // before processing current object
- Object oProcess = null;
- try
- { if (null==(oProcess = preProcess(oCurr)))
- continue;
- }
- catch (Exception ePre)
- { m_oLogger.error("preProcess(Object) FAILED",ePre);
- continue;
- }
+ String sAtt = listenerConfig.getAttr(PARM_POLL_LTCY);
+ m_iPollMillis = (null == sAtt) ? m_iDfltPollMillis : 1000 * Integer.parseInt(sAtt);
+ if (m_iPollMillis < m_iMinPollMillis) {
+ m_iPollMillis = m_iMinPollMillis;
+ }
+ }
- AbstractAction oExec = null;
- try
- { Constructor oConst = m_oExecClass
- .getConstructor(GpListener.getActionClassArgs());
- oExec = (AbstractAction)oConst
- .newInstance(new Object[] {m_oParms,oProcess});
- }
- catch (Exception e)
- { m_oLogger.error("Can't instantiate action class",e);
- break;
- }
- // launch an instance of the AbstractAction in a child thread
- m_iQthr += 1;
- oExec.addObserver(this);
- new Thread(oExec).start();
- }
- }
- } //__________________________________
-
-} //____________________________________________________________________________
+ /**
+ * Polling listener receive implementation.
+ * @return An array of objects polled from the concrete Poller implementation.
+ */
+ protected Object[] receive() {
+ while (m_oDad.continueLooping()) {
+ List<Object> olPending = pollForCandidates();
+
+ if (olPending == null || olPending.isEmpty()) {
+ try {
+ Thread.sleep(m_iPollMillis);
+ } catch (InterruptedException e) {
+ logger.error("Unexpected thread interupt exception. Not terminating blocking receive!!", e);
+ }
+ continue;
+ } else {
+ Object[] objForProcessing = new Object[olPending.size()];
+
+ // Preprocess all the message objects.
+ // TODO: I really think this is no longer required or a good idea!!
+ for(int i = 0; i < olPending.size(); i++) {
+ objForProcessing[i] = preProcess(olPending.get(i));
+ }
+ return objForProcessing;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Poll for message objects.
+ * @return A list of message objects, or an empty list if there are no message objects.
+ */
+ protected abstract List<Object> pollForCandidates();
+
+ /**
+ * Preprocess the message object before returning for pipeline processing.
+ * @param message Message object for preprocessing.
+ * @return The preprocessed message object, or the supplied message unmodified.
+ */
+ protected abstract Object preProcess(Object message);
+ // TODO: Is this "preprocessing" step needed now that we have processing pipelines on listeners???
+}
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/DirectoryPoller.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/DirectoryPoller.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/DirectoryPoller.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -28,7 +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.helpers.*;
public class DirectoryPoller extends AbstractPoller
@@ -42,9 +43,9 @@
public static final String FILE_POST_SFX = "postSuffix";
public static final String FILE_POST_DEL = "postDelete";
- public DirectoryPoller(GpListener p_oDad, DomElement p_oParms) throws Exception
+ public DirectoryPoller(GpListener p_oDad, DomElement p_oParms, ActionDefinitionFactory actionDefinitionFactory) throws Exception
{
- super(p_oDad,p_oParms);
+ super(p_oDad, p_oParms, actionDefinitionFactory);
checkMyParms();
} //__________________________________
@@ -56,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) throws Exception
+ 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
@@ -90,32 +92,32 @@
return Arrays.asList((Object[])oaF);
} //________________________________
- protected void checkMyParms() throws Exception
+ private void checkMyParms() throws Exception
{
// INPUT directory and suffix (used for FileFilter)
- String sInpDir = GpListener.obtainAtt(m_oParms,FILE_INPUT_DIR,null);
- m_oInpDir = new File(new URI(sInpDir));
+ String sInpDir = GpListener.obtainAtt(listenerConfig,FILE_INPUT_DIR,null);
+ m_oInpDir = getFile(sInpDir);
seeIfOkToWorkOnDir(m_oInpDir);
- m_sInpSfx = GpListener.obtainAtt(m_oParms,FILE_INPUT_SFX,null);
+ m_sInpSfx = GpListener.obtainAtt(listenerConfig,FILE_INPUT_SFX,null);
m_sInpSfx = m_sInpSfx.trim();
if (m_sInpSfx.length()<1)
throw new Exception ("Invalid "+FILE_INPUT_SFX+" attribute");
m_oFFilt = new FileEndsWith(m_sInpSfx);
// WORK suffix (will rename in input directory)
- m_sWrkSfx = GpListener.obtainAtt(m_oParms,FILE_WORK_SFX,".esbWork").trim();
+ m_sWrkSfx = GpListener.obtainAtt(listenerConfig,FILE_WORK_SFX,".esbWork").trim();
if (m_sWrkSfx.length()<1)
throw new Exception ("Invalid "+FILE_WORK_SFX+" attribute");
if (m_sInpSfx.equals(m_sWrkSfx))
throw new Exception("Work suffix must differ from input suffix <"+m_sWrkSfx+">");
// ERROR directory and suffix (defaults to input dir and ".esbError" suffix)
- String sErrDir = GpListener.obtainAtt(m_oParms,FILE_ERROR_DIR,sInpDir);
- m_oErrorDir = new File(new URI(sErrDir));
+ String sErrDir = GpListener.obtainAtt(listenerConfig,FILE_ERROR_DIR,sInpDir);
+ m_oErrorDir = getFile(sErrDir);
seeIfOkToWorkOnDir(m_oErrorDir);
- m_sErrSfx = GpListener.obtainAtt(m_oParms,FILE_ERROR_SFX,".esbError").trim();
+ m_sErrSfx = GpListener.obtainAtt(listenerConfig,FILE_ERROR_SFX,".esbError").trim();
if (m_sErrSfx.length()<1)
throw new Exception ("Invalid "+FILE_ERROR_SFX+" attribute");
if (m_oErrorDir.equals(m_oInpDir) && m_sInpSfx.equals(m_sErrSfx))
@@ -123,16 +125,16 @@
// Do users wish to delete files that were processed OK ?
- String sPostDel = GpListener.obtainAtt(m_oParms,FILE_POST_DEL,"false").trim();
+ String sPostDel = GpListener.obtainAtt(listenerConfig,FILE_POST_DEL,"false").trim();
m_bPostDel = Boolean.parseBoolean(sPostDel);
if (m_bPostDel)
return;
// POST (done) directory and suffix (defaults to input dir and ".esbDone" suffix)
- String sPostDir = GpListener.obtainAtt(m_oParms,FILE_POST_DIR,sInpDir);
- m_oPostDir = new File(new URI(sPostDir));
+ String sPostDir = GpListener.obtainAtt(listenerConfig,FILE_POST_DIR,sInpDir);
+ m_oPostDir = getFile(sPostDir);
seeIfOkToWorkOnDir(m_oPostDir);
- m_sPostSfx = GpListener.obtainAtt(m_oParms,FILE_POST_SFX,".esbDone").trim();
+ m_sPostSfx = GpListener.obtainAtt(listenerConfig,FILE_POST_SFX,".esbDone").trim();
if (m_oPostDir.equals(m_oInpDir))
{ if (m_sPostSfx.length()<1)
throw new Exception ("Invalid "+FILE_POST_SFX+" attribute");
@@ -142,7 +144,15 @@
} //________________________________
- protected void seeIfOkToWorkOnDir (File p_oDir) throws Exception
+ private File getFile(String file) {
+ try {
+ return new File(new URI(file));
+ } catch(Exception e) {
+ return new File(file);
+ }
+ }
+
+ protected void seeIfOkToWorkOnDir (File p_oDir) throws Exception
{
if (! p_oDir.exists())
throw new Exception ("Directory "+p_oDir.toString()+" not found");
@@ -172,4 +182,77 @@
} //______________________________
} //____________________________________________________
-} //____________________________________________________________________________
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.AbstractListener#close()
+ */
+ @Override
+ protected void close() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.AbstractListener#processingError(java.lang.Object, org.jboss.soa.esb.actions.ActionProcessor, java.lang.Throwable)
+ */
+ @Override
+ protected void processingError(Object initialMessage, ActionProcessor processor, Throwable error) {
+ WorkingFile workingFile = (WorkingFile) initialMessage;
+
+ workingFile.renameToError();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.AbstractListener#processingComplete(java.lang.Object)
+ */
+ @Override
+ protected void processingComplete(Object initialMessage) {
+ WorkingFile workingFile = (WorkingFile) initialMessage;
+
+ // Delete or rename the file...
+ if (workingFile.postDelete) {
+ workingFile.delete();
+ } else {
+ 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/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -22,22 +22,29 @@
package org.jboss.soa.esb.listeners;
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
import java.text.SimpleDateFormat;
-import java.util.*;
-import java.lang.reflect.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
-import javax.jms.*;
-import javax.naming.*;
-
-import org.apache.log4j.*;
-
-import org.jboss.soa.esb.actions.AbstractAction;
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionDefinitionFactory;
+import org.jboss.soa.esb.command.CommandQueue;
+import org.jboss.soa.esb.command.CommandQueueException;
+import org.jboss.soa.esb.command.JmsCommandQueue;
import org.jboss.soa.esb.common.SystemProperties;
-import org.jboss.soa.esb.helpers.*;
+import org.jboss.soa.esb.helpers.DomElement;
import org.jboss.soa.esb.notification.NotificationList;
-import org.jboss.soa.esb.parameters.*;
-import org.jboss.soa.esb.services.*;
+import org.jboss.soa.esb.parameters.ParamRepositoryException;
+import org.jboss.soa.esb.parameters.ParamRepositoryFactory;
+import org.jboss.soa.esb.services.InotificationHandler;
+import org.jboss.soa.esb.services.NotificationHandlerFactory;
import org.jboss.soa.esb.util.Util;
import org.xml.sax.SAXException;
@@ -83,18 +90,6 @@
// parameter reloads
;
- public static final String COMMAND_CONN_FACTORY = "commandConnFactoryClass";
-
- public static final String COMMAND_JNDI_TYPE = "commandJndiType";
-
- public static final String COMMAND_JNDI_URL = "commandJndiURL";
-
- public static final String COMMAND_IS_TOPIC = "commandIsTopic";
-
- public static final String COMMAND_JNDI_NAME = "commandJndiName";
-
- public static final String COMMAND_MSG_SELECTOR = "messageSelector";
-
public static final String PARM_RELOAD_SECS = "parameterReloadSecs";
public static final String PARM_END_TIME = "endTime";
@@ -105,7 +100,7 @@
// DomElements
public static final String PARM_LISTENER_CLASS = "listenerClass";
- public static final String PARM_ACTION_CLASS = "actionClass";
+ public static final String PARM_ACTIONS = "actions";
public static final String PARM_MAX_THREADS = "maxThreads";
@@ -164,12 +159,10 @@
}
};
- private MessageConsumer m_oCmdSrc;
+ private CommandQueue commandQueue;
- private Session m_oJmsSess;
+ private ActionDefinitionFactory actionDefinitionFactory;
- private Connection m_oJmsConn;
-
/**
* Construct a Listener Manager from the named repository based
* configuration.
@@ -204,9 +197,7 @@
m_oState = State.Exception_thrown;
m_oState.m_oException = e;
- m_oLogger
- .fatal(
- "Listener configuration and startup error. Config Source: "
+ m_oLogger.fatal("Listener configuration and startup error. Config Source: "
+ (configSource != null ? configSource
: "unknown"), e);
@@ -253,66 +244,18 @@
public void checkParms(DomElement p_oP) throws Exception {
// We've just loaded - set to false until next reload requested
m_bReloadRequested = false;
- m_oCmdSrc = null;
+ commandQueue = createCommandQueue(p_oP);
- Map<String, Object> oNewAtts = new HashMap<String, Object>();
+ // Open the command queue...
+ commandQueue.open(p_oP);
- // Only check for JMS attributes if a queue JNDI name was specified
- String sJndiName = p_oP.getAttr(COMMAND_JNDI_NAME);
- if (!Util.isNullString(sJndiName)) {
- oNewAtts.put(COMMAND_JNDI_NAME, sJndiName);
-
- String sJndiType = obtainAtt(p_oP, COMMAND_JNDI_TYPE, "jboss");
- oNewAtts.put(COMMAND_JNDI_TYPE, sJndiType);
- String sJndiURL = obtainAtt(p_oP, COMMAND_JNDI_URL, "localhost");
- oNewAtts.put(COMMAND_JNDI_URL, sJndiURL);
- Context oJndiCtx = AppServerContext.getServerContext(sJndiType,
- sJndiURL);
-
- String sFactClass = obtainAtt(p_oP, COMMAND_CONN_FACTORY,
- "ConnectionFactory");
- oNewAtts.put(COMMAND_CONN_FACTORY, sFactClass);
- if (Util.isNullString(sFactClass))
- sFactClass = "ConnectionFactory";
- Object oFactCls = oJndiCtx.lookup(sFactClass);
-
- String sMsgSelector = p_oP.getAttr(COMMAND_MSG_SELECTOR);
- if (null != sMsgSelector)
- oNewAtts.put(COMMAND_MSG_SELECTOR, sMsgSelector);
-
- boolean bIsTopic = Boolean.parseBoolean(obtainAtt(p_oP,
- COMMAND_IS_TOPIC, "false"));
- if (bIsTopic) {
- TopicConnectionFactory tcf = (TopicConnectionFactory) oFactCls;
- TopicConnection oTC = tcf.createTopicConnection();
- Topic oTopic = (Topic) oJndiCtx.lookup(sJndiName);
- TopicSession oSess = oTC.createTopicSession(false,
- TopicSession.AUTO_ACKNOWLEDGE);
- m_oJmsConn = oTC;
- m_oJmsSess = oSess;
- oTC.start();
- m_oCmdSrc = oSess.createSubscriber(oTopic, sMsgSelector, true);
- } else {
- QueueConnectionFactory qcf = (QueueConnectionFactory) oFactCls;
- QueueConnection oQC = qcf.createQueueConnection();
- javax.jms.Queue oQ = (javax.jms.Queue) oJndiCtx
- .lookup(sJndiName);
- QueueSession oSess = oQC.createQueueSession(false,
- TopicSession.AUTO_ACKNOWLEDGE);
- oQC.start();
- m_oJmsConn = oQC;
- m_oJmsSess = oSess;
- m_oCmdSrc = oSess.createReceiver(oQ, sMsgSelector);
- }
- }
-
// if PARM_RELOAD_SECS not set, and no command queue
// then reload every 10 minutes
// If there is a command queue, run until command is received
String sRldSecs = p_oP.getAttr(PARM_RELOAD_SECS);
m_lNextReload = (null != sRldSecs) ? System.currentTimeMillis() + 1000
* Long.parseLong(sRldSecs)
- : (null == m_oCmdSrc) ? Long.MAX_VALUE : System
+ : (null == commandQueue) ? Long.MAX_VALUE : System
.currentTimeMillis()
+ m_iDfltReloadMillis;
@@ -323,8 +266,35 @@
m_lEndTime = (null == sEndT) ? Long.MAX_VALUE : s_oDateParse.parse(
sEndT).getTime();
+ // Read and initialise the action definitions...
+ DomElement actionConfig = p_oP.getFirstElementChild("Actions");
+ if(actionConfig == null) {
+ throw new ConfigurationException("No 'Actions' configuration.");
+ }
+ actionDefinitionFactory = new ActionDefinitionFactory(actionConfig);
+
} // ________________________________
+ /**
+ * Factory method for creating the command queue.
+ * @param config GpListener config.
+ * @return GpListener CommandQueue instance.
+ */
+ private CommandQueue createCommandQueue(DomElement config) {
+ String commandQueueClass = config.getAttr("command-queue-class");
+
+ if(commandQueueClass != null) {
+ try {
+ return (CommandQueue) Class.forName(commandQueueClass).newInstance();
+ } catch (Exception e) {
+ m_oLogger.error("Failed to instantiate CommandQueue ["+ commandQueueClass + "]. Defaulting to the JMS Command Queue", e);
+ }
+ }
+
+ // Default command queue...
+ return new JmsCommandQueue();
+ }
+
/**
* Main execution loop <p/> Will continue to run until either <p/>a) run
* time is expired <p/>b) quiesce command is received in command queue
@@ -373,25 +343,21 @@
m_oLogger
.info("Finishing_____________________________________________________");
- if (null != m_oJmsSess)
- try {
- m_oJmsSess.close();
- } catch (JMSException eS) {/* Tried my best - Just continue */
- }
- if (null != m_oJmsConn)
- try {
- m_oJmsConn.close();
- } catch (JMSException eC) {/* Tried my best - Just continue */
- }
+ // Close the command queue...
+ try {
+ commandQueue.close();
+ } catch (CommandQueueException e) {
+ m_oLogger.error("Error closing Command Queue.", e);
+ }
} // ________________________________
private void tryToLaunchChildListener(DomElement p_oP, String p_sClassName) {
try {
Class oListener = Class.forName(p_sClassName);
Constructor oConst = oListener.getConstructor(new Class[] {
- this.getClass(), DomElement.class });
+ this.getClass(), DomElement.class, ActionDefinitionFactory.class });
Runnable oRun = (Runnable) oConst.newInstance(new Object[] { this,
- p_oP });
+ p_oP, actionDefinitionFactory });
new Thread(oRun).start();
} catch (Exception e) {
m_oLogger.error("Cannot launch <" + p_sClassName + ">\n", e);
@@ -405,7 +371,7 @@
private void waitForCmdOrSleep() {
long lToGo = millisToWait();
- if (null == m_oCmdSrc) {
+ if (null == commandQueue) {
m_oLogger.debug("About to sleep " + lToGo);
// No command queue nor topic - Just sleep until time
// exhausted, or thread interrupted
@@ -423,22 +389,17 @@
// that's why time to go is recalculated on each cycle
while ((lToGo = millisToWait()) > 0) {
try {
- m_oLogger.info("Waiting for command ... timeout=" + lToGo
- + " millis");
- // for the time being, only text messages allowed
- // THIS WILL CHANGE !!
- Message oM = m_oCmdSrc.receive(lToGo);
- if (null == oM)
+ m_oLogger.info("Waiting for command ... timeout=" + lToGo + " millis");
+
+ String oM = commandQueue.receiveCommand(lToGo);
+ if (null == oM) {
return;
- if (!(oM instanceof TextMessage)) {
- m_oLogger
- .warn("Message in command queue IGNORED - should be instanceof TextMessage");
- return;
}
- processCommand((TextMessage) oM);
- if (endRequested() || timeToReload())
+ processCommand(oM);
+ if (endRequested() || timeToReload()) {
break;
- } catch (JMSException eJ) {
+ }
+ } catch (CommandQueueException eJ) {
m_oLogger.info("receive on command queue failed", eJ);
}
}
@@ -473,40 +434,37 @@
* </TABLE> * startsWith() <p/>
*
* @param p_oMsg
- * TextMessage - Received in command queue/topic
+ * Message received from the command queue.
*
*/
- private void processCommand(TextMessage p_oMsg) {
- try {
- String sTxt = p_oMsg.getText();
- if (null == sTxt)
- return;
- String sLow = sTxt.trim().toLowerCase();
- if (sLow.startsWith("shutdown")) {
- m_bEndRequested = true;
- m_oLogger.info("Shutdown has been requested");
- return;
+ private void processCommand(String sTxt) {
+ if (null == sTxt)
+ return;
+
+ String sLow = sTxt.trim().toLowerCase();
+ if (sLow.startsWith("shutdown")) {
+ m_bEndRequested = true;
+ m_oLogger.info("Shutdown has been requested");
+ return;
+ }
+ if (sLow.startsWith("reload param")) {
+ m_bReloadRequested = true;
+ m_oLogger
+ .info("Request for parameter reload has been received");
+ return;
+ }
+ String[] sa = sLow.split("\\s+");
+ if (sa.length > 1 && "endtime".equals(sa[0])) {
+ try {
+ String sDate = sa[1];
+ String sTime = (sa.length < 3 || null == sa[2]) ? "23:59:59"
+ : sa[2];
+ Date oEnd = s_oDateParse.parse(sDate + " " + sTime);
+ m_oLogger.info("New end date set to : " + oEnd);
+ m_lEndTime = oEnd.getTime();
+ } catch (Exception eDat) {
+ m_oLogger.info("Problems with endTime command", eDat);
}
- if (sLow.startsWith("reload param")) {
- m_bReloadRequested = true;
- m_oLogger
- .info("Request for parameter reload has been received");
- return;
- }
- String[] sa = sLow.split("\\s+");
- if (sa.length > 1 && "endtime".equals(sa[0]))
- try {
- String sDate = sa[1];
- String sTime = (sa.length < 3 || null == sa[2]) ? "23:59:59"
- : sa[2];
- Date oEnd = s_oDateParse.parse(sDate + " " + sTime);
- m_oLogger.info("New end date set to : " + oEnd);
- m_lEndTime = oEnd.getTime();
- } catch (Exception eDat) {
- m_oLogger.info("Problems with endTime command", eDat);
- }
- } catch (JMSException eJ) {
- m_oLogger.info("Problems with command queue", eJ);
}
} // ________________________________
@@ -585,56 +543,16 @@
* If requested attribute not found and no default value
* supplied by invoker
*/
- static String obtainAtt(DomElement p_oP, String p_sAtt, String p_sDefault)
- throws Exception {
+ public static String obtainAtt(DomElement p_oP, String p_sAtt, String p_sDefault)
+ throws ConfigurationException {
String sVal = p_oP.getAttr(p_sAtt);
if ((null == sVal) && (null == p_sDefault))
- throw new Exception("Missing or invalid <" + p_sAtt + "> attribute");
+ throw new ConfigurationException("Missing or invalid <" + p_sAtt + "> attribute");
return (null != sVal) ? sVal : p_sDefault;
} // ________________________________
- private static Class[] s_oaActionConstr = { DomElement.class, Object.class };
-
- public static Class[] getActionClassArgs() {
- return s_oaActionConstr;
- }
-
/**
- * Check to see if an object of the class (arg 0) can be instantiated in
- * this context
- *
- * @param p_sName
- * String - class name to instantiate - Must implement
- * org.jboss.soa.esb.listeners.AbstractActionClass
- * @return Class -
- * @throws Exception -
- * if class not found in path or no appropriate constructor
- */
- protected static Class checkActionClass(String p_sName) throws Exception {
- Class oCls;
- try {
- oCls = Class.forName(p_sName);
- } catch (ClassNotFoundException e) {
- throw new Exception("Class " + p_sName + " not found in classpath");
- }
-
- try {
- oCls.getConstructor(s_oaActionConstr);
- } catch (NoSuchMethodException eN) {
- throw new Exception("No appropriate constructor " + p_sName
- + "(DomElement,Object) found for class ");
- }
- try {
- oCls.asSubclass(AbstractAction.class);
- } catch (ClassCastException eCC) {
- throw new Exception("class " + p_sName + " does not extend "
- + AbstractAction.class.getName());
- }
- return oCls;
- } // _________________________________________
-
- /**
* Find child nodes named "NotificationList" that contain an attribute
* 'type' that starts with "ok" (case insensitive)
*
@@ -644,6 +562,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
@@ -670,8 +592,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/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,196 +1,186 @@
/*
-* 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.
-*/
+ * 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.listeners;
-import java.lang.reflect.*;
-import java.util.Observer;
-import java.util.Observable;
-
-import org.apache.log4j.*;
-
import javax.naming.*;
import javax.jms.*;
-import org.jboss.soa.esb.actions.AbstractAction;
+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.*;
-public class JmsQueueListener implements Runnable, Observer
-{
- // You can override these values at constructor time of your derived class
- protected int
- m_iSleepForThreads = 3000 // default sleep if no threads available
- ,m_iUpperThreadLimit = 10 // just in case - override if you wish
- ;
- public static final String LISTEN_QUEUE_CONN_FACT = "queueConnFactoryClass";
- public static final String LISTEN_JNDI_TYPE = "listenJndiType";
- public static final String LISTEN_JNDI_URL = "listenJndiURL";
- public static final String LISTEN_QUEUE = "listenQueue";
- public static final String LISTEN_MSG_SELECTOR = "listenMsgSelector";
+public class JmsQueueListener extends AbstractListener {
- protected boolean m_bError = false;
+ public static final String LISTEN_QUEUE_CONN_FACT = "queueConnFactoryClass";
- protected QueueConnection m_oQconn;
- protected QueueSession m_oQsess;
- protected Queue m_oQueue;
- protected String m_sSelector;
- protected MessageConsumer m_oRdr;
+ public static final String LISTEN_JNDI_TYPE = "listenJndiType";
+ public static final String LISTEN_JNDI_URL = "listenJndiURL";
- protected int m_iQthr = 0, m_iMaxThr;
+ public static final String LISTEN_QUEUE = "listenQueue";
- protected ThreadGroup m_oThrGrp = null;
-
- protected Logger m_oLogger;
+ public static final String LISTEN_MSG_SELECTOR = "listenMsgSelector";
- protected GpListener m_oDad;
- protected DomElement m_oParms;
- protected Class m_oExecClass;
+ protected boolean m_bError = false;
- public JmsQueueListener(GpListener p_oDad, DomElement p_oParms) throws Exception
- {
- m_oLogger = Logger.getLogger(this.getClass());
- m_oDad = p_oDad;
- m_oParms = p_oParms.cloneObj();
- checkMyParms();
- m_oThrGrp = new ThreadGroup(m_oParms.getName());
- } //__________________________________
-
- /**
- * Check for mandatory and optional attributes in parameter tree
- *
- * @throws Exception - if mandatory atts are not right
- * or actionClass not in classpath
- */
- protected void checkMyParms() throws Exception
- {
- String sAtt = GpListener.obtainAtt(m_oParms
- ,GpListener.PARM_ACTION_CLASS,null);
- m_oExecClass= GpListener.checkActionClass(sAtt);
-
- sAtt = GpListener.obtainAtt(m_oParms
- ,GpListener.PARM_MAX_THREADS,"1");
- int iMax = Integer.parseInt(sAtt);
- m_iMaxThr = Math.min(iMax,m_iUpperThreadLimit);
+ protected QueueConnection m_oQconn;
- // Third arg is null - Exception will br thrown if listenQueue is not found
- String sQueue = GpListener.obtainAtt(m_oParms,LISTEN_QUEUE,null);
-
- // No problem if selector is null - everything in queue will be returned
- m_sSelector = m_oParms.getAttr(LISTEN_MSG_SELECTOR);
+ protected QueueSession m_oQsess;
- m_oQconn = null;
- m_oQsess = null;
- m_oQueue = null;
-
- String sJndiType = GpListener.obtainAtt(m_oParms
- ,LISTEN_JNDI_TYPE,"jboss");
- String sJndiURL = GpListener.obtainAtt(m_oParms
- ,LISTEN_JNDI_URL,"localhost");
- Context oJndiCtx = AppServerContext.getServerContext(sJndiType,sJndiURL);
+ protected Queue m_oQueue;
- String sFactClass = GpListener.obtainAtt(m_oParms
- ,LISTEN_QUEUE_CONN_FACT,"ConnectionFactory");
- Object tmp = oJndiCtx.lookup(sFactClass);
- QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+ protected String m_sSelector;
- m_oQconn = qcf.createQueueConnection();
- m_oQueue = (Queue) oJndiCtx.lookup(sQueue);
- m_oQsess = m_oQconn.createQueueSession
- (false,TopicSession.AUTO_ACKNOWLEDGE);
- m_oQconn.start();
- m_oRdr = m_oQsess.createReceiver(m_oQueue, m_sSelector);
-
- } //________________________________
+ protected MessageConsumer jmsMessageReceiver;
+
+ public JmsQueueListener(GpListener commandListener, DomElement listenerConfig, ActionDefinitionFactory actionDefinitionFactory) throws Exception {
+ super(commandListener, listenerConfig, actionDefinitionFactory);
+ checkMyParms();
+ } // __________________________________
+
/**
- * Implement run method for this Runnable
- * <p/> Will continue to run until controlling class (ref in m_oDad) indicates
- * no more looping allowed for all child classes
- * <p/> This condition will not prevent child processes to finish normally
+ * Check for mandatory and optional attributes in parameter tree
+ *
+ * @throws Exception -
+ * if mandatory atts are not right or actionClass not in
+ * classpath
*/
- public void run()
- {
- while (m_oDad.continueLooping())
- {
- if (m_iQthr >= m_iMaxThr)
- { m_oLogger.info("Waiting for available threads...");
- try { Thread.sleep(m_iSleepForThreads); }
- catch (InterruptedException e) {return; }
- break;
- }
- Message oM = null;
- try { oM = m_oRdr.receive(m_oDad.millisToWait()); }
- catch (JMSException oJ)
- {
- m_oLogger.error("JMS error on receive",oJ);
- for (int i1=0; i1<3; i1++)
- try {checkMyParms(); } // try to reconnect to the queue
- catch (Exception e)
- { m_oLogger.error("Reconnecting to Queue",e);
- try { Thread.sleep(m_iSleepForThreads); }
- catch (InterruptedException e1)
- { //Just return
- return;
- }
- }
- }
- if (null==oM)
- continue;
+ protected void checkMyParms() throws Exception {
+ // Third arg is null - Exception will br thrown if listenQueue is not
+ // found
+ String sQueue = GpListener.obtainAtt(listenerConfig, LISTEN_QUEUE, null);
- AbstractAction oExec = null;
- try
- { Constructor oConst = m_oExecClass
- .getConstructor(GpListener.getActionClassArgs());
- oExec = (AbstractAction)oConst.newInstance
- (new Object[] {m_oParms,oM});
- }
- catch (Exception e)
- { m_oLogger.error("Can't instantiate action class",e);
- break;
- }
- // invoke the run method of the AbstractAction
- m_iQthr += 1;
- oExec.addObserver(this);
- new Thread(oExec).start();
- }
- if (null!=m_oQsess)
- try { m_oQsess.close(); }
- catch (Exception e1) {/* Tried my best - Just continue */}
- if (null!=m_oQconn)
- try { m_oQconn.close(); }
- catch (Exception e2) {/* Tried my best - Just continue */}
- } //______________________________
-
-/**
- * Implementation of Observer interface
- * <p/> Just count the number of active child threads
- *
- */
- public void update(Observable p_oObs, Object p_oUsrObj)
- {
- if (p_oUsrObj instanceof Integer)
- m_iQthr += ((Integer) p_oUsrObj).intValue();
- } //________________________________
+ // No problem if selector is null - everything in queue will be returned
+ m_sSelector = listenerConfig.getAttr(LISTEN_MSG_SELECTOR);
-
-} //____________________________________________________________________________
+ m_oQconn = null;
+ m_oQsess = null;
+ m_oQueue = null;
+
+ String sJndiType = GpListener.obtainAtt(listenerConfig, LISTEN_JNDI_TYPE,
+ "jboss");
+ String sJndiURL = GpListener.obtainAtt(listenerConfig, LISTEN_JNDI_URL,
+ "localhost");
+ Context oJndiCtx = AppServerContext.getServerContext(sJndiType,
+ sJndiURL);
+
+ String sFactClass = GpListener.obtainAtt(listenerConfig,
+ LISTEN_QUEUE_CONN_FACT, "ConnectionFactory");
+ Object tmp = oJndiCtx.lookup(sFactClass);
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+
+ m_oQconn = qcf.createQueueConnection();
+ m_oQueue = (Queue) oJndiCtx.lookup(sQueue);
+ m_oQsess = m_oQconn.createQueueSession(false,
+ TopicSession.AUTO_ACKNOWLEDGE);
+ m_oQconn.start();
+ jmsMessageReceiver = m_oQsess.createReceiver(m_oQueue, m_sSelector);
+
+ } // ________________________________
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.AbstractListener#receive()
+ */
+ @Override
+ protected Object[] receive() {
+ while (m_oDad.continueLooping()) {
+ Message jmsMessage = null;
+ try {
+ jmsMessage = jmsMessageReceiver.receive(m_oDad.millisToWait());
+ } catch (JMSException oJ) {
+ logger.error("JMS error on receive. Attempting JMS Destination reconnect.", oJ);
+ for (int i1 = 0; i1 < 3; i1++)
+ try {
+ checkMyParms();
+ } // try to reconnect to the queue
+ catch (Exception e) {
+ logger.error("Reconnecting to Queue", e);
+ try {
+ Thread.sleep(m_iSleepForThreads);
+ } catch (InterruptedException e1) { // Just return
+ logger.error("Unexpected thread interupt exception.", e);
+ return null;
+ }
+ }
+ }
+ if (null == jmsMessage) {
+ // REVIEW: Can this really happen i.e. the JMS
+ continue;
+ }
+
+ 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;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.AbstractListener#close()
+ */
+ @Override
+ protected void close() {
+ if (null != m_oQsess) {
+ try {
+ m_oQsess.close();
+ } catch (Exception e1) {/* Tried my best - Just continue */
+ }
+ }
+ if (null != m_oQconn) {
+ try {
+ m_oQconn.close();
+ } catch (Exception e2) {/* Tried my best - Just continue */
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.AbstractListener#processingError(java.lang.Object, org.jboss.soa.esb.actions.ActionProcessor, java.lang.Throwable)
+ */
+ @Override
+ protected void processingError(Object initialMessage, ActionProcessor processor, Throwable error) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.AbstractListener#processingComplete(java.lang.Object)
+ */
+ @Override
+ protected void processingComplete(Object initialMessage) {
+ }
+}
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -23,14 +23,27 @@
package org.jboss.soa.esb.listeners;
-import java.util.*;
-import java.sql.*;
-import javax.sql.*;
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
-import org.jboss.soa.esb.helpers.*;
-import org.jboss.soa.esb.helpers.persist.*;
-import org.jboss.soa.esb.actions.*;
-import org.jboss.soa.esb.util.*;
+import javax.sql.DataSource;
+
+import org.jboss.soa.esb.actions.ActionDefinitionFactory;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.helpers.DomElement;
+import org.jboss.soa.esb.helpers.persist.JdbcCleanConn;
+import org.jboss.soa.esb.helpers.persist.SimpleDataSource;
+import org.jboss.soa.esb.util.Util;
+
/**
* SqlTablePoller class
*
@@ -155,13 +168,13 @@
* @param p_oParms DomElement - Sub tree that corresponds to this instance
* @throws Exception
*/
- public SqlTablePoller(GpListener p_oDad, DomElement p_oParms) throws Exception
+ public SqlTablePoller(GpListener p_oDad, DomElement p_oParms, ActionDefinitionFactory actionDefinitionFactory) throws Exception
{
- super(p_oDad,p_oParms);
+ super(p_oDad, p_oParms, actionDefinitionFactory);
try { checkMyParms(); }
catch (Exception e)
{
- m_oLogger.error("checkMyParms() FAILED",e);
+ logger.error("checkMyParms() FAILED",e);
throw e;
}
} //__________________________________
@@ -174,19 +187,19 @@
protected void checkMyParms() throws Exception
{
- checkAndStoreAtt(m_oParms,SimpleDataSource.DRIVER ,null);
- checkAndStoreAtt(m_oParms,SimpleDataSource.URL ,null);
- checkAndStoreAtt(m_oParms,SimpleDataSource.USER ,"");
- checkAndStoreAtt(m_oParms,SimpleDataSource.PASSWORD ,"");
+ checkAndStoreAtt(listenerConfig,SimpleDataSource.DRIVER ,null);
+ checkAndStoreAtt(listenerConfig,SimpleDataSource.URL ,null);
+ checkAndStoreAtt(listenerConfig,SimpleDataSource.USER ,"");
+ checkAndStoreAtt(listenerConfig,SimpleDataSource.PASSWORD ,"");
for (TABLE_ATT oCurr : TABLE_ATT.values())
- checkAndStoreAtt(m_oParms,oCurr.toString(),null);
+ checkAndStoreAtt(listenerConfig,oCurr.toString(),null);
- checkAndStoreAtt(m_oParms,OPTIONAL_ATT.whereCondition.toString(),"");
- checkAndStoreAtt(m_oParms,OPTIONAL_ATT.orderBy.toString(),"");
+ checkAndStoreAtt(listenerConfig,OPTIONAL_ATT.whereCondition.toString(),"");
+ checkAndStoreAtt(listenerConfig,OPTIONAL_ATT.orderBy.toString(),"");
String sAtt = OPTIONAL_ATT.inProcessVals.toString();
- checkAndStoreAtt(m_oParms,sAtt,DEFAULT_STATES);
+ checkAndStoreAtt(listenerConfig,sAtt,DEFAULT_STATES);
m_sUpdStates = m_oVals.get(sAtt);
if (m_sUpdStates.length()<4)
throw new Exception("Parameter <"+sAtt+"> must be at least 4 characters long (PWED)");
@@ -219,12 +232,13 @@
} //________________________________
@Override
- protected Object preProcess(Object p_o) throws Exception
+ protected Object preProcess(Object p_o)
{
return p_o;
} //________________________________
- @Override
+ @SuppressWarnings("unchecked")
+ @Override
protected List<Object> pollForCandidates()
{
String sSel4U = selectForUpdStatement();
@@ -238,27 +252,29 @@
PreparedStatement PS = oConn.prepareStatement(sScan);
ResultSet RS = oConn.execQueryWait(PS,1);
- while (RS.next())
- { Map<String,Object> oColVals = new HashMap<String,Object>();
+ while (RS.next()) {
+ SQLPollResult rowParams = new SQLPollResult(sSel4U, sUpdStmt);
int iCurr = 0;
- for (String sColName : m_saCols)
- oColVals.put(sColName,RS.getObject(++iCurr));
+ for (String sColName : m_saCols) {
+ rowParams.put(sColName,RS.getObject(++iCurr));
+ }
+
// Set up the parameter object for the SqlRowAction
- AbstractSqlRowAction.Params oActionP = new AbstractSqlRowAction.Params();
- oActionP.omVals = oColVals;
- oActionP.sUpdStates = m_sUpdStates;
- oActionP.saCols = m_saCols;
- oActionP.saKeys = m_saKeys;
- oActionP.sSel4Upd = sSel4U;
- oActionP.sUpdate = sUpdStmt;
+ rowParams.sUpdStates = m_sUpdStates;
+ rowParams.saKeys = m_saKeys;
+ rowParams.sSel4Upd = sSel4U;
+ rowParams.sUpdate = sUpdStmt;
+
+ // Mark the row as "working"...
+ rowParams.changeStatusToWorking();
- oResults.add(oActionP);
+ oResults.add(rowParams);
}
}
catch (Exception e)
{
- m_oLogger.warn("Some triggers might not have been returned",e);
+ logger.warn("Some triggers might not have been returned",e);
}
finally
{
@@ -266,6 +282,7 @@
oConn.release();
}
+ logger.info("Returning " + oResults.size() + " rows.");
return oResults;
} //________________________________
@@ -362,4 +379,127 @@
return sb.append(" for update").toString();
} //________________________________
-} //____________________________________________________________________________
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.AbstractListener#close()
+ */
+ @Override
+ protected void close() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.AbstractListener#processingError(java.lang.Object, org.jboss.soa.esb.actions.ActionProcessor, java.lang.Throwable)
+ */
+ @Override
+ protected void processingError(Object initialMessage, ActionProcessor processor, Throwable error) {
+ // Mark the row as "error"...
+ ((SQLPollResult)initialMessage).changeStatusToError();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.AbstractListener#processingComplete(java.lang.Object)
+ */
+ @Override
+ protected void processingComplete(Object initialMessage) {
+ // Mark the row as "working"...
+ ((SQLPollResult)initialMessage).changeStatusToDone();
+ }
+
+ private class SQLPollResult extends LinkedHashMap implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String sUpdStates;
+
+ private String[] saKeys;
+
+ private String sSel4Upd, sUpdate;
+
+ private SQLPollResult(String sSel4Upd, String sUpdate) throws Exception {
+ this.sSel4Upd = sSel4Upd;
+ this.sUpdate = sUpdate;
+ }
+
+ private String getStatus(ROW_STATE p_oState) {
+ int iPos = p_oState.ordinal();
+ return sUpdStates.substring(iPos, ++iPos);
+ }
+
+ private boolean changeStatusToWorking() {
+ return changeStatus(ROW_STATE.Pending, ROW_STATE.Working);
+ }
+
+ private boolean changeStatusToDone() {
+ return changeStatus(ROW_STATE.Working, ROW_STATE.Done);
+ }
+
+ private boolean changeStatusToError() {
+ return changeStatus(ROW_STATE.Working, ROW_STATE.Error);
+ }
+
+ private boolean changeStatus(ROW_STATE fromState, ROW_STATE toState) {
+ JdbcCleanConn dbConnection = null;
+
+ try {
+ // This is expensive at the moment but will be OK once we get proper connection pooling enabled!
+ dbConnection = newDbConn();
+ } catch (Exception e) {
+ logger.error("Unable to get DB connection.", e);
+ throw new IllegalStateException("Unable to get DB connection.", e);
+ }
+
+ try {
+ PreparedStatement m_PSsel4U;
+ PreparedStatement m_PSupd;
+
+ m_PSsel4U = dbConnection.prepareStatement(sSel4Upd);
+ m_PSupd = dbConnection.prepareStatement(sUpdate);
+
+ int iParm=1;
+ for (String sColName : saKeys) {
+ Object oVal = get(sColName);
+ m_PSsel4U.setObject (iParm ,oVal);
+ // parameters are +1 in update statement
+ // autoincrement leaves things ready for next SQL parameter
+ m_PSupd.setObject (++iParm,oVal);
+ }
+
+ try {
+ ResultSet resultSet = dbConnection.execQueryWait(m_PSsel4U, 5);
+
+ if (resultSet.next()) {
+ String sOldStatus = resultSet.getString(1).substring(0, 1);
+
+ if (sOldStatus.equalsIgnoreCase(getStatus(fromState))) {
+ m_PSupd.setString(1, getStatus(toState));
+ dbConnection.execUpdWait(m_PSupd, 5);
+ dbConnection.commit();
+
+ if(logger.isDebugEnabled()) {
+ logger.debug("Successfully changed row state from " + fromState + " to " + toState + ".");
+ }
+
+ return true;
+ } else {
+ logger.warn("Cannot change row state from " + fromState + " to " + toState + ". Row not in state " + fromState);
+ return false;
+ }
+ }
+ logger.error("Row status change to " + toState + " has failed. Rolling back!!");
+ } catch(Exception e) {
+ logger.error("Row status change to " + toState + " has failed. Rolling back!!", e);
+ }
+
+ try {
+ dbConnection.rollback();
+ } catch (Exception e) {
+ logger.error("Unable to rollback row status change to " + fromState.name(), e);
+ }
+ } catch (Exception e) {
+ logger.error("Unexpected exception.", e);
+ } finally {
+ dbConnection.release();
+ }
+
+ return false;
+ }
+ }
+}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-01.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-01.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-01.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,16 +0,0 @@
- <Actions>
- <Action name="ActionA" processor="TestActionProcessor1">
- <property name="param1" value="val1" />
- <property name="param2" value="val2" />
- <property name="param3" value="val3" />
- </Action>
- <Action name="ActionB" processor="TestActionProcessor1">
- <property name="param1" value="val2" />
- </Action>
- <Action name="ActionC" processor="TestActionProcessor2" />
-
- <ProcessorAliases>
- <Alias name="TestActionProcessor1" class="org.jboss.soa.esb.actions.TestActionProcessor1" />
- <Alias name="TestActionProcessor2" class="org.jboss.soa.esb.actions.TestActionProcessor2" />
- </ProcessorAliases>
- </Actions>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-01.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-01.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-02.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-02.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-02.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,9 +0,0 @@
- <Actions>
- <Action name="" processor="TestActionProcessor1">
- <property name="param1" value="val1" />
- </Action>
-
- <ProcessorAliases>
- <Alias name="TestActionProcessor1" class="org.jboss.soa.esb.actions.TestActionProcessor1" />
- </ProcessorAliases>
- </Actions>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-02.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-02.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-03.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-03.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-03.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,9 +0,0 @@
- <Actions>
- <Action name="ActionA" processor="">
- <property name="param1" value="val1" />
- </Action>
-
- <ProcessorAliases>
- <Alias name="TestActionProcessor1" class="org.jboss.soa.esb.actions.TestActionProcessor1" />
- </ProcessorAliases>
- </Actions>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-03.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-03.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-04.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-04.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-04.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,9 +0,0 @@
- <Actions>
- <Action name="ActionA" processor="TestActionProcessor1">
- <property name="" value="val1" />
- </Action>
-
- <ProcessorAliases>
- <Alias name="TestActionProcessor1" class="org.jboss.soa.esb.actions.TestActionProcessor1" />
- </ProcessorAliases>
- </Actions>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-04.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-04.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-05.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-05.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-05.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,9 +0,0 @@
- <Actions>
- <Action name="ActionA" processor="TestActionProcessor1">
- <property name="param1" value="" />
- </Action>
-
- <ProcessorAliases>
- <Alias name="TestActionProcessor1" class="org.jboss.soa.esb.actions.TestActionProcessor1" />
- </ProcessorAliases>
- </Actions>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-05.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-05.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-06.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-06.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-06.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,9 +0,0 @@
- <Actions>
- <Action name="ActionA" processor="UnknownHandle1">
- <property name="param1" value="val1" />
- </Action>
-
- <ProcessorAliases>
- <Alias name="TestActionProcessor1" class="org.jboss.soa.esb.actions.TestActionProcessor1" />
- </ProcessorAliases>
- </Actions>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-06.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-06.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-07.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-07.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-07.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,9 +0,0 @@
- <Actions>
- <Action name="ActionA" processor="TestActionProcessor1">
- <property name="param1" value="val1" />
- </Action>
-
- <ProcessorAliases>
- <Alias name="" class="org.jboss.soa.esb.actions.TestActionProcessor1" />
- </ProcessorAliases>
- </Actions>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-07.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-07.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-08.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-08.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-08.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,6 +0,0 @@
- <Actions>
-
- <ProcessorAliases>
- <Alias name="TestActionProcessor1" class="org.jboss.soa.esb.actions.TestActionProcessor1" />
- </ProcessorAliases>
- </Actions>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-08.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-08.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-09.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-09.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-09.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,5 +0,0 @@
- <Actions>
- <Action name="ActionA" processor="TestActionProcessor1">
- <property name="param1" value="val1" />
- </Action>
- </Actions>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-09.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-09.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-10.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-10.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-10.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,8 +0,0 @@
- <Actions>
- <Action name="ActionA" processor="TestActionProcessor1">
- <property name="param1" value="val1" />
- </Action>
-
- <ProcessorAliases>
- </ProcessorAliases>
- </Actions>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-10.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-10.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-11.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-11.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-11.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,9 +0,0 @@
- <Actions>
- <Action name="ActionA" processor="TestActionProcessor1">
- <property name="param1" value="val1" />
- </Action>
-
- <ProcessorAliases>
- <Alias name="TestActionProcessor1" class="org.jboss.soa.esb.actions.TestActionProcessor1" />
- </ProcessorAliases>
- </Actions>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-11.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinition-Config-11.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinitionFactoryUnitTest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinitionFactoryUnitTest.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinitionFactoryUnitTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.helpers.KeyValuePair;
-import org.xml.sax.SAXException;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for the ActionDefinitionFactory class.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class ActionDefinitionFactoryUnitTest extends TestCase {
-
- public void test_good_config() throws SAXException, IOException, ConfigurationException {
- DomElement config = DomElement.fromInputStream(getClass().getResourceAsStream("ActionDefinition-Config-01.xml"));
- ActionDefinitionFactory factory = new ActionDefinitionFactory(config);
-
- // ActionProcessor Impl with a non-default public constructor
- ActionDefinition actionDef = factory.getInstance("ActionA");
- assertEquals("ActionA", actionDef.getName());
- List<KeyValuePair> properties = actionDef.getProperties();
- assertEquals(3, properties.size());
- TestActionProcessor1 processor1 = (TestActionProcessor1) actionDef.getProcessor();
- assertEquals(actionDef.getName(), processor1.name);
- assertEquals(properties, processor1.properties);
-
- actionDef = factory.getInstance("ActionB");
- assertEquals("ActionB", actionDef.getName());
- properties = actionDef.getProperties();
- assertEquals(1, properties.size());
- processor1 = (TestActionProcessor1) actionDef.getProcessor();
- assertEquals(actionDef.getName(), processor1.name);
- assertEquals(properties, processor1.properties);
-
- // ActionProcessor Impl with a non-default public constructor
- actionDef = factory.getInstance("ActionC");
- assertEquals("ActionC", actionDef.getName());
- TestActionProcessor2 processor2 = (TestActionProcessor2) actionDef.getProcessor();
- }
-
- public void test_bad_config() throws SAXException, IOException, ConfigurationException {
- test_bad_config("ActionDefinition-Config-02.xml", "Actions/Action has no 'name' defined.");
- test_bad_config("ActionDefinition-Config-03.xml", "Actions/Action [ActionA] has no 'processor' defined.");
- test_bad_config("ActionDefinition-Config-04.xml", "Actions/Action/property has no 'name' defined. Action [ActionA]");
- test_bad_config("ActionDefinition-Config-05.xml", "Actions/Action/property has no 'value' defined. Action [ActionA]");
- test_bad_config("ActionDefinition-Config-06.xml", "No action processor class defined for processor alias");
- test_bad_config("ActionDefinition-Config-07.xml", "Actions/ProcessorAliases/Alias has no 'name' defined");
- test_bad_config("ActionDefinition-Config-08.xml", "No 'Actions/Action' configurations");
- test_bad_config("ActionDefinition-Config-09.xml", "No 'Actions/ProcessorAliases' configuration");
- test_bad_config("ActionDefinition-Config-10.xml", "No action processor classes defined");
- }
-
- private void test_bad_config(String configName, String exceptionMsg) throws SAXException, IOException, ConfigurationException {
- DomElement config = DomElement.fromInputStream(getClass().getResourceAsStream(configName));
- try {
- new ActionDefinitionFactory(config);
- fail("Expected ConfigurationException");
- } catch(ConfigurationException e) {
- assertTrue("Expected config exception statrting with [" + exceptionMsg + "]. Instead, go [" + e.getMessage() + "]", e.getMessage().startsWith(exceptionMsg));
- }
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinitionFactoryUnitTest.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ActionDefinitionFactoryUnitTest.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/BaseTestActionProcessor.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/BaseTestActionProcessor.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/BaseTestActionProcessor.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.io.Serializable;
-
-/**
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public abstract class BaseTestActionProcessor implements ActionProcessor {
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
- */
- public abstract Object process(Object message) throws ActionProcessingException;
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
- */
- public Serializable getOkNotification(Object message) {
- return "OK: " + message;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
- */
- public Serializable getErrorNotification(Object message) {
- return "ERROR: " + message;
- }
-
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/BaseTestActionProcessor.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/BaseTestActionProcessor.java)
Deleted: labs/jbossesb/trunk/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 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ByteArrayToStringUnitTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-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);
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ByteArrayToStringUnitTest.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ByteArrayToStringUnitTest.java)
Deleted: labs/jbossesb/trunk/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 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/FileToByteArrayUnitTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-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));
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/FileToByteArrayUnitTest.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/FileToByteArrayUnitTest.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/LongToDateConverter.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/LongToDateConverter.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/LongToDateConverter.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.util.Date;
-
-/**
- * LongToDate Converter Test Action Handler.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class LongToDateConverter extends BaseTestActionProcessor {
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.actions.ActionProcessor#processAction(java.lang.Object)
- */
- public Object process(Object payload) throws ActionProcessingException {
- if(!(payload instanceof Long)) {
- throw new ActionProcessingException("This action handler only accepts Long object instances.");
- }
- System.out.println("LongToDateConverter");
-
- return new Date((Long)payload);
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/LongToDateConverter.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/LongToDateConverter.java)
Deleted: labs/jbossesb/trunk/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 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToCSVStringUnitTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-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;
- }
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToCSVStringUnitTest.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToCSVStringUnitTest.java)
Deleted: labs/jbossesb/trunk/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 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToFileWriterUnitTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-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));
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToFileWriterUnitTest.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ObjectToFileWriterUnitTest.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformAction-Config-01.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformAction-Config-01.xml 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformAction-Config-01.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,35 +0,0 @@
-<EsbConfig
- command-queue-class="org.jboss.soa.esb.command.InMemoryCommandQueue"
- command-queue-name="test-queue"
->
-
- <ListenerConfig
- listenerClass="org.jboss.soa.esb.util.MockPoller"
- actions="X12N837-to-HL7V3, Process-HL7V3-Claim, HL7V3-to-X12N837, Route-to-Claims"
- maxThreads="1"
- >
- </ListenerConfig>
-
- <Actions>
- <!--
- Under the new architecture I think these will be equivalent to "Contracts Definitions"?
- -->
- <Action name="X12N837-to-HL7V3" processor="Smooks" />
- <Action name="Process-HL7V3-Claim" processor="ClaimsProcessor" />
- <Action name="HL7V3-to-X12N837" processor="Smooks" />
- <Action name="Route-to-Claims" processor="SocketRouter">
- <property name="address" value="xxxxx" />
- </Action>
-
- <ProcessorAliases>
- <!--
- Under the new architecture I think these will be equivalent to "Services"? The alias "name" being like the Service URN.
- -->
- <Alias name="Smooks" class="org.jboss.soa.esb.actions.SmooksTransformActionProcessor" />
- <Alias name="ClaimsProcessor" class="com.acme.health.ClaimsProcessor" />
- <Alias name="JmsRouter" class="org.jboss.soa.esb.actions.JmsRouter" />
- <Alias name="SocketRouter" class="org.jboss.soa.esb.actions.SocketRouter" />
- </ProcessorAliases>
- </Actions>
-
-</EsbConfig>
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformAction-Config-01.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformAction-Config-01.xml)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionFuncTest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionFuncTest.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionFuncTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,18 +0,0 @@
-package org.jboss.soa.esb.actions;
-
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.listeners.GpListener;
-import org.jboss.soa.esb.util.ListenersManagerExecThread;
-
-import junit.framework.TestCase;
-
-public class SmooksTransformActionFuncTest extends TestCase {
-
- public void test() throws Exception {
- DomElement config = DomElement.fromInputStream(getClass().getResourceAsStream("SmooksTransformAction-Config-01.xml"));
- GpListener listenerManager = new GpListener(config);
- ListenersManagerExecThread execThread = new ListenersManagerExecThread(listenerManager);
-
- // TODO: ... Work in progress...
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionFuncTest.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionFuncTest.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionUnitTest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionUnitTest.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionUnitTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,10 +0,0 @@
-package org.jboss.soa.esb.actions;
-
-import junit.framework.TestCase;
-
-public class SmooksTransformActionUnitTest extends TestCase {
-
- public void test() {
- // TODO: ... Work in progress...
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionUnitTest.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/SmooksTransformActionUnitTest.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/StringToLongConverter.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/StringToLongConverter.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/StringToLongConverter.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-/**
- * StringToLong Converter Test Action Handler.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class StringToLongConverter extends BaseTestActionProcessor {
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.actions.ActionProcessor#processAction(java.lang.Object)
- */
- public Object process(Object payload) throws ActionProcessingException {
- if(!(payload instanceof String)) {
- throw new ActionProcessingException("This action handler only accepts String object instances.");
- }
-
- System.out.println("StringToLongConverter");
-
- return Long.parseLong((String)payload);
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/StringToLongConverter.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/StringToLongConverter.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor1.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor1.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor1.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.util.List;
-
-import org.jboss.soa.esb.helpers.KeyValuePair;
-
-/**
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-
-public class TestActionProcessor1 extends BaseTestActionProcessor {
-
- public String name;
- public List<KeyValuePair> properties;
-
- public TestActionProcessor1(String name, List<KeyValuePair> properties) {
- System.out.println("Instantiate action handler: " + name);
-
- this.name = name;
- this.properties = properties;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.actions.ActionProcessor#processAction(java.lang.Object)
- */
- public Object process(Object payload) {
- System.out.println("processAction: " + payload);
- return payload;
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor1.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor1.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor2.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor2.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor2.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-/**
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-
-public class TestActionProcessor2 extends BaseTestActionProcessor {
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.actions.ActionProcessor#processAction(java.lang.Object)
- */
- public Object process(Object payload) {
- System.out.println("processAction: " + payload);
- return payload;
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor2.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor2.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor3.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor3.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor3.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-/**
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-
-public class TestActionProcessor3 extends BaseTestActionProcessor {
-
- public TestActionProcessor3(String name) {
- System.out.println("Instantiate action handler: " + name);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.actions.ActionProcessor#processAction(java.lang.Object)
- */
- public Object process(Object payload) {
- System.out.println("processAction: " + payload);
- return payload;
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor3.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/TestActionProcessor3.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ToNowhereRouter.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ToNowhereRouter.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ToNowhereRouter.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class ToNowhereRouter extends BaseTestActionProcessor {
-
- public static List objects = new ArrayList();
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.actions.ActionProcessor#processAction(java.lang.Object)
- */
- public Object process(Object payload) throws ActionProcessingException {
- objects.add(payload);
-
- System.out.println("ToNowhereRouter");
-
- return null;
- }
-
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ToNowhereRouter.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/actions/ToNowhereRouter.java)
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/command (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/command)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/command/InMemoryCommandQueueUnitTest.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/command/InMemoryCommandQueueUnitTest.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/command/InMemoryCommandQueueUnitTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,121 +0,0 @@
-package org.jboss.soa.esb.command;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.soa.esb.helpers.DomElement;
-
-import junit.framework.TestCase;
-
-public class InMemoryCommandQueueUnitTest extends TestCase {
-
- public void test_args() throws CommandQueueException {
- InMemoryCommandQueue commandQueue = new InMemoryCommandQueue();
-
- try {
- commandQueue.open(null);
- fail("Expected IllegalArgumentException.");
- } catch (IllegalArgumentException e) {
- // OK
- }
-
- DomElement config = new DomElement("config");
- try {
- commandQueue.open(config);
- fail("Expected CommandQueueException.");
- } catch (CommandQueueException e) {
- // OK
- }
- }
-
- public void test_queue_open_close() throws CommandQueueException {
- DomElement config = new DomElement("config");
- InMemoryCommandQueue commandQueue = new InMemoryCommandQueue();
-
- config.setAttr(InMemoryCommandQueue.COMMAND_QUEUE_NAME, "test-queue");
- assertEquals(null, InMemoryCommandQueue.getQueue("test-queue"));
- commandQueue.open(config);
- assertEquals(commandQueue, InMemoryCommandQueue.getQueue("test-queue"));
- commandQueue.close();
- assertEquals(null, InMemoryCommandQueue.getQueue("test-queue"));
- }
-
- public void test_queue_receive() throws CommandQueueException, InterruptedException {
- DomElement config = new DomElement("config");
- InMemoryCommandQueue commandQueue = new InMemoryCommandQueue();
-
- // receive should fail if the queue hasn't been opened yet...
- try {
- commandQueue.receiveCommand(0);
- fail("Expected CommandQueueException.");
- } catch (CommandQueueException e) {
- // OK
- }
-
- config.setAttr(InMemoryCommandQueue.COMMAND_QUEUE_NAME, "test-queue");
- commandQueue.open(config);
-
- // Start the consumer thread - it will receive the commands from the queue.
- CommandConsumerThread consumerThread = new CommandConsumerThread(commandQueue);
- consumerThread.start();
-
- // Make sure the thread is running.
- assertTrue(consumerThread.isRunning);
-
- commandQueue.addCommand("command1");
- assertCommandReceived(consumerThread, "command1", 0);
- commandQueue.addCommand("command2");
- assertCommandReceived(consumerThread, "command2", 1);
- commandQueue.addCommand("command3");
- assertCommandReceived(consumerThread, "command3", 2);
-
- // Stop the queue thread...
- commandQueue.addCommand("stop");
- Thread.sleep(50);
- assertTrue(!consumerThread.isRunning); // this flag being reset proves the stop command was consumed and so the queue is really working
- assertEquals(4, consumerThread.unblockCount); // Should have unblocked 4 times - once for each command.
-
- // receive should fail if the queue has been closed...
- commandQueue.close();
- try {
- commandQueue.receiveCommand(0);
- fail("Expected CommandQueueException.");
- } catch (CommandQueueException e) {
- // OK
- }
- }
-
- private void assertCommandReceived(CommandConsumerThread consumerThread, String expected, int index) throws InterruptedException {
- Thread.sleep(50);
- assertEquals("Received commands queue is not the expected length.", index + 1, consumerThread.commandsReceived.size());
- assertEquals("Command not found as last added command.", expected, consumerThread.commandsReceived.get(index));
- }
-
- private class CommandConsumerThread extends Thread {
-
- private List<String> commandsReceived = new ArrayList<String>();
- private CommandQueue commandQueue;
- private boolean isRunning = true;
- private int unblockCount = 0;
-
- private CommandConsumerThread(CommandQueue commandQueue) {
- this.commandQueue = commandQueue;
- }
-
- @Override
- public void run() {
- String command = null;
-
- while(!"stop".equals(command)) {
- try {
- command = commandQueue.receiveCommand(0);
- commandsReceived.add(command);
- } catch (CommandQueueException e) {
- fail("CommandQueue Exception: " + e.getMessage());
- }
- unblockCount++;
- }
- isRunning = false;
- }
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/command/InMemoryCommandQueueUnitTest.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/command/InMemoryCommandQueueUnitTest.java)
Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/DirectoryPollerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/DirectoryPollerUnitTest.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/DirectoryPollerUnitTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -42,7 +42,7 @@
// This should fail
DirectoryPoller dirPoller = null;
try {
- dirPoller = new DirectoryPoller(null,null);
+ dirPoller = new DirectoryPoller(null,null, null);
fail("GpListener should fail with empty constructor string");
} catch (Exception e) {
}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/GpListener-Config-01.xml (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/GpListener-Config-01.xml)
Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/GpListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/GpListenerUnitTest.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/GpListenerUnitTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -21,7 +21,14 @@
*/
package org.jboss.soa.esb.listeners;
+import java.util.Date;
+
+import org.jboss.soa.esb.actions.ToNowhereRouter;
+import org.jboss.soa.esb.command.InMemoryCommandQueue;
import org.jboss.soa.esb.common.tests.BaseTest;
+import org.jboss.soa.esb.helpers.DomElement;
+import org.jboss.soa.esb.util.ListenersManagerExecThread;
+import org.jboss.soa.esb.util.MockPoller;
/**
* Test the GpListener
@@ -50,7 +57,34 @@
-
-
-
+ public void test_newGpListener() throws Exception {
+ DomElement config = DomElement.fromInputStream(getClass().getResourceAsStream("GpListener-Config-01.xml"));
+ GpListener listenerManager = new GpListener(config);
+ ListenersManagerExecThread execThread = new ListenersManagerExecThread(listenerManager);
+ long currentTimeInMillis = System.currentTimeMillis();
+
+ // Clear the routing processor at the end of the pipeline...
+ ToNowhereRouter.objects.clear();
+
+ // Start the GpListener command thread...
+ execThread.start();
+
+ // Stick the current time into the poller as a String...
+ MockPoller.addToQueue("" + currentTimeInMillis);
+
+ // The message has been pulled from the poller in-queue at this stage because MockPoller.addToQueue blocks.
+ // Wait for a few milliseconds to allow the processor pipeline do it's thing...
+ Thread.sleep(200);
+
+ // Check did the "payload" get processed. The String containing the time should have been processed down the
+ // pileline and into a Date object in the ToNowhereRouter (mock routing processor) at the end of the pipeline...
+ assertEquals(1, ToNowhereRouter.objects.size());
+ Object date = ToNowhereRouter.objects.get(0);
+ assertTrue(date instanceof Date);
+ assertEquals(new Date(currentTimeInMillis), date);
+
+ // Send a shutdown command to the GpListener...
+ InMemoryCommandQueue.getQueue("test-queue").addCommand("shutdown");
+ execThread.assertShutdownOK(10000);
+ }
}
Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/SqlTablePollerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/SqlTablePollerUnitTest.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/SqlTablePollerUnitTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -41,7 +41,7 @@
// This should fail
SqlTablePoller sqlPoller = null;
try {
- sqlPoller = new SqlTablePoller(null, null);
+ sqlPoller = new SqlTablePoller(null, null, null);
fail("SqlTablePoller should fail with empty constructor string");
} catch (Exception e) {
}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/util)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/ListenersManagerExecThread.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/util/ListenersManagerExecThread.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/ListenersManagerExecThread.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,90 +0,0 @@
-package org.jboss.soa.esb.util;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.listeners.GpListener;
-
-public class ListenersManagerExecThread extends Thread {
-
- private static Logger logger = Logger.getLogger(ListenersManagerExecThread.class);
- private GpListener listenersManager;
-
- public ListenersManagerExecThread(GpListener listenersManager) {
- super(listenersManager);
- this.listenersManager = listenersManager;
- }
-
- @Override
- public synchronized void start() {
- logger.info("Waiting on Listener Manager the start...");
- super.start();
- while(listenersManager.getState() != GpListener.State.Running) {
- try {
- sleep(50);
- } catch (InterruptedException e) {
- throw new IllegalStateException("Unexpected Thread Interrupt exception.", e);
- }
- if(listenersManager.getState() == GpListener.State.Exception_thrown) {
- Exception e = listenersManager.getState().getException();
- logger.error("Failed to start the Listener Manager!", e);
- TestCase.fail(e.getMessage());
- }
- }
- logger.info("Listener Manager running (Thread: " + getName() + ")! Note this does not mean all the Listeners are up and running!");
- }
-
-
- /**
- * Get the {@link GpListener} Listeners Manager class executing in this thread.
- * @return The listenersManager property value.
- */
- public GpListener getListenersManager() {
- return listenersManager;
- }
-
- /**
- * Assert that the listener Manager is in an Exception state..
- */
- public void asserttInException() {
- if(listenersManager.getState() != GpListener.State.Exception_thrown) {
- String errorMsg = "GpListener not in Exception state. Listener Manager Thread: " + this.getName();
- logger.error(errorMsg);
- TestCase.fail(errorMsg);
- }
- }
-
- /**
- * Assert that the listener Manager is not in an Exception state..
- */
- public void assertNotInException() {
- if(listenersManager.getState() == GpListener.State.Exception_thrown) {
- String errorMsg = "GpListener in Exception state. See log. Listener Manager Thread: " + this.getName();
- logger.error(errorMsg, listenersManager.getState().getException());
- TestCase.fail(errorMsg);
- }
- }
-
- /**
- * Assert that the listener Manager has shutdown.
- * @param maxWait The maximum length of time (ms) to wait for shutdown before failing the test.
- */
- public void assertShutdownOK(long maxWait) {
- long endTime = System.currentTimeMillis() + maxWait;
-
- while(System.currentTimeMillis() < endTime) {
- if(listenersManager.getState() == GpListener.State.Done_OK) {
- logger.info("Shutdown was successful. Listener Manager Thread: " + this.getName());
- return;
- }
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- logger.error("Thread interupt...", e);
- }
- }
- String errorMsg = "GpListener failed to shutdown as requested. Waited for " + maxWait + "ms. Listener Manager Thread: " + this.getName();
- logger.error(errorMsg);
- TestCase.fail(errorMsg);
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/ListenersManagerExecThread.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/util/ListenersManagerExecThread.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockNotificationTarget.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockNotificationTarget.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockNotificationTarget.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,68 +0,0 @@
-package org.jboss.soa.esb.util;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.notification.NotificationTarget;
-
-/**
- * Mock NotificationTarget Implementation.
- * <p/>
- * Configured by giving the target output list a 'name'. Notifications are statically accessed via the static
- * {@link #getTargetList(String)} method, supplying the target list name.
- * <p/>
- * Sample config:
- * <pre>
- * <NotificationList type="OK">
- * <target class="org.jboss.soa.esb.util.MockNotificationTarget" <b>name="ok-target"</b> />
- * </NotificationList>
- * </pre>
- * @author tfennelly
- */
-public class MockNotificationTarget extends NotificationTarget {
-
- private static Hashtable<String, List<Serializable>> targetLists = new Hashtable<String, List<Serializable>>();
- private List<Serializable> targetList;
-
- public MockNotificationTarget(DomElement config) {
- super(config);
-
- String name = config.getAttr("name");
-
- if(name == null || name.trim().equals("")) {
- TestCase.fail("Mock NotificationTarget configured incorrectly. Must specify a 'name' attribute on the NotificationList/target element.");
- }
-
- targetList = getTargetList(name);
- }
-
- public static List<Serializable> getTargetList(String name) {
- synchronized (targetLists) {
- List<Serializable> notificationList = targetLists.get(name);
-
- // Never return a null list.
- if(notificationList == null) {
- notificationList = new ArrayList<Serializable>();
- targetLists.put(name, notificationList);
- }
-
- return notificationList;
- }
- }
-
- public static void clearNotifications() {
- synchronized (targetLists) {
- targetLists.clear();
- }
- }
-
- @Override
- public void sendNotification(Serializable notificationObject) throws Exception {
- targetList.add(notificationObject);
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockNotificationTarget.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockNotificationTarget.java)
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockPoller.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockPoller.java 2006-09-18 16:42:58 UTC (rev 6281)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockPoller.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,91 +0,0 @@
-package org.jboss.soa.esb.util;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-import org.jboss.soa.esb.actions.ActionDefinitionFactory;
-import org.jboss.soa.esb.actions.ActionProcessor;
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.listeners.AbstractPoller;
-import org.jboss.soa.esb.listeners.GpListener;
-
-/**
- * Simple Mock {@link org.jboss.soa.esb.listeners.AbstractPoller} implementation that can be used for testing.
- * <p/>
- * Maintains a static in-memory queue into which objects can be dropped for processing by the configured action handler.
- * @author tfennelly
- */
-public class MockPoller extends AbstractPoller {
-
- private static Queue queue = new ConcurrentLinkedQueue<Object>();
-
- public MockPoller(GpListener p_oDad, DomElement p_oParms, ActionDefinitionFactory actionDefinitionFactory) throws Exception {
- super(p_oDad, p_oParms, actionDefinitionFactory);
- m_iPollMillis = 250;
- }
-
- /**
- * Add an object for processing by the configured action handler.
- * <p/>
- * Blocks indefinitely until the message is consumed.
- * @param actionObject The Object instance for processing.
- */
- public static void addToQueue(Object actionObject) {
- synchronized (queue) {
- queue.add(actionObject);
- }
- while(!queue.isEmpty()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- throw new IllegalStateException("Unexpected thread interupt.", e);
- }
- }
- }
-
- public static void clearQueue() {
- synchronized (queue) {
- queue.clear();
- }
- }
-
- @Override
- protected List<Object> pollForCandidates() {
- // This method is called periodically by the AbstractPoller.
- synchronized (queue) {
- List<Object> actionObjects = Arrays.asList(queue.toArray());
- queue.clear();
- return actionObjects;
- }
- }
-
- @Override
- protected Object preProcess(Object actionObject) {
- // Called by the AbstractPoller for each of the objects returned to it be the above pollForCandidates method.
- // Just return the object to be processed by the action class that's configured on the listener.
- return actionObject;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.listeners.AbstractListener#close()
- */
- @Override
- protected void close() {
- }
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.listeners.AbstractListener#processingError(java.lang.Object, org.jboss.soa.esb.actions.ActionProcessor, java.lang.Throwable)
- */
- @Override
- protected void processingError(Object initialMessage, ActionProcessor processor, Throwable error) {
- }
-
- /* (non-Javadoc)
- * @see org.jboss.soa.esb.listeners.AbstractListener#processingComplete(java.lang.Object)
- */
- @Override
- protected void processingComplete(Object initialMessage) {
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockPoller.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/core/listeners/tests/src/org/jboss/soa/esb/util/MockPoller.java)
Modified: labs/jbossesb/trunk/product/docs/samples/TestJBossESB/paramsDir/FileMoverConfigExample.xml
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/TestJBossESB/paramsDir/FileMoverConfigExample.xml 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/docs/samples/TestJBossESB/paramsDir/FileMoverConfigExample.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,36 +1,43 @@
<JBossESB parameterReloadSecs="60">
<FilePollerTest
listenerClass="org.jboss.soa.esb.listeners.DirectoryPoller"
- actionClass="org.jboss.soa.esb.actions.FileCopier"
+ actions="Copy-File-To-OutOkDir"
pollLatencySecs="3"
maxThreads="1"
- inputDirURI="file:///C:/de/jbossesb/product/docs/samples/TestJBossESB/inputDir"
+ inputDirURI="./inputDir"
inputSuffix=".inp"
workSuffix=".INPROC"
- errorDirURI="file:///C:/dev/jbossesb/product/docs/samples/TestJBossESB/errorDir"
+ errorDirURI="./errorDir"
errorSuffix=".ERR"
- postDirURI="file:///C:/dev/jbossesb/product/docs/samples/TestJBossESB/inputDoneDir"
+ postDirURI="./inputDoneDir"
postSuffix=".DONE"
postDelete="n"
>
- <CopyTo copyToDirURI="file:///C:/dev/jbossesb/product/docs/samples/TestJBossESB//outputOkDir" copyToSuffix=".fileCopierOutput" />
-
-
<NotificationList type="OK">
<target class="NotifyFiles">
- <file URI="file:///C:/dev/jbossesb/product/docs/samples/TestJBossESB/notifyDir/notif.OK"
- append="true"
- />
+ <file URI="./notifyDir/notif.OK" append="true" />
</target>
</NotificationList>
<NotificationList type="ERR">
- <target class="NotifyFiles">
- <file URI="file:///C:/dev/jbossesb/product/docs/samples/TestJBossESB/notifyDir/notif.ERR"
- append="true"
- />
- </target>
+ <target class="NotifyFiles">
+ <file URI="./notifyDir/notif.ERR" append="true" />
+ </target>
</NotificationList>
- </FilePollerTest>
+ </FilePollerTest>
+
+
+ <Actions>
+ <Action name="Copy-File-To-OutOkDir" processor="FileCopier">
+ <property name="copyToDirURI" value="./outputOkDir" />
+ <property name="copyToSuffix" value=".fileCopierOutput" />
+ </Action>
+
+ <ProcessorAliases>
+ <Alias name="FileCopier" class="org.jboss.soa.esb.actions.FileCopier" />
+ </ProcessorAliases>
+ </Actions>
+
+
</JBossESB>
Modified: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -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/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml.template
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml.template 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml.template 2006-09-19 10:39:35 UTC (rev 6289)
@@ -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@"
Copied: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ObjectToXStream.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ObjectToXStream.java)
Deleted: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksFileResponse.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksFileResponse.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksFileResponse.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,87 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-
-package org.jboss.soa.esb.samples.loanbroker.actions;
-
-import java.io.Serializable;
-
-import org.jboss.soa.esb.actions.AbstractFileAction;
-import org.jboss.soa.esb.common.SystemProperties;
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.jboss.loanbroker.util.FileUtil;
-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 ProcessBanksFileResponse extends AbstractFileAction {
-
- public ProcessBanksFileResponse(DomElement p_oP, Object p_oCurr) {
- super(p_oP, p_oCurr);
- }
-
- @Override
- public void processCurrentObject() throws Exception {
- m_oLogger.info("processObject was called with <<"
- +m_oCurr.toString()+">>");
-
-// File file = getInputFile();
- String message = FileUtil.readTextFile(getWorkFile());
- String[] messagePart = message.split(",");
- long uid = Long.parseLong(messagePart[3]);
-
-// 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, uid);
- m_oLogger.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, messagePart[0]);
- offer.setField(LoanOffer.ATTRIB.quoteId, messagePart[1]);
- offer.setField(LoanOffer.ATTRIB.errorCode, messagePart[2]);
- customer.addOffer(offer);
- esbHandler.rplObject(customer); //update the object store
- m_oLogger.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
- {
- ProcessEmail email = new ProcessEmail(customer);
- email.sendEmail();
- }
-
- }
-
- @Override
- public Serializable getOkNotification() {
- return "OK NOTIF: " + this.getClass();
- }
-
- @Override
- public Serializable getErrorNotification() {
- return "ERR NOTIFICATION: "+this.getClass();
- }
-
-}
Deleted: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksJMSResponse.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksJMSResponse.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksJMSResponse.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,113 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-package org.jboss.soa.esb.samples.loanbroker.actions;
-
-import java.io.Serializable;
-
-import javax.jms.TextMessage;
-
-import org.jboss.soa.esb.actions.AbstractAction;
-import org.jboss.soa.esb.common.SystemProperties;
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.listeners.GpListener;
-import org.jboss.soa.esb.samples.loanbroker.adapters.CustomerAdapter;
-import org.jboss.soa.esb.samples.loanbroker.banks.BanksQuoteResponse;
-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 ProcessBanksJMSResponse extends AbstractAction {
-
- private BanksQuoteResponse bankResponse;
-
- public ProcessBanksJMSResponse(DomElement p_oP, Object p_oCurr) {
- super(p_oP, p_oCurr);
- }
-
- @Override
- public void processCurrentObject() throws Exception {
- m_oLogger.info("processObject was called with <<"
- +m_oCurr.toString()+">>");
-
- if (! (m_oCurr instanceof TextMessage))
- throw new Exception("Message must be a TextMessage");
-
- String sVal = (String)((TextMessage)m_oCurr).getText();
- bankResponse = CustomerAdapter.bankQuoteFromXML(sVal);
-// 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);
- m_oLogger.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
- m_oLogger.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
- {
- ProcessEmail email = new ProcessEmail(customer);;
- email.sendEmail();
- }
-
- }
-
- @Override
- public Serializable getOkNotification() {
- return "OK NOTIF: " + this.getClass().getSimpleName();
- }
-
- @Override
- public Serializable getErrorNotification() {
- return "ERR NOTIFICATION: "+this.getClass().getSimpleName();
- }
-
- 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));
- }
- } //________________________________
-
-}
Copied: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksResponse.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessBanksResponse.java)
Modified: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -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/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -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();
+ }
}
Copied: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ToBankQuoteResponse.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ToBankQuoteResponse.java)
Modified: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -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);
Copied: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java)
Copied: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteResponse.java (from rev 6281, labs/jbossesb/workspace/tfennelly/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteResponse.java)
Deleted: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BanksQuoteRequest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BanksQuoteRequest.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BanksQuoteRequest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,72 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-
-public class BanksQuoteRequest {
-
- public int ssn;
- public int creditScore;
- public int historyLength=0; //setting to 0 for now, don't have that in the CreditAgency
- public int loanAmount;
- public int loanTerm;
- public long customerUID;
-
- public BanksQuoteRequest() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- public int getCreditScore() {
- return creditScore;
- }
-
- public void setCreditScore(int creditScore) {
- this.creditScore = creditScore;
- }
-
- public int getLoanAmount() {
- return loanAmount;
- }
-
- public void setLoanAmount(int loanAmount) {
- this.loanAmount = loanAmount;
- }
-
- public int getLoanTerm() {
- return loanTerm;
- }
-
- public void setLoanTerm(int loanTerm) {
- this.loanTerm = loanTerm;
- }
-
- public int getSsn() {
- return ssn;
- }
-
- public void setSsn(int ssn) {
- this.ssn = ssn;
- }
-
-}
Deleted: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BanksQuoteResponse.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BanksQuoteResponse.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/banks/BanksQuoteResponse.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -1,18 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-public class BanksQuoteResponse implements Serializable{
-
- private static final long serialVersionUID = 1L;
- public BigDecimal interestRate;
- public String quoteId;
- public int errorCode;
- public long customerUID;
-
- public BanksQuoteResponse() {
- super();
- }
-
-}
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponseNotification.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponseNotification.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponseNotification.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -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/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig1.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig1.xml 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig1.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -10,25 +10,32 @@
>
<PollDirectoryExample
listenerClass="org.jboss.soa.esb.listeners.DirectoryPoller"
- actionClass="org.jboss.soa.esb.actions.FileCopier"
+ actions="FileCopy1, FileCopy2"
pollLatencySecs="2"
maxThreads="2"
inputDirURI="@qa.build@/inputDir"
inputSuffix=".inp"
- workSuffix=".COPYING"
- errorSuffix=".COPYERR"
+ workSuffix=".WORKING"
+ errorSuffix=".PROCERR"
postDirURI="@qa.build@/inputDoneDir"
postSuffix=".DONE"
postDelete="n"
>
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromFirst"
- />
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromSecond"
- />
</PollDirectoryExample>
+
+ <Actions>
+ <Action name="FileCopy1" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromFirst"/>
+ </Action>
+ <Action name="FileCopy2" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromSecond"/>
+ </Action>
+ <ProcessorAliases>
+ <Alias name="FileCopier" class="org.jboss.soa.esb.actions.FileCopier" />
+ </ProcessorAliases>
+ </Actions>
+
</FileCopierExample>
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig2.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig2.xml 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig2.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -10,25 +10,32 @@
>
<PollDirectoryExample
listenerClass="org.jboss.soa.esb.listeners.DirectoryPoller"
- actionClass="org.jboss.soa.esb.actions.FileCopier"
+ actions="FileCopy1, FileCopy2"
pollLatencySecs="2"
maxThreads="2"
inputDirURI="@qa.build@/inputDir"
inputSuffix=".inp"
- workSuffix=".COPYING"
- errorSuffix=".COPYERR"
+ workSuffix=".WORKING"
+ errorSuffix=".PROCERR"
postDirURI="@qa.build@/inputDoneDir"
postSuffix=".DONE"
postDelete="n"
>
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromFirst"
- />
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromSecond"
- />
</PollDirectoryExample>
+
+ <Actions>
+ <Action name="FileCopy1" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromFirst"/>
+ </Action>
+ <Action name="FileCopy2" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromSecond"/>
+ </Action>
+ <ProcessorAliases>
+ <Alias name="FileCopier" class="org.jboss.soa.esb.actions.FileCopier" />
+ </ProcessorAliases>
+ </Actions>
+
</FileCopierExample>
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig3.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig3.xml 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig3.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -10,25 +10,32 @@
>
<PollDirectoryExample
listenerClass="org.jboss.soa.esb.listeners.DirectoryPoller"
- actionClass="org.jboss.soa.esb.actions.FileCopier"
+ actions="FileCopy1, FileCopy2"
pollLatencySecs="2"
maxThreads="2"
inputDirURI="@qa.build@/inputDir"
inputSuffix=".inp"
- workSuffix=".COPYING"
- errorSuffix=".COPYERR"
+ workSuffix=".WORKING"
+ errorSuffix=".PROCERR"
postDirURI="@qa.build@/inputDoneDir"
postSuffix=".DONE"
postDelete="n"
>
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromFirst"
- />
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromSecond"
- />
</PollDirectoryExample>
+
+ <Actions>
+ <Action name="FileCopy1" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromFirst"/>
+ </Action>
+ <Action name="FileCopy2" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromSecond"/>
+ </Action>
+ <ProcessorAliases>
+ <Alias name="FileCopier" class="org.jboss.soa.esb.actions.FileCopier" />
+ </ProcessorAliases>
+ </Actions>
+
</FileCopierExample>
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig4.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig4.xml 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig4.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -10,25 +10,32 @@
>
<PollDirectoryExample
listenerClass="org.jboss.soa.esb.listeners.DirectoryPoller"
- actionClass="org.jboss.soa.esb.actions.FileCopier"
+ actions="FileCopy1, FileCopy2"
pollLatencySecs="2"
maxThreads="2"
inputDirURI="@qa.build@/inputDir"
inputSuffix=".inp"
- workSuffix=".COPYING"
- errorSuffix=".COPYERR"
+ workSuffix=".WORKING"
+ errorSuffix=".PROCERR"
postDirURI="@qa.build@/inputDoneDir"
postSuffix=".DONE"
postDelete="n"
>
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromFirst"
- />
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromSecond"
- />
</PollDirectoryExample>
+
+ <Actions>
+ <Action name="FileCopy1" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromFirst"/>
+ </Action>
+ <Action name="FileCopy2" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromSecond"/>
+ </Action>
+ <ProcessorAliases>
+ <Alias name="FileCopier" class="org.jboss.soa.esb.actions.FileCopier" />
+ </ProcessorAliases>
+ </Actions>
+
</FileCopierExample>
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig5.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig5.xml 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig5.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -10,25 +10,32 @@
>
<PollDirectoryExample
listenerClass="org.jboss.soa.esb.listeners.DirectoryPoller"
- actionClass="org.jboss.soa.esb.actions.FileCopier"
+ actions="FileCopy1, FileCopy2"
pollLatencySecs="2"
maxThreads="2"
inputDirURI="@qa.build@/inputDir"
inputSuffix=".inp"
- workSuffix=".COPYING"
- errorSuffix=".COPYERR"
+ workSuffix=".WORKING"
+ errorSuffix=".PROCERR"
postDirURI="@qa.build@/inputDoneDir"
postSuffix=".DONE"
postDelete="n"
>
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromFirst"
- />
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromSecond"
- />
</PollDirectoryExample>
+
+ <Actions>
+ <Action name="FileCopy1" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromFirst"/>
+ </Action>
+ <Action name="FileCopy2" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromSecond"/>
+ </Action>
+ <ProcessorAliases>
+ <Alias name="FileCopier" class="org.jboss.soa.esb.actions.FileCopier" />
+ </ProcessorAliases>
+ </Actions>
+
</FileCopierExample>
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig6.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig6.xml 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/BadConfig6.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -10,25 +10,32 @@
>
<PollDirectoryExample
listenerClass="org.jboss.soa.esb.listeners.DirectoryPoller"
- actionClass="org.jboss.soa.esb.actions.FileCopier"
+ actions="FileCopy1, FileCopy2"
pollLatencySecs="2"
maxThreads="2"
inputDirURI="@qa.build@/inputDir"
inputSuffix=".inp"
- workSuffix=".COPYING"
- errorSuffix=".COPYERR"
+ workSuffix=".WORKING"
+ errorSuffix=".PROCERR"
postDirURI="@qa.build@/inputDoneDir"
postSuffix=".DONE"
postDelete="n"
>
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromFirst"
- />
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromSecond"
- />
</PollDirectoryExample>
+
+ <Actions>
+ <Action name="FileCopy1" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromFirst"/>
+ </Action>
+ <Action name="FileCopy2" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromSecond"/>
+ </Action>
+ <ProcessorAliases>
+ <Alias name="FileCopier" class="org.jboss.soa.esb.actions.FileCopier" />
+ </ProcessorAliases>
+ </Actions>
+
</FileCopierExample>
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/DirectoryPollerConfig1.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/DirectoryPollerConfig1.xml 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/DirectoryPollerConfig1.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -8,25 +8,32 @@
>
<PollDirectoryExample
listenerClass="org.jboss.soa.esb.listeners.DirectoryPoller"
- actionClass="org.jboss.soa.esb.actions.FileCopier"
+ actions="FileCopy1, FileCopy2"
pollLatencySecs="2"
maxThreads="2"
inputDirURI="@qa.build@/inputDir"
inputSuffix=".inp"
- workSuffix=".COPYING"
- errorSuffix=".COPYERR"
+ workSuffix=".WORKING"
+ errorSuffix=".PROCERR"
postDirURI="@qa.build@/inputDoneDir"
postSuffix=".DONE"
postDelete="n"
>
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromFirst"
- />
- <CopyTo
- copyToDirURI="@qa.build@/copiedTo"
- copyToSuffix=".outFromSecond"
- />
</PollDirectoryExample>
+
+ <Actions>
+ <Action name="FileCopy1" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromFirst"/>
+ </Action>
+ <Action name="FileCopy2" processor="FileCopier">
+ <property name="copyToDirURI" value="@qa.build@/copiedTo"/>
+ <property name="copyToSuffix" value=".outFromSecond"/>
+ </Action>
+ <ProcessorAliases>
+ <Alias name="FileCopier" class="org.jboss.soa.esb.actions.FileCopier" />
+ </ProcessorAliases>
+ </Actions>
+
</FileCopierExample>
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/JmsQueueListenerConfig.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/JmsQueueListenerConfig.xml 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/JmsQueueListenerConfig.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -11,7 +11,7 @@
<QueueExample
listenerClass="org.jboss.soa.esb.listeners.JmsQueueListener"
- actionClass="org.jboss.soa.esb.actions.FileCopier"
+ actions="CaptureMessage"
maxThreads="1"
queueConnFactoryClass="ConnectionFactory"
listenJndiType="jboss"
@@ -36,4 +36,12 @@
</NotificationList>
</QueueExample>
+ <Actions>
+ <Action name="CaptureMessage" processor="MessageBox" />
+
+ <ProcessorAliases>
+ <Alias name="MessageBox" class="org.jboss.soa.esb.listeners.MessageBox" />
+ </ProcessorAliases>
+ </Actions>
+
</JmsListenerExample>
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/JmsQueueListenerTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/JmsQueueListenerTest.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/JmsQueueListenerTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -49,14 +49,21 @@
public void test() throws InterruptedException {
// There should have been no exceptions...
listenersMgr.assertNotInException();
+
+ MessageBox.messages.clear();
+
// Send a request via jms
- JMSClientUtil.sendMessageToQueue("hello is anyone there?", JMSClientUtil.QUEUE.A, new KeyValuePair[] {new KeyValuePair("gpMsgSelector", "zambia")});
+ JMSClientUtil.sendMessageToQueue("hello is anyone there?", JMSClientUtil.QUEUE.A, new KeyValuePair[] {new KeyValuePair("listener", "zambia")});
- //
- //
- //Check if the file was written, or if there is any acknowledgement from the listener
- //
- //
+ // Check did the messagebox recevive the message from the JMSListener...
+ MessageBox.assertMessageCount(1, 10000);
+
+ // Make sure the notifications appear in the "notifyDir" dir...
+ FileUtils.assertFileExists(new File(notifyDir, "JmsQueueListenerExample.notifOK"), 10000);
+ FileUtils.assertCanDelete(new File(notifyDir, "JmsQueueListenerExample.notifOK"), 10000);
+
+ // There should have been no exceptions...
+ listenersMgr.assertNotInException();
// Send a Shutdown message to the command queue...
JMSClientUtil.sendMessageToQueue("shutdown", JMSClientUtil.QUEUE.A, new KeyValuePair[] {new KeyValuePair("gpMsgSelector", "zambia")});
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/ListenerManagerTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/ListenerManagerTest.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/ListenerManagerTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -24,6 +24,7 @@
import javax.naming.CommunicationException;
import javax.naming.NameNotFoundException;
+import org.jboss.soa.esb.command.CommandQueueException;
import org.jboss.soa.esb.util.ClassUtils;
import org.jboss.soa.esb.util.ListenerUtils;
@@ -58,11 +59,11 @@
fail("[Param '" + paramName + "' test] No exception being thrown for bad param config!! Expected Exception: " + expectedException.getName());
}
} catch(AssertionFailedError e) {
- throw e;
- } catch(Throwable e) {
+ throw e;
+ } catch(CommandQueueException e) {
if(expectedException == null) {
fail("[Param '" + paramName + "' test] Unexpected Exception: " + e.getClass().getName() + ": " + e.getMessage());
- } else if(!expectedException.isInstance(e)) {
+ } else if(!expectedException.isInstance(e) && !expectedException.isInstance(e.getCause())) {
fail("[Param '" + paramName + "' test] Expected Exception: " + expectedException.getName() + ". Got " + e.getClass().getName() + ": " + e.getMessage());
}
// Is the expected Exception!!
Copied: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/MessageBox.java (from rev 6281, labs/jbossesb/workspace/tfennelly/qa/junit/src/org/jboss/soa/esb/listeners/MessageBox.java)
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerConfig1.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerConfig1.xml 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerConfig1.xml 2006-09-19 10:39:35 UTC (rev 6289)
@@ -9,7 +9,7 @@
<PollSqlTableExample
listenerClass="org.jboss.soa.esb.listeners.SqlTablePoller"
- actionClass="org.jboss.soa.esb.actions.DummySqlRowAction"
+ actions="CaptureMessage, ProcessMessageFromSQL"
pollLatencySecs="2"
maxThreads="2"
connection-url="@db.url@"
@@ -38,6 +38,17 @@
/>
</target>
</NotificationList>
+
+ <Actions>
+ <Action name="CaptureMessage" processor="MessageBox" />
+ <Action name="ProcessMessageFromSQL" processor="SQLProcessor"/>
+
+ <ProcessorAliases>
+ <Alias name="MessageBox" class="org.jboss.soa.esb.listeners.MessageBox" />
+ <Alias name="SQLProcessor" class="org.jboss.soa.esb.actions.DummySqlRowAction" />
+ </ProcessorAliases>
+ </Actions>
+
</PollSqlTableExample>
</LoanBrokerExample>
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/SQLTablePollerTest.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -23,7 +23,9 @@
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.util.ClassUtils;
import org.jboss.soa.esb.util.DbUtils;
@@ -54,6 +56,9 @@
}
public void test() throws InterruptedException, SQLException {
+ MessageBox.messages.clear();
+ DummySqlRowAction.params.clear();
+
// Insert the row into the table and wait for the status to go to "P" (Pending) to "D" (Done)...
int insertCount = DbUtils.executeUpdate("insert into test_poll_table values ('pepe','ref1','An arbitrary message', '1111111111','2222222222','P')");
@@ -62,9 +67,18 @@
// FIXME: This assertion is broken - prob something wrong with the listener config - it's status isn't changing to "D" (Done)
DbUtils.assertNonEmptyResultSet("select * from test_poll_table where src='pepe' and ref='ref1' and status='D'", 10000);
+ // Check did the messagebox recevive the message from the JMSListener...
+ MessageBox.assertMessageCount(1, 10000);
+ assertEquals(1, DummySqlRowAction.params.size());
+ Map pollResult = DummySqlRowAction.params.get(0);
+
+ // Check the rowset values...
+ assertEquals("ref1", pollResult.get("ref"));
+ assertEquals("An arbitrary message", pollResult.get("msg"));
+ assertEquals("2222222222", pollResult.get("val2"));
+
// Make sure the notifications appear in the "notifyDir" dir...
FileUtils.assertFileExists(new File(notifyDir, "GpListenerExample.notifOK"), 10000);
- // Make sure there's no open file handles on the files created/copied by the ESB...
FileUtils.assertCanDelete(new File(notifyDir, "GpListenerExample.notifOK"), 10000);
// There should have been no exceptions...
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java 2006-09-18 22:20:26 UTC (rev 6288)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/FileUtils.java 2006-09-19 10:39:35 UTC (rev 6289)
@@ -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