[jboss-svn-commits] JBL Code SVN: r14322 - in labs/jbossesb/trunk/product: rosetta/src/org/jboss/internal/soa/esb/message and 13 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 16 14:46:43 EDT 2007
Author: tfennelly
Date: 2007-08-16 14:46:43 -0400 (Thu, 16 Aug 2007)
New Revision: 14322
Added:
labs/jbossesb/trunk/product/lib/ext/quartz-1.5.2.jar
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/LegacyMessageComposerAdapter.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/LocalFileMessageComposer.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/RemoteFileMessageComposer.java
Removed:
labs/jbossesb/trunk/product/lib/ext/quartz-1.6.0.jar
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/XAbstractFileGateway.java
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/Service.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListener.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListener.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/AbstractMessageComposer.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/MessageComposer.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduleProvider.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduledEventListener.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/MessageRouter.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/FileUtil.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/GroovyGatewayUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerIntegrationTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerIntegrationTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerUnitTest.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/README.TXT
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer2/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer2/test/SendEsbMessage.java
labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java
Log:
Some cleanup of the file based gateways + migrating them to use the ServiceInvoker
Added: labs/jbossesb/trunk/product/lib/ext/quartz-1.5.2.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/trunk/product/lib/ext/quartz-1.5.2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: labs/jbossesb/trunk/product/lib/ext/quartz-1.6.0.jar
===================================================================
(Binary files differ)
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/LegacyMessageComposerAdapter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/LegacyMessageComposerAdapter.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/LegacyMessageComposerAdapter.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.message;
+
+import org.jboss.soa.esb.listeners.message.MessageComposer;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.util.ClassUtil;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Legacy Message Composer adapter.
+ * <p/>
+ * The legacy code used a "reflection-only" model for the composers. We want
+ * all such code to implement the {@link MessageComposer} interface, but we also
+ * need to be backward compatible. This class forms an adapter layer around a
+ * legacy style composer class, making it look and feel like a {@link MessageComposer}
+ * implementation.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public abstract class LegacyMessageComposerAdapter implements MessageComposer {
+
+ protected Class _composerClass;
+
+ protected Object _composer;
+
+ protected Method _processMethod;
+
+ protected Method _responderMethod;
+
+ private ConfigTree config;
+
+ public void setConfiguration(ConfigTree config) throws ConfigurationException {
+ this.config = config;
+ resolveComposerClass();
+ }
+
+ public boolean hasResponder() {
+ return (_responderMethod != null);
+ }
+
+ public abstract Class[] getResponderParameters();
+
+ public Message compose(Object messagePayload) throws MessageDeliverException {
+ try {
+ return (Message) _processMethod.invoke(_composer, new Object[] {messagePayload});
+ } catch(ClassCastException e) {
+ throw new MessageDeliverException("Legacy composer class ('" + _composerClass.getName() + "') process method '" + _processMethod.getName() + "' must return an ESB Message (" + Message.class.getName() + ").");
+ } catch (IllegalAccessException e) {
+ throw new MessageDeliverException("Legacy composer class ('" + _composerClass.getName() + "') process method '" + _processMethod.getName() + "' is not callable.", e);
+ } catch (InvocationTargetException e) {
+ throw new MessageDeliverException("Legacy composer class ('" + _composerClass.getName() + "') process method '" + _processMethod.getName() + "' failed with exception.", e.getCause());
+ }
+ }
+
+ /**
+ * Lifted from the old AbstractFileGateway implementation that used reflection
+ * for composers.
+ *
+ * @throws ConfigurationException
+ */
+ private void resolveComposerClass() throws ConfigurationException {
+ String sProcessMethod = null;
+ String sResponderMethod = null;
+ String composerName = config.getRequiredAttribute(ListenerTagNames.GATEWAY_COMPOSER_CLASS_TAG);
+
+ try {
+ _composerClass = ClassUtil.forName(composerName, getClass());
+ } catch (ClassNotFoundException e) {
+ throw new ConfigurationException("Unable to locate composer class '" + composerName + "' on classpath.");
+ }
+
+ Constructor constructor;
+ try {
+ constructor = _composerClass.getConstructor(new Class[]{ConfigTree.class});
+ } catch (NoSuchMethodException e) {
+ throw new ConfigurationException("Unable to construct legacy style composer class '" + composerName + "'. Class must contain a constructor of the form '" + _composerClass.getSimpleName() + "(ConfigTree)'");
+ }
+ try {
+ _composer = constructor.newInstance(config);
+ } catch (Exception e) {
+ throw new ConfigurationException("Unable to construct legacy style composer class '" + composerName + "'.", e);
+ }
+ sProcessMethod = config.getAttribute(ListenerTagNames.GATEWAY_COMPOSER_METHOD_TAG, "process");
+ sResponderMethod = config.getAttribute(ListenerTagNames.GATEWAY_RESPONDER_METHOD_TAG, "respond");
+
+ try {
+ _processMethod = _composerClass.getMethod(sProcessMethod, new Class[]{Object.class});
+ } catch (NoSuchMethodException e) {
+ throw new ConfigurationException("Legacy style composer class '" + composerName + "' configuration is inavlid. Class should contain a method called '" + sProcessMethod + "', with a single Object arg.");
+ }
+
+ try {
+ // So the old stuff seemed to supported variable parameter lists on the responder method.
+ // Hard to tell for sure what the intent was because there's only 1 example!!
+ _responderMethod = _composerClass.getMethod(sResponderMethod, getResponderParameters());
+ } catch (NoSuchMethodException e) {
+ throw new ConfigurationException("Legacy style composer class '" + composerName + "' configuration is inavlid. Class should contain a valid '" + sResponderMethod + "' method.");
+ }
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/LegacyMessageComposerAdapter.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -153,8 +153,15 @@
ModulePropertyManager.TRANSPORTS_MODULE).getProperty(
Environment.FTP_LOCALDIR, tmpdir);
- m_bPassive = false;
+ File oLocalDir = new File(m_sLocalDir);
+ if(!oLocalDir.exists()) {
+ throw new ConfigurationException("Local FTP directory '" + oLocalDir.getAbsolutePath()
+ + "' doesn't exist. Check your JBossESB config '"
+ + ModulePropertyManager.TRANSPORTS_MODULE + ":" + Environment.FTP_LOCALDIR + "'");
+ }
+ m_bPassive = false;
+
try
{
m_bPassive = m_oEpr.getPassive();
@@ -297,8 +304,9 @@
throws IOException, RemoteFileSystemException
{
File oLocalDir = new File(m_sLocalDir);
- File oLclFile = File.createTempFile("Rosetta_", TMP_SUFFIX, oLocalDir);
+ File oLclFile = File.createTempFile("Rosetta_", TMP_SUFFIX, oLocalDir);
+
try
{
oLclFile.delete();
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/Service.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/Service.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/Service.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -22,6 +22,8 @@
import java.io.Serializable;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
/**
* Service.
@@ -81,4 +83,20 @@
public String toString() {
return category + ":" + name;
}
+
+ /**
+ * Construct a {@link Service} instance corresponding to the target Service
+ * for the supplied Gateway configuration.
+ *
+ * @param config Gateway configuration.
+ * @return Service instance corresponding to the target Service.
+ * @throws ConfigurationException One of the Target Service config attributes was not
+ * specified on the supplied configuration.
+ */
+ public static Service getGatewayTargetService(ConfigTree config) throws ConfigurationException {
+ String category = config.getRequiredAttribute(ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG);
+ String name = config.getRequiredAttribute(ListenerTagNames.TARGET_SERVICE_NAME_TAG);
+
+ return new Service(category, name);
+ }
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -107,7 +107,6 @@
* Public constructor.
*
* @param service The Service to which this instance will deliver messages.
- * @throws RegistryException Failed to lookup Service endpoint.
* @throws MessageDeliverException Failed to deliver message to endpoint.
*/
public ServiceInvoker(Service service) throws MessageDeliverException {
@@ -138,10 +137,9 @@
* deliver messages.
* @param serviceName The <b>name</b> of the Service to which this instance will
* deliver messages.
- * @throws RegistryException Failed to lookup Service endpoint.
* @throws MessageDeliverException Failed to deliver message to endpoint.
*/
- public ServiceInvoker(String serviceCategory, String serviceName) throws RegistryException, MessageDeliverException {
+ public ServiceInvoker(String serviceCategory, String serviceName) throws MessageDeliverException {
this(new Service(serviceCategory, serviceName));
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -24,75 +24,70 @@
import java.io.File;
import java.io.FileFilter;
-import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.MalformedEPRException;
-import org.jboss.soa.esb.addressing.util.DefaultReplyTo;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
+import org.jboss.soa.esb.schedule.ScheduledEventListener;
+import org.jboss.soa.esb.schedule.SchedulingException;
import org.jboss.soa.esb.common.Environment;
-import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierException;
-import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.couriers.CourierTimeoutException;
-import org.jboss.soa.esb.couriers.CourierUtil;
-import org.jboss.soa.esb.couriers.TwoWayCourier;
import org.jboss.soa.esb.filter.FilterManager;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.ListenerTagNames;
import org.jboss.soa.esb.listeners.ListenerUtil;
-import org.jboss.soa.esb.listeners.RegistryUtil;
-import org.jboss.soa.esb.listeners.lifecycle.AbstractThreadedManagedLifecycle;
-import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
-import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleThreadState;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.listeners.message.MessageComposer;
+import org.jboss.soa.esb.listeners.lifecycle.*;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
-import org.jboss.soa.esb.util.ClassUtil;
-import org.jboss.soa.esb.util.Util;
+import org.jboss.internal.soa.esb.message.LegacyMessageComposerAdapter;
/**
* Base class for all file gateways: local filesystem, ftp, sftp and ftps.
* <p/>Implementations for file manipulation (getFileList, getFileContents,
* renameFile and deleteFile) must be provided by factory
*
- * @author <a
- * href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
* @since Version 4.0
*/
-public abstract class AbstractFileGateway extends
- AbstractThreadedManagedLifecycle {
- abstract File[] getFileList() throws GatewayException;
+public abstract class AbstractFileGateway extends AbstractManagedLifecycle implements ScheduledEventListener {
- abstract byte[] getFileContents(File file) throws GatewayException;
+ protected final static Logger _logger = Logger
+ .getLogger(AbstractFileGateway.class);
- abstract boolean renameFile(File from, File to) throws GatewayException;
+ protected ConfigTree config;
- abstract boolean deleteFile(File file) throws GatewayException;
+ protected long _maxMillisForResponse;
- abstract void seeIfOkToWorkOnDir(File p_oDir) throws GatewayException;
+ protected Service targetService;
- abstract void getDefaultComposer() throws GatewayException;
+ protected ServiceInvoker serviceInvoker;
- abstract void bytesToFile(byte[] bytes, File file) throws GatewayException;
+ protected MessageComposer messageComposer;
- protected AbstractFileGateway(ConfigTree config)
- throws ConfigurationException, RegistryException, GatewayException {
+ protected boolean _deleteAfterOK;
+
+ protected File _inputDirectory, _errorDirectory, _postProcessDirectory;
+
+ protected String _inputSuffix, _postProcessSuffix, _workingSuffix,
+ _errorSuffix;
+
+ protected FileFilter _fileFilter;
+
+ protected AbstractFileGateway(ConfigTree config) throws ConfigurationException, RegistryException, GatewayException {
super(config);
- _config = config;
- _sleepBetweenPolls = 10000; // milliseconds
+ this.config = config;
checkMyParms();
- } // __________________________________
+ }
/**
* Handle the initialisation of the managed instance.
@@ -101,245 +96,168 @@
*/
protected void doInitialise() throws ManagedLifecycleException {
try {
- _targetEprs = RegistryUtil.getEprs(_targetServiceCategory,
- _targetServiceName);
- if (null == _targetEprs || _targetEprs.size() < 1)
- throw new ManagedLifecycleException("EPR <"
- + _targetServiceName + "> not found in registry");
+ serviceInvoker = new ServiceInvoker(targetService);
+ } catch (MessageDeliverException e) {
+ throw new ManagedLifecycleException(e);
}
- catch (ServiceNotFoundException snfe) {
- throw new ManagedLifecycleException("EPR <" + _targetServiceCategory + " "
- + _targetServiceName + "> not found in registry");
- }
- catch (final RegistryException re) {
- throw new ManagedLifecycleException(
- "Unexpected registry exception", re);
- }
}
+ protected void doStart() throws ManagedLifecycleException {
+ }
+
+ protected void doStop() throws ManagedLifecycleException {
+ }
+
+ protected void doDestroy() throws ManagedLifecycleException {
+ }
+
/**
- * Execute on the thread.
+ * Execute on trigger from the scheduler.
*/
- protected void doRun() {
+ public void onSchedule() throws SchedulingException {
- EPR replyEpr = null;
- Message replyMsg = null;
-
- if (_logger.isDebugEnabled()) {
- _logger.debug("run() method of " + this.getClass().getSimpleName()
- + " started on thread " + Thread.currentThread().getName());
+ File[] fileList;
+ try {
+ fileList = getFileList();
}
+ catch (GatewayException e) {
+ _logger.error("Can't retrieve file list", e);
+ return;
+ }
- do {
- File[] fileList;
- try {
- fileList = getFileList();
+ for (File fileIn : fileList) {
+
+ // Only continue to process files if we're in a STARTED state...
+ if(getState() != ManagedLifecycleState.STARTED) {
+ break;
}
- catch (GatewayException e) {
- _logger.error("Can't retrieve file list", e);
+
+ // Set the file working. If that fails, move to the next file...
+ File workingFile = setFileWorking(fileIn);
+ if (workingFile == null) {
continue;
}
- for (File fileIn : fileList) {
- // Try to rename - if unsuccessful, somebody else got it first
- File fileWork = getWorkFileName(fileIn, _workingSuffix);
+ try {
+ Message message;
+
try {
- if (!renameFile(fileIn, fileWork))
- continue;
+ message = messageComposer.compose(workingFile);
+ } catch (MessageDeliverException e) {
+ processException("Composer <" + messageComposer.getClass().getName() + "> Failed.", e, fileIn, workingFile);
+ continue;
}
- catch (GatewayException e) {
- _logger.error("Problems renaming file " + fileIn + " to "
- + fileWork);
+ if (message == null) {
+ _logger.warn("Composer <" + messageComposer.getClass().getName() + "> returned a null object");
continue;
}
- Throwable thrown = null;
- String text = null;
- try {
- Object obj = _processMethod.invoke(_composer, new Object[]
- {fileWork});
- if (null == obj) {
- _logger.warn("Action class method <"
- + _processMethod.getName()
- + "> returned a null object");
- continue;
- }
- boolean bSent = false;
+ Map<String, Object> params = new HashMap<String, Object>();
- Message outMessage = (Message) obj;
- Map<String, Object> params = new HashMap<String, Object>();
+ params.put(Environment.ORIGINAL_FILE, fileIn);
+ params.put(Environment.GATEWAY_CONFIG, config);
- params.put(Environment.ORIGINAL_FILE, fileIn);
- params.put(Environment.GATEWAY_CONFIG, _config);
-
- outMessage = FilterManager.getInstance().doOutputWork(outMessage, params);
-
- for (EPR current : _targetEprs) {
- _courier = getCourier(current);
+ message = FilterManager.getInstance().doOutputWork(message, params);
+ try {
+ if (_maxMillisForResponse > 0) {
+ Message replyMsg = serviceInvoker.deliverSync(message, _maxMillisForResponse);
+ replyMsg.getAttachment().put(Environment.ORIGINAL_FILE, fileIn);
try {
- replyEpr = null;
- outMessage.getHeader().getCall().setTo(current);
- if (_maxMillisForResponse > 0) {
- replyEpr = DefaultReplyTo
- .getReplyTo(current);
- outMessage.getHeader().getCall().setReplyTo(
- replyEpr);
- }
- if (_courier.deliver(outMessage)) {
- bSent = true;
- break;
- }
+ processReply(replyMsg);
+ } catch (GatewayException e) {
+ processException("Failed to process reply.", e, fileIn, workingFile);
+ continue;
}
- finally {
- CourierUtil.cleanCourier(_courier);
- }
-
+ } else {
+ serviceInvoker.deliverAsync(message);
}
- if (!bSent) {
- text = "Target service <" + _targetServiceCategory
- + "," + _targetServiceName
- + "> is not registered";
- thrown = new Exception(text);
- } else if (null != replyEpr) {
- TwoWayCourier replyCourier = CourierFactory
- .getPickupCourier(replyEpr);
- try {
- replyMsg = replyCourier
- .pickup(_maxMillisForResponse);
- _responderMethod.invoke(_composer, new Object[]
- {replyMsg, fileIn});
- }
- catch (CourierTimeoutException e) {
- thrown = e;
- text = "Expected response was not received from invoked service";
- replyMsg = MessageFactory.getInstance()
- .getMessage();
- String timedOut = "Service <"
- + _targetServiceCategory + ","
- + "_targetServiceName"
- + "> timed out without sending response";
- replyMsg.getBody()
- .setByteArray(timedOut.getBytes());
- _responderMethod.invoke(_composer, new Object[]
- {replyMsg, fileIn});
- }
- finally {
- if (null != replyCourier)
- CourierUtil.cleanCourier(replyCourier);
- }
- }
+ } catch (MessageDeliverException e) {
+ processException("Message Delivery Failure.", e, fileIn, workingFile);
+ continue;
+ } catch (RegistryException e) {
+ processException("Message Delivery Failure.", e, fileIn, workingFile);
+ continue;
}
- catch (InvocationTargetException e) {
- thrown = e;
- text = "Problems invoking method <"
- + _processMethod.getName() + ">";
+ } catch (CourierException e) {
+ processException("Message Delivery Failure.", e, fileIn, workingFile);
+ continue;
+ }
- }
- catch (IllegalAccessException e) {
- thrown = e;
- text = "Problems invoking method <"
- + _processMethod.getName() + ">";
- }
- catch (ClassCastException e) {
- thrown = e;
- text = "Action class method <" + _processMethod.getName()
- + "> returned a non Message object";
- }
- catch (CourierException e) {
- thrown = e;
- if (null != _courier)
- text = "Courier <" + _courier.getClass().getName()
- + ".deliverAsync(Message) FAILED";
- else
- text = "NULL courier can't deliverAsync Message";
- }
- catch (MalformedEPRException e) {
- thrown = e;
- if (null != _courier)
- text = "Courier <"
- + _courier.getClass().getName()
- + ".deliverAsync(Message) FAILED with malformed EPR.";
- else
- text = "NULL courier can't deliverAsync Message";
- }
+ // The message has been successfully processed...
+ processingComplete(fileIn, workingFile);
+ }
+ }
- if (null == thrown) {
- File fileOK = new File(_postProcessDirectory, fileIn
- .getName()
- + _postProcessSuffix);
- if (_deleteAfterOK) {
- try {
- deleteFile(fileWork);
- }
- catch (GatewayException e) {
- _logger
- .error(
- "File "
- + fileIn
- + " has been processed and renamed to "
- + fileWork
- + ", but there were problems deleting it from the input directory ",
- e);
- }
- } else {
- try {
- renameFile(fileWork, fileOK);
- }
- catch (GatewayException e) {
- _logger
- .error(
- "File "
- + fileIn
- + " has been processed and renamed to "
- + fileWork
- + ", but there were problems renaming it to "
- + fileOK, e);
- }
- }
- } else {
- thrown.printStackTrace();
- _logger.error(text, thrown);
- File fileError = new File(_errorDirectory, fileIn.getName()
- + _errorSuffix);
- try {
- deleteFile(fileError);
- }
- catch (GatewayException e) {
- _logger.warn("File : " + fileError + " did not exist.");
- }
- try {
- renameFile(fileWork, fileError);
- }
- catch (GatewayException e) {
- _logger.error("Problems renaming file " + fileWork
- + " to " + fileError, e);
- }
- }
+ private void processingComplete(File fileIn, File workingFile) {
+ File fileOK = new File(_postProcessDirectory, fileIn.getName() + _postProcessSuffix);
+ if (_deleteAfterOK) {
+ try {
+ deleteFile(workingFile);
}
+ catch (GatewayException e) {
+ _logger.error("File "+ fileIn + " has been processed and renamed to " + workingFile
+ + ", but there were problems deleting it from the input directory ", e);
+ }
+ } else {
+ try {
+ renameFile(workingFile, fileOK);
+ }
+ catch (GatewayException e) {
+ _logger.error("File " + fileIn + " has been processed and renamed to " + workingFile
+ + ", but there were problems renaming it to " + fileOK, e);
+ }
}
- while (!waitForRunningStateChange(ManagedLifecycleThreadState.STOPPING,
- _sleepBetweenPolls));
+ }
- if (_logger.isDebugEnabled()) {
- _logger
- .debug("run() method of " + this.getClass().getSimpleName()
- + " finished on thread "
- + Thread.currentThread().getName());
+ private void processException(String message, Throwable thrown, File fileIn, File workingFile) {
+ _logger.error(message, thrown);
+ File fileError = new File(_errorDirectory, fileIn.getName() + _errorSuffix);
+
+ try {
+ deleteFile(fileError);
+ } catch (GatewayException e) {
+ _logger.warn("File : " + fileError + " did not exist.");
}
- } // ________________________________
+ try {
+ renameFile(workingFile, fileError);
+ }catch (GatewayException e) {
+ _logger.error("Problems renaming file " + workingFile + " to " + fileError, e);
+ }
+ }
- protected File getWorkFileName(File fileIn, String suffix) {
- return new File(fileIn.toString() + _workingSuffix);
+ private void processReply(Message replyMsg) throws MessageDeliverException, GatewayException {
+ Object responseData = messageComposer.decompose(replyMsg);
+
+ if(responseData == null) {
+ // Legacy composers may handled response delivery themselves...
+ } else if(responseData instanceof byte[]) {
+ File inputFile = (File) replyMsg.getAttachment().get(Environment.ORIGINAL_FILE);
+ File responseFile = new File(inputFile.getParent(), inputFile.getName() + FileEpr.DEFAULT_REPLY_TO_FILE_SUFFIX + "_gw");
+
+ bytesToFile((byte[])responseData, responseFile);
+ } else {
+ _logger.error("File based composers must return a byte[] from their decompose implementations.");
+ }
}
- /*
- * Extracted to simplify testing
- */
- protected Courier getCourier(EPR current) throws CourierException,
- MalformedEPRException {
- return CourierFactory.getCourier(current);
+ private File setFileWorking(File file) {
+ File workingFile = getWorkFileName(file, _workingSuffix);
+
+ try {
+ if (!renameFile(file, workingFile)) {
+ return null;
+ }
+ } catch (GatewayException e) {
+ _logger.error("Problems renaming file " + file + " to " + workingFile);
+ }
+
+ return workingFile;
}
+ protected File getWorkFileName(File fileIn, String suffix) {
+ return new File(fileIn.toString() + _workingSuffix);
+ }
+
/**
* Handle the threaded destroy of the managed instance.
*
@@ -361,212 +279,149 @@
/**
* Check for mandatory and optional attributes in parameter tree
*
- * @throws ConfigurationException -
- * if mandatory atts are not right or actionClass not in
- * classpath
+ * @throws ConfigurationException Mandatory atts are not right or actionClass not in classpath.
*/
- private void checkMyParms() throws ConfigurationException,
- RegistryException, GatewayException {
- // Third arg is null - Exception will be thrown if attribute is not
- // found
- _targetServiceCategory = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG, null);
- _targetServiceName = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.TARGET_SERVICE_NAME_TAG, null);
+ private void checkMyParms() throws ConfigurationException {
- // Polling interval
- String sAux = _config
- .getAttribute(ListenerTagNames.POLL_LATENCY_SECS_TAG);
+ targetService = Service.getGatewayTargetService(config);
- if (!Util.isNullString(sAux)) {
- try {
- _sleepBetweenPolls = 1000 * Long.parseLong(sAux);
- }
- catch (NumberFormatException e) {
- _logger.warn("Invalid poll latency - keeping default of "
- + (_sleepBetweenPolls / 1000));
- }
- } else {
- _logger.warn("No value specified for: "
- + ListenerTagNames.POLL_LATENCY_SECS_TAG
- + " - Using default of " + (_sleepBetweenPolls / 1000));
+ String composerClass = config.getAttribute(ListenerTagNames.GATEWAY_COMPOSER_CLASS_TAG);
+ if(composerClass == null) {
+ composerClass = getDefaultComposer();
}
+ messageComposer = MessageComposer.Factory.getInstance(composerClass, config, LegacyFileMessageComposerAdapter.class);
- resolveComposerClass();
+ boolean hasResponder = false;
+ if(messageComposer instanceof LegacyMessageComposerAdapter) {
+ // Backward compatibility :-(
+ hasResponder = ((LegacyMessageComposerAdapter)messageComposer).hasResponder();
+ }
+ _maxMillisForResponse = ListenerUtil.getMaxMillisGatewayWait(config, _logger, hasResponder);
- boolean hasResponder = _responderMethod != null;
- _maxMillisForResponse = ListenerUtil.getMaxMillisGatewayWait(_config,
- _logger, hasResponder);
- try {
- // INPUT directory and suffix (used for FileFilter)
- String url = _config.getAttribute(ListenerTagNames.URL_TAG);
- String sInpDir = (null != url) ? new URL(url).getFile()
- : ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_INPUT_DIR_TAG, null);
- _inputDirectory = fileFromString(sInpDir);
- seeIfOkToWorkOnDir(_inputDirectory);
+ String sInpDir = getInputDir(config);
- _inputSuffix = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_INPUT_SFX_TAG, null);
- _inputSuffix = _inputSuffix.trim();
+ _inputDirectory = fileFromString(sInpDir);
+ seeIfOkToWorkOnDir(_inputDirectory);
- checkInputSuffix();
+ _inputSuffix = config.getRequiredAttribute(ListenerTagNames.FILE_INPUT_SFX_TAG).trim();
+ checkInputSuffix();
- // WORK suffix (will rename in input directory)
- _workingSuffix = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_WORK_SFX_TAG, ".esbWork").trim();
- if (_workingSuffix.length() < 1)
- throw new ConfigurationException("Invalid "
- + ListenerTagNames.FILE_WORK_SFX_TAG + " attribute");
+ // WORK suffix (will rename in input directory)
+ _workingSuffix = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_WORK_SFX_TAG, ".esbWork").trim();
+ if (_workingSuffix.length() < 1) {
+ throw new ConfigurationException("Invalid "+ ListenerTagNames.FILE_WORK_SFX_TAG + " attribute");
+ }
- if (_inputSuffix.equals(_workingSuffix))
- throw new ConfigurationException(
- "Work suffix must differ from input suffix <"
- + _workingSuffix + ">");
+ if (_inputSuffix.equals(_workingSuffix)) {
+ throw new ConfigurationException("Work suffix must differ from input suffix <" + _workingSuffix + ">");
+ }
- // ERROR directory and suffix (defaults to input dir and
- // ".esbError"
- // suffix)
- String sErrDir = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_ERROR_DIR_TAG, sInpDir);
- _errorDirectory = fileFromString(sErrDir);
- seeIfOkToWorkOnDir(_errorDirectory);
+ // ERROR directory and suffix (defaults to input dir and
+ // ".esbError"
+ // suffix)
+ String sErrDir = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_ERROR_DIR_TAG, sInpDir);
+ _errorDirectory = fileFromString(sErrDir);
+ seeIfOkToWorkOnDir(_errorDirectory);
- _errorSuffix = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_ERROR_SFX_TAG, ".esbError").trim();
- if (_errorSuffix.length() < 1)
- throw new ConfigurationException("Invalid "
- + ListenerTagNames.FILE_ERROR_SFX_TAG + " attribute");
- if (_errorDirectory.equals(_inputDirectory)
- && _inputSuffix.equals(_errorSuffix))
- throw new ConfigurationException(
- "Error suffix must differ from input suffix <"
- + _errorSuffix + ">");
+ _errorSuffix = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_ERROR_SFX_TAG, ".esbError").trim();
+ if (_errorSuffix.length() < 1) {
+ throw new ConfigurationException("Invalid " + ListenerTagNames.FILE_ERROR_SFX_TAG + " attribute");
+ }
+ if (_errorDirectory.equals(_inputDirectory) && _inputSuffix.equals(_errorSuffix)) {
+ throw new ConfigurationException("Error suffix must differ from input suffix <" + _errorSuffix + ">");
+ }
- // Do users wish to delete files that were processed OK ?
- String sPostDel = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_POST_DEL_TAG, "false").trim();
- _deleteAfterOK = Boolean.parseBoolean(sPostDel);
- if (_deleteAfterOK)
- return;
+ // Do users wish to delete files that were processed OK ?
+ String sPostDel = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_POST_DEL_TAG, "false").trim();
+ _deleteAfterOK = Boolean.parseBoolean(sPostDel);
+ if (_deleteAfterOK) {
+ return;
+ }
- // POST (done) directory and suffix (defaults to input dir and
- // ".esbDone" suffix)
- String sPostDir = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_POST_DIR_TAG, sInpDir);
- _postProcessDirectory = fileFromString(sPostDir);
- seeIfOkToWorkOnDir(_postProcessDirectory);
- _postProcessSuffix = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_POST_SFX_TAG, ".esbDone").trim();
+ // POST (done) directory and suffix (defaults to input dir and
+ // ".esbDone" suffix)
+ String sPostDir = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_POST_DIR_TAG, sInpDir);
+ _postProcessDirectory = fileFromString(sPostDir);
+ seeIfOkToWorkOnDir(_postProcessDirectory);
+ _postProcessSuffix = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_POST_SFX_TAG, ".esbDone").trim();
- if (_postProcessDirectory.equals(_inputDirectory)) {
- if (_postProcessSuffix.length() < 1)
- throw new ConfigurationException("Invalid "
- + ListenerTagNames.FILE_POST_SFX_TAG + " attribute");
- if (_postProcessSuffix.equals(_inputSuffix))
- throw new ConfigurationException(
- "Post process suffix must differ from input suffix <"
- + _postProcessSuffix + ">");
+ if (_postProcessDirectory.equals(_inputDirectory)) {
+ if (_postProcessSuffix.length() < 1) {
+ throw new ConfigurationException("Invalid " + ListenerTagNames.FILE_POST_SFX_TAG + " attribute");
}
+ if (_postProcessSuffix.equals(_inputSuffix)) {
+ throw new ConfigurationException("Post process suffix must differ from input suffix <" + _postProcessSuffix + ">");
+ }
}
- catch (GatewayException ex) {
- throw ex;
- }
- catch (MalformedURLException ex) {
- throw new ConfigurationException(ex);
- }
- } // ________________________________
+ }
- protected void resolveComposerClass() throws ConfigurationException,
- GatewayException {
- String sProcessMethod = null;
- String sResponderMethod = null;
- try {
- _composerName = _config
- .getAttribute(ListenerTagNames.GATEWAY_COMPOSER_CLASS_TAG);
- if (null != _composerName) { // class attribute
- _composerClass = ClassUtil.forName(_composerName, getClass());
- Constructor oConst = _composerClass.getConstructor(new Class[]
- {ConfigTree.class});
- _composer = oConst.newInstance(_config);
- sProcessMethod = _config
- .getAttribute(
- ListenerTagNames.GATEWAY_COMPOSER_METHOD_TAG,
- "process");
- sResponderMethod = _config
- .getAttribute(ListenerTagNames.GATEWAY_RESPONDER_METHOD_TAG);
- } else {
- getDefaultComposer();
- sProcessMethod = "process";
- sResponderMethod = "respond";
- }
+ public static File getFileInputDirectory(ConfigTree config) throws ConfigurationException {
+ String sInpDir = getInputDir(config);
+ return fileFromString(sInpDir);
+ }
- _processMethod = _composerClass.getMethod(sProcessMethod,
- new Class[]
- {Object.class});
+ private static String getInputDir(ConfigTree config) throws ConfigurationException {
+ String url = config.getAttribute(ListenerTagNames.URL_TAG);
- _responderMethod = (null == sResponderMethod) ? null
- : _composerClass.getMethod(sResponderMethod, new Class[]
- {Message.class, File.class});
+ if(url != null) {
+ try {
+ return new URL(url).getFile();
+ } catch (MalformedURLException e) {
+ throw new ConfigurationException("Invalid '" + ListenerTagNames.URL_TAG + "' value '" + url + "'. Must be a valid URI.");
+ }
}
- catch (InvocationTargetException ex) {
- throw new ConfigurationException(ex);
- }
- catch (IllegalAccessException ex) {
- throw new ConfigurationException(ex);
- }
- catch (InstantiationException ex) {
- throw new ConfigurationException(ex);
- }
- catch (NoSuchMethodException ex) {
- throw new ConfigurationException(ex);
- }
- catch (ClassNotFoundException ex) {
- throw new ConfigurationException(ex);
- }
- } // ________________________________
- private File fileFromString(String file) {
+ return config.getRequiredAttribute(ListenerTagNames.FILE_INPUT_DIR_TAG);
+ }
+
+ private static File fileFromString(String file) {
try {
return new File(new URI(file));
}
catch (Exception e) {
return new File(file);
}
- } // ________________________________
+ }
- protected final static Logger _logger = Logger
- .getLogger(AbstractFileGateway.class);
+ abstract File[] getFileList() throws GatewayException;
- protected ConfigTree _config;
+ abstract byte[] getFileContents(File file) throws GatewayException;
- protected long _sleepBetweenPolls; // milliseconds
+ abstract boolean renameFile(File from, File to) throws GatewayException;
- protected long _maxMillisForResponse;
+ abstract boolean deleteFile(File file) throws GatewayException;
- protected String _targetServiceCategory, _targetServiceName;
+ abstract void seeIfOkToWorkOnDir(File p_oDir) throws ConfigurationException;
- protected Collection<EPR> _targetEprs;
+ abstract String getDefaultComposer() throws ConfigurationException;
- protected String _composerName;
+ abstract void bytesToFile(byte[] bytes, File file) throws GatewayException;
- protected Class _composerClass;
+ /**
+ * Legacy Message composer adapter for the file based gateways.
+ * <p/>
+ * The old AbstractFileGateway used to leave it to the composer to handle the
+ * response. It also used to supply the composer with the input file and leave
+ * it to the composer to determine the name of the output file.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+ private class LegacyFileMessageComposerAdapter extends LegacyMessageComposerAdapter {
- protected Object _composer;
+ public Object decompose(Message message) throws MessageDeliverException {
+ // This is all done this way for backward compatibility!!!!
+ File inputFile = (File) message.getAttachment().get(Environment.ORIGINAL_FILE);
+ try {
+ return _responderMethod.invoke(_composer, message, inputFile);
+ } catch (IllegalAccessException e) {
+ throw new MessageDeliverException("Legacy composer class ('" + _composerClass.getName() + "') responder method '" + _responderMethod.getName() + "' is not callable.", e);
+ } catch (InvocationTargetException e) {
+ throw new MessageDeliverException("Legacy composer class ('" + _composerClass.getName() + "') responder method '" + _responderMethod.getName() + "' failed with exception.", e.getCause());
+ }
+ }
- protected Method _processMethod;
-
- protected Method _responderMethod;
-
- protected Courier _courier;
-
- protected boolean _deleteAfterOK;
-
- protected File _inputDirectory, _errorDirectory, _postProcessDirectory;
-
- protected String _inputSuffix, _postProcessSuffix, _workingSuffix,
- _errorSuffix;
-
- protected FileFilter _fileFilter;
-
-} // ____________________________________________________________________________
+ public Class[] getResponderParameters() {
+ return new Class[]{Message.class, File.class};
+ }
+ }
+}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListener.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListener.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -30,16 +30,12 @@
import java.io.IOException;
import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.eprs.FileEpr;
import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.util.FileUtil;
import org.jboss.soa.esb.util.Util;
-public class FileGatewayListener extends XAbstractFileGateway {
+public class FileGatewayListener extends AbstractFileGateway {
/**
* serial version uid for this class
*/
@@ -75,19 +71,15 @@
}
@Override
- protected void seeIfOkToWorkOnDir(File p_oDir) throws GatewayException {
+ protected void seeIfOkToWorkOnDir(File p_oDir) throws ConfigurationException {
if (!p_oDir.exists())
- throw new GatewayException("Directory " + p_oDir.toString()
- + " not found");
+ throw new ConfigurationException("Directory " + p_oDir.toString() + " not found");
if (!p_oDir.isDirectory())
- throw new GatewayException(p_oDir.toString()
- + " is not a directory");
+ throw new ConfigurationException(p_oDir.toString() + " is not a directory");
if (!p_oDir.canRead())
- throw new GatewayException("Can't read directory "
- + p_oDir.toString());
+ throw new ConfigurationException("Can't read directory " + p_oDir.toString());
if (!p_oDir.canWrite())
- throw new GatewayException("Can't write/rename in directory "
- + p_oDir.toString());
+ throw new ConfigurationException("Can't write/rename in directory " + p_oDir.toString());
} // ________________________________
@Override
@@ -150,13 +142,8 @@
}
@Override
- void getDefaultComposer() throws GatewayException {
- _composerName = PackageFileContents.class.getName();
- _composerClass = PackageFileContents.class;
- _composer = new PackageFileContents();
- _logger.debug("No <" + ListenerTagNames.ACTION_ELEMENT_TAG
- + "> element found in gateway configuration"
- + " - Using default composer class : " + _composerName);
+ String getDefaultComposer() {
+ return LocalFileMessageComposer.class.getName();
}
@Override
@@ -173,38 +160,7 @@
}
}
- // ______________________________________________________________________________
/**
- * Default gateway action for files <p/>It will just drop the file contents
- * into a Message
- *
- * @author <a
- * href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- * @since Version 4.0
- */
- public class PackageFileContents {
- public Message process(Object obj) throws ConfigurationException, GatewayException {
- if (!(obj instanceof File))
- throw new ConfigurationException("Object must be instance of File");
-
- Message message = MessageFactory.getInstance().getMessage();
- message.getBody().setByteArray(getFileContent((File) obj));
- return message;
- }
-
- private byte[] getFileContent(File file) throws ConfigurationException, GatewayException {
- return getFileContents(file);
- }
-
- public void respond(Message msg, File file) throws Exception {
- File responseFile = new File(file.getParent(), file.getName()
- + FileEpr.DEFAULT_REPLY_TO_FILE_SUFFIX + "_gw");
- bytesToFile(msg.getBody().getByteArray(), responseFile);
- }
-
- } // ____________________________________________________
-
- /**
* This implementation allows no input suffix, whereas the base class
* requires an input suffix.
*/
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/LocalFileMessageComposer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/LocalFileMessageComposer.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/LocalFileMessageComposer.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.gateway;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.util.FileUtil;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.MessageComposer;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Local File Message Composer.
+ *
+ * @see org.jboss.soa.esb.listeners.gateway.RemoteFileMessageComposer
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class LocalFileMessageComposer implements MessageComposer {
+
+ public void setConfiguration(ConfigTree config) throws ConfigurationException {
+ }
+
+ public Message compose(Object messagePayload) throws MessageDeliverException {
+ AssertArgument.isNotNull(messagePayload, "messagePayload");
+
+ if(!(messagePayload instanceof File)) {
+ throw new MessageDeliverException("Invalid payload type '" + messagePayload.getClass().getName() + "'. Must be a " + File.class.getName() + " based payload.");
+ }
+
+ File inputFile = (File)messagePayload;
+ if(!inputFile.exists()) {
+ throw new MessageDeliverException("Invalid File payload. File '" + inputFile.getAbsolutePath() + "' doesn't exist.");
+ }
+
+ Message message = MessageFactory.getInstance().getMessage();
+ try {
+ message.getBody().setByteArray(FileUtil.readFile(inputFile));
+ } catch (IOException e) {
+ throw new MessageDeliverException("Error reading input file '" + inputFile.getAbsolutePath() + "'.", e);
+ }
+
+ return message;
+ }
+
+ public Object decompose(Message message) throws MessageDeliverException {
+ byte[] payload = message.getBody().getByteArray();
+
+ if(payload == null) {
+ throw new MessageDeliverException("No byte[] payload returned by 'Message.getBody().getByteArray()'.");
+ }
+
+ return payload;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/LocalFileMessageComposer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListener.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListener.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -31,6 +31,7 @@
import org.jboss.soa.esb.listeners.gateway.remotestrategies.RemoteFileSystemStrategyException;
import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.DeleteOnEvictTreeCacheListener;
import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.util.ClassUtil;
@@ -191,7 +192,7 @@
private void createRemoteFileSystemStrategy() throws ConfigurationException
{
- String strategyClassName = _config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CLASS );
+ String strategyClassName = config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CLASS );
RemoteFileSystemStrategy strategy = null;
if ( strategyClassName != null )
@@ -199,7 +200,7 @@
remotefileSystemStrategy = strategy != null ? strategy : new ReadOnlyRemoteFileSystemStrategy();
- String configFile = _config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE );
+ String configFile = config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE );
try
{
remotefileSystemStrategy.init( configFile );
@@ -207,7 +208,7 @@
if ( remotefileSystemStrategy instanceof ReadOnlyRemoteFileSystemStrategy )
{
ReadOnlyRemoteFileSystemStrategy rm = (ReadOnlyRemoteFileSystemStrategy) remotefileSystemStrategy;
- String cacheListener = _config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CACHE_LISTENER );
+ String cacheListener = config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CACHE_LISTENER );
if ( cacheListener != null )
{
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/RemoteFileMessageComposer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/RemoteFileMessageComposer.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/RemoteFileMessageComposer.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.gateway;
+
+import org.jboss.soa.esb.listeners.message.MessageComposer;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.listeners.ListenerUtil;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.util.*;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.apache.log4j.Logger;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Remote File Message Composer.
+ * <p/>
+ * The logic in this class was lifeted from {@link RemoteGatewayListener}.
+ *
+ * @see org.jboss.soa.esb.listeners.gateway.LocalFileMessageComposer
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class RemoteFileMessageComposer implements MessageComposer {
+
+ private static Logger logger = Logger.getLogger(RemoteFileMessageComposer.class);
+
+ private FTPEpr ftpEpr;
+ private File downloadDir;
+
+ public void setConfiguration(ConfigTree config) throws ConfigurationException {
+ EPR epr = ListenerUtil.assembleEpr(config);
+
+ if (!(epr instanceof FTPEpr)) {
+ throw new ConfigurationException("This Gateway only accepts FTP and SFTP.");
+ }
+ ftpEpr = (FTPEpr) epr;
+ // This may look a bit odd... The "file" input dir is our FTP download dir...
+ downloadDir = AbstractFileGateway.getFileInputDirectory(config);
+ }
+
+ public Message compose(Object messagePayload) throws MessageDeliverException {
+ AssertArgument.isNotNull(messagePayload, "messagePayload");
+
+ if(!(messagePayload instanceof File)) {
+ throw new MessageDeliverException("Invalid payload type '" + messagePayload.getClass().getName() + "'. Must be a " + File.class.getName() + " based payload.");
+ }
+
+ File inputFile = (File)messagePayload;
+
+ Message message = MessageFactory.getInstance().getMessage();
+ try {
+ message.getBody().setByteArray(getFileContents(inputFile));
+ } catch (IOException e) {
+ throw new MessageDeliverException("Error reading remote input file '" + inputFile.getAbsolutePath() + "'.", e);
+ } catch (RemoteFileSystemException e) {
+ throw new MessageDeliverException("Error reading remote input file '" + inputFile.getAbsolutePath() + "'.", e);
+ }
+
+ return message;
+ }
+
+ public Object decompose(Message message) throws MessageDeliverException {
+ byte[] payload = message.getBody().getByteArray();
+
+ if(payload == null) {
+ throw new MessageDeliverException("No byte[] payload returned by 'Message.getBody().getByteArray()'.");
+ }
+
+ return payload;
+ }
+
+ private byte[] getFileContents(File file) throws IOException, RemoteFileSystemException {
+ RemoteFileSystem remoteFileSystem = null;
+ File temp = File.createTempFile("FTPdown", ".tmp");
+
+ try
+ {
+ remoteFileSystem = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
+ remoteFileSystem.setRemoteDir(FtpClientUtil.fileToFtpString(downloadDir));
+ remoteFileSystem.downloadFile(file.toString(), temp.getAbsolutePath());
+
+ return FileUtil.readFile(temp);
+ } finally {
+ temp.delete();
+ if (null != remoteFileSystem) {
+ remoteFileSystem.quit();
+ }
+ }
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/RemoteFileMessageComposer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -73,10 +73,10 @@
String localDir = temp.getParent();
if (null==localDir)
localDir=new File("").getAbsolutePath();
- _config.setAttribute(RemoteFileSystem.PARMS_LOCAL_DIR, localDir);
- final String remoteDir = _config.getAttribute(ListenerTagNames.FILE_INPUT_DIR_TAG) ;
- _config.setAttribute(RemoteFileSystem.PARMS_REMOTE_DIR, remoteDir);
- EPR epr = ListenerUtil.assembleEpr(_config);
+ config.setAttribute(RemoteFileSystem.PARMS_LOCAL_DIR, localDir);
+ final String remoteDir = config.getAttribute(ListenerTagNames.FILE_INPUT_DIR_TAG) ;
+ config.setAttribute(RemoteFileSystem.PARMS_REMOTE_DIR, remoteDir);
+ EPR epr = ListenerUtil.assembleEpr(config);
if (epr instanceof FTPEpr) {
FTPEpr ftpEpr = (FTPEpr) epr;
RemoteFileSystem rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
@@ -97,8 +97,7 @@
}
@Override
- protected void seeIfOkToWorkOnDir(File p_oDir) throws GatewayException
- {
+ protected void seeIfOkToWorkOnDir(File p_oDir) {
// TODO: Implement. Very expensive though.
// It is possible to check for existence and permission by connecting,
// cd to target, put dummy file, ls to see list it, rm to clean it
@@ -113,7 +112,7 @@
RemoteFileSystem rfs = null;
try
{
- EPR epr = ListenerUtil.assembleEpr(_config);
+ EPR epr = ListenerUtil.assembleEpr(config);
if (epr instanceof FTPEpr) {
FTPEpr ftpEpr = (FTPEpr) epr;
rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
@@ -134,14 +133,14 @@
}
}
- @Override
+ @Override
byte[] getFileContents(File file) throws GatewayException
{
RemoteFileSystem rfs = null;
try
{
File temp = File.createTempFile("FTPdown", ".tmp");
- EPR epr = ListenerUtil.assembleEpr(_config);
+ EPR epr = ListenerUtil.assembleEpr(config);
if (epr instanceof FTPEpr) {
FTPEpr ftpEpr = (FTPEpr) epr;
rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
@@ -164,14 +163,19 @@
}
}
- @Override
+ @Override
+ String getDefaultComposer() {
+ return RemoteFileMessageComposer.class.getName();
+ }
+
+ @Override
File[] getFileList() throws GatewayException
{
RemoteFileSystem rfs = null;
File[] oaRet = null;
try
{
- EPR epr = ListenerUtil.assembleEpr(_config);
+ EPR epr = ListenerUtil.assembleEpr(config);
if (epr instanceof FTPEpr) {
FTPEpr ftpEpr = (FTPEpr) epr;
rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
@@ -200,7 +204,7 @@
RemoteFileSystem rfs = null;
try
{
- EPR epr = ListenerUtil.assembleEpr(_config);
+ EPR epr = ListenerUtil.assembleEpr(config);
if (epr instanceof FTPEpr) {
FTPEpr ftpEpr = (FTPEpr) epr;
rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
@@ -230,7 +234,7 @@
RemoteFileSystem rfs = null;
try
{
- EPR epr = ListenerUtil.assembleEpr(_config);
+ EPR epr = ListenerUtil.assembleEpr(config);
if (!(epr instanceof FTPEpr))
throw new Exception("This Gateway only accepts FTP and SFTP.");
Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/XAbstractFileGateway.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/XAbstractFileGateway.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/XAbstractFileGateway.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -1,546 +0,0 @@
-package org.jboss.soa.esb.listeners.gateway;
-
-import org.jboss.soa.esb.listeners.lifecycle.AbstractThreadedManagedLifecycle;
-import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
-import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleThreadState;
-import org.jboss.soa.esb.listeners.RegistryUtil;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.listeners.ListenerUtil;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.util.Util;
-import org.jboss.soa.esb.util.ClassUtil;
-import org.jboss.soa.esb.couriers.*;
-import org.jboss.soa.esb.filter.FilterManager;
-import org.jboss.soa.esb.common.Environment;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.MalformedEPRException;
-import org.jboss.soa.esb.addressing.util.DefaultReplyTo;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
-import org.apache.log4j.Logger;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collection;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.net.URI;
-
-/**
- * Base class for all file gateways: local filesystem, ftp, sftp and ftps.
- * <p/>Implementations for file manipulation (getFileList, getFileContents,
- * renameFile and deleteFile) must be provided by factory
- *
- * @author <a
- * href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- * @since Version 4.0
- */
-public abstract class XAbstractFileGateway extends
- AbstractThreadedManagedLifecycle {
- abstract File[] getFileList() throws GatewayException;
-
- abstract byte[] getFileContents(File file) throws GatewayException;
-
- abstract boolean renameFile(File from, File to) throws GatewayException;
-
- abstract boolean deleteFile(File file) throws GatewayException;
-
- abstract void seeIfOkToWorkOnDir(File p_oDir) throws GatewayException;
-
- abstract void getDefaultComposer() throws GatewayException;
-
- abstract void bytesToFile(byte[] bytes, File file) throws GatewayException;
-
- protected XAbstractFileGateway(ConfigTree config)
- throws ConfigurationException, RegistryException, GatewayException {
- super(config);
- _config = config;
- _sleepBetweenPolls = 10000; // milliseconds
- checkMyParms();
- } // __________________________________
-
- /**
- * Handle the initialisation of the managed instance.
- *
- * @throws org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException
- * for errors while initialisation.
- */
- protected void doInitialise() throws ManagedLifecycleException {
- try {
- _targetEprs = RegistryUtil.getEprs(_targetServiceCategory,
- _targetServiceName);
- if (null == _targetEprs || _targetEprs.size() < 1)
- throw new ManagedLifecycleException("EPR <"
- + _targetServiceName + "> not found in registry");
- } catch (ServiceNotFoundException snfe) {
- throw new ManagedLifecycleException("EPR <" + _targetServiceName + " "
- + _targetServiceName + "> not found in registry");
- }
- catch (final RegistryException re) {
- throw new ManagedLifecycleException(
- "Unexpected registry exception", re);
- }
- }
-
- /**
- * Execute on the thread.
- */
- protected void doRun() {
-
- EPR replyEpr = null;
- Message replyMsg = null;
-
- if (_logger.isDebugEnabled()) {
- _logger.debug("run() method of " + this.getClass().getSimpleName()
- + " started on thread " + Thread.currentThread().getName());
- }
-
- do {
- File[] fileList;
- try {
- fileList = getFileList();
- }
- catch (GatewayException e) {
- _logger.error("Can't retrieve file list", e);
- continue;
- }
-
- for (File fileIn : fileList) {
- // Try to rename - if unsuccessful, somebody else got it first
- File fileWork = getWorkFileName(fileIn, _workingSuffix);
- try {
- if (!renameFile(fileIn, fileWork))
- continue;
- }
- catch (GatewayException e) {
- _logger.error("Problems renaming file " + fileIn + " to "
- + fileWork);
- continue;
- }
-
- Throwable thrown = null;
- String text = null;
- try {
- Object obj = _processMethod.invoke(_composer, new Object[]
- {fileWork});
- if (null == obj) {
- _logger.warn("Action class method <"
- + _processMethod.getName()
- + "> returned a null object");
- continue;
- }
- boolean bSent = false;
-
- Message outMessage = (Message) obj;
- Map<String, Object> params = new HashMap<String, Object>();
-
- params.put(Environment.ORIGINAL_FILE, fileIn);
- params.put(Environment.GATEWAY_CONFIG, _config);
-
- outMessage = FilterManager.getInstance().doOutputWork(outMessage, params);
-
- for (EPR current : _targetEprs) {
- _courier = getCourier(current);
- try {
- replyEpr = null;
- outMessage.getHeader().getCall().setTo(current);
- if (_maxMillisForResponse > 0) {
- replyEpr = DefaultReplyTo.getReplyTo(current);
- outMessage.getHeader().getCall().setReplyTo(
- replyEpr);
- }
- if (_courier.deliver(outMessage)) {
- bSent = true;
- break;
- }
- }
- finally {
- CourierUtil.cleanCourier(_courier);
- }
-
- }
- if (!bSent) {
- text = "Target service <" + _targetServiceCategory
- + "," + _targetServiceName
- + "> is not registered";
- thrown = new Exception(text);
- } else if (null != replyEpr) {
- TwoWayCourier replyCourier = CourierFactory
- .getPickupCourier(replyEpr);
- try {
- replyMsg = replyCourier
- .pickup(_maxMillisForResponse);
- _responderMethod.invoke(_composer, new Object[]
- {replyMsg, fileIn});
- }
- catch (CourierTimeoutException e) {
- thrown = e;
- text = "Expected response was not received from invoked service";
- replyMsg = MessageFactory.getInstance()
- .getMessage();
- String timedOut = "Service <"
- + _targetServiceCategory + ","
- + "_targetServiceName"
- + "> timed out without sending response";
- replyMsg.getBody()
- .setByteArray(timedOut.getBytes());
- _responderMethod.invoke(_composer, new Object[]
- {replyMsg, fileIn});
- }
- finally {
- if (null != replyCourier)
- CourierUtil.cleanCourier(replyCourier);
- }
- }
- }
- catch (InvocationTargetException e) {
- thrown = e;
- text = "Problems invoking method <"
- + _processMethod.getName() + ">";
-
- }
- catch (IllegalAccessException e) {
- thrown = e;
- text = "Problems invoking method <"
- + _processMethod.getName() + ">";
- }
- catch (ClassCastException e) {
- thrown = e;
- text = "Action class method <" + _processMethod.getName()
- + "> returned a non Message object";
- }
- catch (CourierException e) {
- thrown = e;
- if (null != _courier)
- text = "Courier <" + _courier.getClass().getName()
- + ".deliverAsync(Message) FAILED";
- else
- text = "NULL courier can't deliverAsync Message";
- }
- catch (MalformedEPRException e) {
- thrown = e;
- if (null != _courier)
- text = "Courier <"
- + _courier.getClass().getName()
- + ".deliverAsync(Message) FAILED with malformed EPR.";
- else
- text = "NULL courier can't deliverAsync Message";
- }
-
- if (null == thrown) {
- File fileOK = new File(_postProcessDirectory, fileIn
- .getName()
- + _postProcessSuffix);
- if (_deleteAfterOK) {
- try {
- deleteFile(fileWork);
- }
- catch (GatewayException e) {
- _logger
- .error(
- "File "
- + fileIn
- + " has been processed and renamed to "
- + fileWork
- + ", but there were problems deleting it from the input directory ",
- e);
- }
- } else {
- try {
- renameFile(fileWork, fileOK);
- }
- catch (GatewayException e) {
- _logger
- .error(
- "File "
- + fileIn
- + " has been processed and renamed to "
- + fileWork
- + ", but there were problems renaming it to "
- + fileOK, e);
- }
- }
- } else {
- thrown.printStackTrace();
- _logger.error(text, thrown);
- File fileError = new File(_errorDirectory, fileIn.getName()
- + _errorSuffix);
- try {
- deleteFile(fileError);
- }
- catch (GatewayException e) {
- _logger.warn("File : " + fileError + " did not exist.");
- }
- try {
- renameFile(fileWork, fileError);
- }
- catch (GatewayException e) {
- _logger.error("Problems renaming file " + fileWork
- + " to " + fileError, e);
- }
- }
- }
- }
- while (!waitForRunningStateChange(ManagedLifecycleThreadState.STOPPING,
- _sleepBetweenPolls));
-
- if (_logger.isDebugEnabled()) {
- _logger
- .debug("run() method of " + this.getClass().getSimpleName()
- + " finished on thread "
- + Thread.currentThread().getName());
- }
- } // ________________________________
-
- protected File getWorkFileName(File fileIn, String suffix) {
- return new File(fileIn.toString() + _workingSuffix);
- }
-
- /*
- * Extracted to simplify testing
- */
- protected Courier getCourier(EPR current) throws CourierException,
- MalformedEPRException {
- return CourierFactory.getCourier(current);
- }
-
- /**
- * Handle the threaded destroy of the managed instance.
- *
- * @throws org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException
- * for errors while destroying.
- */
- protected void doThreadedDestroy() throws ManagedLifecycleException {
- }
-
- /*
- * Is the input suffix valid for this type of gateway?
- */
-
- protected void checkInputSuffix() throws ConfigurationException {
- if (_inputSuffix.length() < 1)
- throw new ConfigurationException("Invalid "
- + ListenerTagNames.FILE_INPUT_SFX_TAG + " attribute");
- }
-
- /**
- * Check for mandatory and optional attributes in parameter tree
- *
- * @throws org.jboss.soa.esb.ConfigurationException
- * -
- * if mandatory atts are not right or actionClass not in
- * classpath
- */
- private void checkMyParms() throws ConfigurationException,
- RegistryException, GatewayException {
- // Third arg is null - Exception will be thrown if attribute is not
- // found
- _targetServiceCategory = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG, null);
- _targetServiceName = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.TARGET_SERVICE_NAME_TAG, null);
-
- // Polling interval
- String sAux = _config
- .getAttribute(ListenerTagNames.POLL_LATENCY_SECS_TAG);
-
- if (!Util.isNullString(sAux)) {
- try {
- _sleepBetweenPolls = 1000 * Long.parseLong(sAux);
- }
- catch (NumberFormatException e) {
- _logger.warn("Invalid poll latency - keeping default of "
- + (_sleepBetweenPolls / 1000));
- }
- } else {
- _logger.warn("No value specified for: "
- + ListenerTagNames.POLL_LATENCY_SECS_TAG
- + " - Using default of " + (_sleepBetweenPolls / 1000));
- }
-
- resolveComposerClass();
-
- boolean hasResponder = _responderMethod != null;
- _maxMillisForResponse = ListenerUtil.getMaxMillisGatewayWait(_config,
- _logger, hasResponder);
- try {
- // INPUT directory and suffix (used for FileFilter)
- String url = _config.getAttribute(ListenerTagNames.URL_TAG);
- String sInpDir = (null != url) ? new URL(url).getFile()
- : ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_INPUT_DIR_TAG, null);
- _inputDirectory = fileFromString(sInpDir);
- seeIfOkToWorkOnDir(_inputDirectory);
-
- _inputSuffix = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_INPUT_SFX_TAG, null);
- _inputSuffix = _inputSuffix.trim();
-
- checkInputSuffix();
-
- // WORK suffix (will rename in input directory)
- _workingSuffix = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_WORK_SFX_TAG, ".esbWork").trim();
- if (_workingSuffix.length() < 1)
- throw new ConfigurationException("Invalid "
- + ListenerTagNames.FILE_WORK_SFX_TAG + " attribute");
-
- if (_inputSuffix.equals(_workingSuffix))
- throw new ConfigurationException(
- "Work suffix must differ from input suffix <"
- + _workingSuffix + ">");
-
- // ERROR directory and suffix (defaults to input dir and
- // ".esbError"
- // suffix)
- String sErrDir = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_ERROR_DIR_TAG, sInpDir);
- _errorDirectory = fileFromString(sErrDir);
- seeIfOkToWorkOnDir(_errorDirectory);
-
- _errorSuffix = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_ERROR_SFX_TAG, ".esbError").trim();
- if (_errorSuffix.length() < 1)
- throw new ConfigurationException("Invalid "
- + ListenerTagNames.FILE_ERROR_SFX_TAG + " attribute");
- if (_errorDirectory.equals(_inputDirectory)
- && _inputSuffix.equals(_errorSuffix))
- throw new ConfigurationException(
- "Error suffix must differ from input suffix <"
- + _errorSuffix + ">");
-
- // Do users wish to delete files that were processed OK ?
- String sPostDel = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_POST_DEL_TAG, "false").trim();
- _deleteAfterOK = Boolean.parseBoolean(sPostDel);
- if (_deleteAfterOK)
- return;
-
- // POST (done) directory and suffix (defaults to input dir and
- // ".esbDone" suffix)
- String sPostDir = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_POST_DIR_TAG, sInpDir);
- _postProcessDirectory = fileFromString(sPostDir);
- seeIfOkToWorkOnDir(_postProcessDirectory);
- _postProcessSuffix = ListenerUtil.obtainAtt(_config,
- ListenerTagNames.FILE_POST_SFX_TAG, ".esbDone").trim();
-
- if (_postProcessDirectory.equals(_inputDirectory)) {
- if (_postProcessSuffix.length() < 1)
- throw new ConfigurationException("Invalid "
- + ListenerTagNames.FILE_POST_SFX_TAG + " attribute");
- if (_postProcessSuffix.equals(_inputSuffix))
- throw new ConfigurationException(
- "Post process suffix must differ from input suffix <"
- + _postProcessSuffix + ">");
- }
- }
- catch (GatewayException ex) {
- throw ex;
- }
- catch (MalformedURLException ex) {
- throw new ConfigurationException(ex);
- }
- } // ________________________________
-
- protected void resolveComposerClass() throws ConfigurationException,
- GatewayException {
- String sProcessMethod = null;
- String sResponderMethod = null;
- try {
- _composerName = _config
- .getAttribute(ListenerTagNames.GATEWAY_COMPOSER_CLASS_TAG);
- if (null != _composerName) { // class attribute
- _composerClass = ClassUtil.forName(_composerName, getClass());
- Constructor oConst = _composerClass.getConstructor(new Class[]
- {ConfigTree.class});
- _composer = oConst.newInstance(_config);
- sProcessMethod = _config
- .getAttribute(
- ListenerTagNames.GATEWAY_COMPOSER_METHOD_TAG,
- "process");
- sResponderMethod = _config
- .getAttribute(ListenerTagNames.GATEWAY_RESPONDER_METHOD_TAG);
- } else {
- getDefaultComposer();
- sProcessMethod = "process";
- sResponderMethod = "respond";
- }
-
- _processMethod = _composerClass.getMethod(sProcessMethod,
- new Class[]
- {Object.class});
-
- _responderMethod = (null == sResponderMethod) ? null
- : _composerClass.getMethod(sResponderMethod, new Class[]
- {Message.class, File.class});
- }
- catch (InvocationTargetException ex) {
- throw new ConfigurationException(ex);
- }
- catch (IllegalAccessException ex) {
- throw new ConfigurationException(ex);
- }
- catch (InstantiationException ex) {
- throw new ConfigurationException(ex);
- }
- catch (NoSuchMethodException ex) {
- throw new ConfigurationException(ex);
- }
- catch (ClassNotFoundException ex) {
- throw new ConfigurationException(ex);
- }
- } // ________________________________
-
- private File fileFromString(String file) {
- try {
- return new File(new URI(file));
- }
- catch (Exception e) {
- return new File(file);
- }
- } // ________________________________
-
- protected final static Logger _logger = Logger
- .getLogger(XAbstractFileGateway.class);
-
- protected ConfigTree _config;
-
- protected long _sleepBetweenPolls; // milliseconds
-
- protected long _maxMillisForResponse;
-
- protected String _targetServiceCategory, _targetServiceName;
-
- protected Collection<EPR> _targetEprs;
-
- protected String _composerName;
-
- protected Class _composerClass;
-
- protected Object _composer;
-
- protected Method _processMethod;
-
- protected Method _responderMethod;
-
- protected Courier _courier;
-
- protected boolean _deleteAfterOK;
-
- protected File _inputDirectory, _errorDirectory, _postProcessDirectory;
-
- protected String _inputSuffix, _postProcessSuffix, _workingSuffix,
- _errorSuffix;
-
- protected FileFilter _fileFilter;
-
-} // ____________________________________________________________________________
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -27,7 +27,6 @@
import java.util.HashMap;
import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.ListenerTagNames;
import org.jboss.soa.esb.listeners.ListenerUtil;
@@ -233,10 +232,6 @@
bean.setServiceInvoker(invoker);
bridge.activate();
}
- catch (RegistryException e)
- {
- logger.error("Failed activate JCA Inflow Gateway. Service '" + serviceCategory + ":" + serviceName + "'.", e);
- }
catch (MessageDeliverException e)
{
logger.error("Failed activate JCA Inflow Gateway. Service '" + serviceCategory + ":" + serviceName + "'.", e);
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/AbstractMessageComposer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/AbstractMessageComposer.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/AbstractMessageComposer.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -65,7 +65,14 @@
public Object decompose(Message message) throws MessageDeliverException {
// Hopefully we can fix the Message object such that there's no need for this
// i.e. the message will have setContents(Object) and getContents() methods.
- return ActionUtils.getTaskObject(message);
+
+ Object response = message.getBody().get();
+
+ if(response != null) {
+ return response;
+ } else {
+ return ActionUtils.getTaskObject(message);
+ }
}
/**
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/MessageComposer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/MessageComposer.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/MessageComposer.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -20,9 +20,11 @@
package org.jboss.soa.esb.listeners.message;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.internal.soa.esb.message.LegacyMessageComposerAdapter;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.soa.esb.ConfigurationException;
/**
* Message composer.
@@ -40,8 +42,9 @@
* Set the conposer's configuration.
*
* @param config Composer configuration.
+ * @throws ConfigurationException Bad configuration.
*/
- public void setConfiguration(ConfigTree config);
+ public void setConfiguration(ConfigTree config) throws ConfigurationException;
/**
* Compose an ESB "aware" message from the supplied message payload.
@@ -76,22 +79,58 @@
* @param className Class name.
* @param config The composer configuration.
* @return Composer instance.
+ * @throws ConfigurationException Bad configuration.
* @throws MessageDeliverException Unable to construct composer.
*/
- public static MessageComposer getInstance(String className, ConfigTree config) throws MessageDeliverException {
+ public static MessageComposer getInstance(String className, ConfigTree config) throws ConfigurationException, MessageDeliverException {
+ return getInstance(className, config, null);
+ }
+
+ /**
+ * Factory method.
+ *
+ * @param className Class name.
+ * @param config The composer configuration.
+ * @param legacyAdapterType The {@link LegacyMessageComposerAdapter legacy adapter} to use if the configured
+ * composer is not a {@link MessageComposer} instance.
+ * @return Composer instance.
+ * @throws ConfigurationException Bad configuration. Unable to create composer instance.
+ */
+ public static MessageComposer getInstance(String className, ConfigTree config, Class legacyAdapterType) throws ConfigurationException {
+ MessageComposer instance = null;
+
AssertArgument.isNotNullAndNotEmpty(className, "className");
AssertArgument.isNotNull(config, "config");
try {
- MessageComposer instance = (MessageComposer) ClassUtil.forName(className, Factory.class).newInstance();
- instance.setConfiguration(config);
- return instance;
+ instance = newComposerInstance(ClassUtil.forName(className, Factory.class));
+ } catch (ClassCastException e) {
+ if (legacyAdapterType == null) {
+ throw new ConfigurationException("Composer class [" + className + "] not an instance of '" + MessageComposer.class.getName() + "' and no " + LegacyMessageComposerAdapter.class.getSimpleName() + " specified.", e);
+ } else if (LegacyMessageComposerAdapter.class.isAssignableFrom(legacyAdapterType)) {
+ instance = newComposerInstance(legacyAdapterType);
+ } else {
+ throw new ConfigurationException("Legacy composer adapter class [" + legacyAdapterType.getName() + "] not an instance of '" + LegacyMessageComposerAdapter.class.getName() + "'.");
+ }
} catch (ClassNotFoundException e) {
- throw new MessageDeliverException("Composer class [" + className + "] not found in classpath.", e);
+ throw new ConfigurationException("Composer class [" + className + "] not found in classpath.", e);
+ }
+
+ instance.setConfiguration(config);
+ return instance;
+ }
+
+ private static MessageComposer newComposerInstance(Class composerClass) throws ConfigurationException {
+ try {
+ return (MessageComposer) composerClass.newInstance();
} catch (InstantiationException e) {
- throw new MessageDeliverException("Failed to instantiate composer class [" + className + "].", e);
+ if(composerClass.getEnclosingClass() != null) {
+ throw new ConfigurationException("Failed to instantiate composer class [" + composerClass.getName() + "]. This may be because it is not a top level class.", e);
+ } else {
+ throw new ConfigurationException("Failed to instantiate composer class [" + composerClass.getName() + "].", e);
+ }
} catch (IllegalAccessException e) {
- throw new MessageDeliverException("Failed to instantiate composer class [" + className + "].", e);
+ throw new ConfigurationException("Failed to instantiate composer class [" + composerClass.getName() + "].", e);
}
}
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -59,7 +59,7 @@
* @throws org.jboss.soa.esb.services.registry.RegistryException
* Failed to lookup EPRs for the specified Service.
*/
- public UncomposedMessageDeliveryAdapter(String serviceCategory, String serviceName, MessageComposer composer) throws RegistryException, MessageDeliverException {
+ public UncomposedMessageDeliveryAdapter(String serviceCategory, String serviceName, MessageComposer composer) throws MessageDeliverException {
AssertArgument.isNotNull(serviceCategory, "serviceCategory");
AssertArgument.isNotNull(serviceName, "serviceName");
AssertArgument.isNotNull(composer, "composer");
@@ -160,8 +160,6 @@
}
return new UncomposedMessageDeliveryAdapter(targetServiceCategory, targetServiceName, composer);
- } catch (RegistryException e) {
- throw new ConfigurationException("Remoting Listener configuration failed.", e);
} catch (MessageDeliverException e) {
throw new ConfigurationException("Remoting Listener configuration failed.", e);
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduleProvider.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduleProvider.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduleProvider.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -25,6 +25,7 @@
import java.util.Properties;
import java.util.List;
+import java.util.Date;
import java.text.ParseException;
/**
@@ -82,6 +83,8 @@
// Set the start and end times, if configured....
if(schedule.getStartDate() != null) {
trigger.setStartTime(schedule.getStartDate().getTime());
+ } else {
+ trigger.setStartTime(new Date());
}
if(schedule.getEndDate() != null) {
trigger.setEndTime(schedule.getEndDate().getTime());
@@ -95,6 +98,7 @@
String name = (listener.toString() + scheduleFrequency);
trigger.setName(name);
+ trigger.setStartTime(new Date());
addListener(listener, trigger, name);
}
@@ -166,7 +170,9 @@
try {
listener.onSchedule();
} catch (SchedulingException e) {
- throw new JobExecutionException("Scheduling exception on " + jobExecutionContext.getJobDetail().getName(), e);
+ JobExecutionException jobException = new JobExecutionException("Scheduling exception on " + jobExecutionContext.getJobDetail().getName());
+ jobException.initCause(e);
+ throw jobException;
}
}
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduledEventListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduledEventListener.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduledEventListener.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -36,5 +36,5 @@
*
* @throws SchedulingException Exception processing schedule event.
*/
- public void onSchedule() throws SchedulingException ;
+ public void onSchedule() throws SchedulingException;
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/MessageRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/MessageRouter.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/MessageRouter.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -29,7 +29,6 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
/**
@@ -72,8 +71,6 @@
try {
org.jboss.soa.esb.client.ServiceInvoker serviceInvoker = new org.jboss.soa.esb.client.ServiceInvoker(serviceCategory, serviceName);
serviceInvoker.deliverAsync(message);
- } catch (RegistryException e) {
- throw new MessageRouterException(e);
} catch (MessageDeliverException e) {
throw new MessageRouterException(e);
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/FileUtil.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/FileUtil.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/FileUtil.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -22,12 +22,7 @@
package org.jboss.soa.esb.util;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
+import java.io.*;
import org.apache.log4j.Logger;
@@ -170,4 +165,28 @@
reader.close();
return sb.toString();
}
+
+ /**
+ * Read the contents of a file and return it as a byte array.
+ * @param file The file to be read.
+ * @return The file contents.
+ * @throws IOException Error reading the file.
+ */
+ public static byte[] readFile(File file) throws IOException {
+ ByteArrayOutputStream fileBuffer = new ByteArrayOutputStream();
+ InputStream fileInStream = new FileInputStream(file);
+
+ try {
+ byte[] readBuffer = new byte[256];
+ int readCount = 0;
+
+ while((readCount = fileInStream.read(readBuffer)) != -1) {
+ fileBuffer.write(readBuffer, 0, readCount);
+ }
+ } finally {
+ fileInStream.close();
+ }
+
+ return fileBuffer.toByteArray();
+ }
}
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -27,12 +27,13 @@
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.services.registry.MockRegistry;
-import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.common.tests.BaseTest;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.listeners.gateway.FileGatewayListener.PackageFileContents;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+import org.jboss.soa.esb.ConfigurationException;
public class FileGatewayListenerUnitTest extends BaseTest
{
@@ -74,7 +75,7 @@
{
gateway.seeIfOkToWorkOnDir(new File("foobarDir"));
}
- catch (GatewayException ex)
+ catch (ConfigurationException ex)
{
exception = true;
}
@@ -111,38 +112,24 @@
fail();
}
- gateway.run();
+ gateway.onSchedule();
- PackageFileContents f = gateway.new PackageFileContents();
+ LocalFileMessageComposer f = new LocalFileMessageComposer();
- exception = false;
-
- try
- {
- f.process(new File("hello"));
- }
- catch (GatewayException ex)
- {
- exception = true;
- }
-
- if (!exception)
- fail();
-
- exception = false;
-
- try
- {
- f.process("hello");
- }
- catch (ConfigurationException ex)
- {
- exception = true;
- }
-
- if (!exception)
- fail();
-
+ try {
+ f.compose(new File("hello"));
+ fail("Expected exception on non-existant file.");
+ } catch(MessageDeliverException e) {
+ // expected
+ }
+
+ try {
+ f.compose("hello");
+ fail("Expected exception on invalid payload type.");
+ } catch(MessageDeliverException e) {
+ // expected
+ }
+
File testFile = null;
File anTestFile = null;
@@ -155,16 +142,14 @@
stream.write(testString.getBytes());
stream.close();
-
- f = gateway.new PackageFileContents();
- f.process(testFile);
+ Message message = f.compose(testFile);
File nFile = null;
try
{
- byte[] content = gateway.getFileContents(testFile);
+ byte[] content = message.getBody().getByteArray();
String value = new String(content);
if (!value.equals(testString))
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/GroovyGatewayUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/GroovyGatewayUnitTest.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/GroovyGatewayUnitTest.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -105,8 +105,6 @@
protected UncomposedMessageDeliveryAdapter createDeliveryAdapter() throws ConfigurationException {
try {
return new UncomposedMessageDeliveryAdapter("x", "y", new BasicMessageComposer());
- } catch (RegistryException e) {
- fail(e.getMessage());
} catch (MessageDeliverException e) {
fail(e.getMessage());
}
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -183,10 +183,6 @@
return epr3;
}
};
- } catch (RegistryException e) {
- e.printStackTrace();
- fail(e.getMessage());
- return null;
} catch (MessageDeliverException e) {
e.printStackTrace();
fail(e.getMessage());
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerIntegrationTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerIntegrationTest.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerIntegrationTest.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -36,7 +36,11 @@
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.util.embedded.EmbeddableException;
import org.jboss.internal.soa.esb.util.embedded.ftp.FtpTestUtil;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.schedule.SchedulingException;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.addressing.eprs.JMSEpr;
@@ -52,6 +56,7 @@
import org.jboss.soa.esb.services.registry.RegistryException;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.AfterClass;
/**
* Unit test for ReadOnlyRemoteGatewayListener that uses an embedded ftp server.
@@ -68,15 +73,26 @@
@BeforeClass
public static void classSetup() throws EmbeddableException, ConfigurationException, GatewayException, RegistryException, MalformedURLException
{
- ftpServer = createFtpServer();
+ MockCourierFactory.install();
+ MockRegistry.install();
+ MockRegistry.register(RemoteGatewayListenerUnitTest.SERVICE_CATEGORY, RemoteGatewayListenerUnitTest.SERVICE_NAME, new MockCourier(true));
+
+ ftpServer = createFtpServer();
ftpServer.start();
createWorkDirectories();
configTree = createConfigTree();
createRemoteGatewayListener( configTree );
}
-
- @Test
+
+ @AfterClass
+ public static void classCleanup() throws EmbeddableException, ConfigurationException, GatewayException, RegistryException, MalformedURLException
+ {
+ MockRegistry.uninstall();
+ MockCourierFactory.uninstall();
+ }
+
+ @Test
public void deleteFile() throws GatewayException
{
File remoteFile = createAbsoluteFromFile();
@@ -109,8 +125,13 @@
File inputDir = ftpServer.getLocalInputDir();
String doneFileName = testFile.getName();
- waitForFile( inputDir, doneFileName );
- stopdoRun( mock );
+ //waitForFile( inputDir, doneFileName );
+ //stopdoRun( mock );
+ try {
+ mock.onSchedule();
+ } catch (SchedulingException e) {
+ fail(e.getMessage());
+ }
File processedFile = new File ( inputDir, doneFileName );
try
@@ -222,90 +243,43 @@
*/
protected RemoteGatewayListenerMock createAndStartListener ( ConfigTree configTree, boolean returnValueForCourier ) throws ConfigurationException, GatewayException, RegistryException
{
- final RemoteGatewayListenerMock mock = new RemoteGatewayListenerMock( configTree , returnValueForCourier );
- mock.doInitialise();
+ final RemoteGatewayListenerMock mock = new RemoteGatewayListenerMock( configTree );
+ try {
+ mock.doInitialise();
+ } catch (ManagedLifecycleException e) {
+ fail(e.getMessage());
+ }
+
+ if(returnValueForCourier) {
+ MockCourierFactory.courierException = null;
+ } else {
+ MockCourierFactory.courierException = new CourierException("Test generated mock exception.");
+ }
+
+ return mock;
- Thread thread = new Thread ( new Runnable () {
- public void run()
- {
- mock.doRun();
- }
- });
- thread.start();
-
- return mock;
-
}
- protected void stopdoRun ( RemoteGatewayListenerMock mock )
- {
- if ( mock == null ) return;
- try
- {
- mock.stop();
- }
- catch ( Exception e )
- {
- if ( ! (e instanceof ManagedLifecycleException ) )
- fail ( e.getMessage() );
- }
- }
-
/**
* Mock impl of RemoteGatewayListener.
*/
class RemoteGatewayListenerMock extends ReadOnlyRemoteGatewayListener
{
private static final long serialVersionUID = 1L;
-
- /* value that will be returned from the getCourier( EPR ) method */
- private boolean returnValueForCourier;
-
+
private boolean finishedOneRun;
/**
* Sole constructor
*
* @param configTree configTree used to configure this RemoteGatewayListener
- * @param returnValueForCourier value to be returned from this objects getCourier( EPR ) method
*
*/
- public RemoteGatewayListenerMock ( ConfigTree configTree, boolean returnValueForCourier) throws ConfigurationException, GatewayException, RegistryException
+ public RemoteGatewayListenerMock ( ConfigTree configTree) throws ConfigurationException, GatewayException, RegistryException
{
super ( configTree );
- this.returnValueForCourier = returnValueForCourier;
- }
-
- /**
- * Will return a Courier instance that returns the value of the
- * field returnValueForCourier.
- */
- @Override
- protected Courier getCourier( EPR current ) throws CourierException, MalformedEPRException
- {
- return new Courier() {
- public boolean deliver( Message message ) throws CourierException, MalformedEPRException
- {
- return returnValueForCourier;
- }
- public void cleanup() { }
- };
- }
-
- @Override
- protected void doInitialise()
- {
- _targetEprs = new ArrayList<EPR>();
- _targetEprs.add( new JMSEpr( new EPR() ) );
- };
-
- @Override
- protected boolean waitForRunningStateChange(final ManagedLifecycleThreadState state, final long terminationPeriod)
- {
- finishedOneRun = true;
- return super.waitForRunningStateChange( state, terminationPeriod );
- }
-
+ }
+
public boolean hasFinishedOneRun()
{
return finishedOneRun;
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerIntegrationTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerIntegrationTest.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerIntegrationTest.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -27,10 +27,26 @@
import org.jboss.soa.esb.addressing.eprs.FTPEpr;
import org.jboss.soa.esb.common.tests.BaseTest;
import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleState;
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
public class RemoteGatewayListenerIntegrationTest extends BaseTest
{
- public RemoteGatewayListenerIntegrationTest ()
+
+ protected void setUp() throws Exception {
+ MockCourierFactory.install();
+ MockRegistry.install();
+ MockRegistry.register("Example", "Test", new MockCourier(true));
+ }
+
+ protected void tearDown() throws Exception {
+ MockRegistry.uninstall();
+ MockCourierFactory.uninstall();
+ }
+
+ public RemoteGatewayListenerIntegrationTest ()
{
}
@@ -62,66 +78,74 @@
RemoteGatewayListener gateway = new RemoteGatewayListener(tree);
boolean exception = false;
-
- try
- {
- gateway.deleteFile(new File("foo"));
- }
- catch (GatewayException ex)
- {
- exception = true;
- }
-
- if (!exception)
- fail();
-
- gateway.run();
-
- try
- {
- @SuppressWarnings("unused")
- byte[] contents = gateway.getFileContents(new File("bar"));
-
- fail();
- }
- catch (GatewayException ex)
- {
- }
-
- // TODO this ignores the parameter too!
-
- try
- {
- gateway.getFileList();
- }
- catch (GatewayException ex)
- {
- fail();
- }
-
- exception = false;
-
- try
- {
- gateway.deleteFile(new File("foo"));
- }
- catch (GatewayException ex)
- {
- exception = true;
- }
-
- if (!exception)
- fail();
-
- try
- {
- gateway.renameFile(new File("foo"), new File("bar"));
-
- fail();
- }
- catch (GatewayException ex)
- {
- }
- }
+
+ gateway.initialise();
+ gateway.start();
+
+ try {
+ try
+ {
+ gateway.deleteFile(new File("foo"));
+ }
+ catch (GatewayException ex)
+ {
+ exception = true;
+ }
+
+ if (!exception)
+ fail();
+
+ gateway.onSchedule();
+
+ try
+ {
+ @SuppressWarnings("unused")
+ byte[] contents = gateway.getFileContents(new File("bar"));
+
+ fail();
+ }
+ catch (GatewayException ex)
+ {
+ }
+
+ // TODO this ignores the parameter too!
+
+ try
+ {
+ gateway.getFileList();
+ }
+ catch (GatewayException ex)
+ {
+ fail();
+ }
+
+ exception = false;
+
+ try
+ {
+ gateway.deleteFile(new File("foo"));
+ }
+ catch (GatewayException ex)
+ {
+ exception = true;
+ }
+
+ if (!exception)
+ fail();
+
+ try
+ {
+ gateway.renameFile(new File("foo"), new File("bar"));
+
+ fail();
+ }
+ catch (GatewayException ex)
+ {
+ }
+ } finally {
+ gateway.stop();
+ gateway.destroy();
+ }
+ }
}
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerUnitTest.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerUnitTest.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -28,7 +28,6 @@
import java.io.File;
import java.net.MalformedURLException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -38,17 +37,16 @@
import org.jboss.internal.soa.esb.util.embedded.EmbeddableException;
import org.jboss.internal.soa.esb.util.embedded.ftp.FtpTestUtil;
import org.jboss.internal.soa.esb.util.embedded.ftp.NoConfigFileFtpServer;
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.MalformedEPRException;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.couriers.Courier;
+import org.jboss.soa.esb.schedule.SchedulingException;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
-import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleThreadState;
-import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.services.registry.RegistryException;
import org.junit.After;
import org.junit.AfterClass;
@@ -88,8 +86,8 @@
/* name of the remote ftp error directory */
protected static String remoteErrorDirName;
- private static final String SERVICE_CATEGORY = "RemoteGWListenerTest";
- private static final String SERVICE_NAME = SERVICE_CATEGORY;
+ protected static final String SERVICE_CATEGORY = "RemoteGWListenerTest";
+ protected static final String SERVICE_NAME = SERVICE_CATEGORY;
private static final String INPUT_SUFFIX = ".txt";
private static final String WORK_SUFFIX = ".esbwork";
protected static final String POST_SUFFIX = ".done";
@@ -104,8 +102,11 @@
protected File renamedFile;
@BeforeClass
- public static void classSetup() throws EmbeddableException, ConfigurationException, GatewayException, RegistryException, MalformedURLException
- {
+ public static void classSetup() throws EmbeddableException, ConfigurationException, GatewayException, RegistryException, MalformedURLException, MessageDeliverException {
+ MockCourierFactory.install();
+ MockRegistry.install();
+ MockRegistry.register(RemoteGatewayListenerUnitTest.SERVICE_CATEGORY, RemoteGatewayListenerUnitTest.SERVICE_NAME, new MockCourier(true));
+
ftpServer = createFtpServer();
ftpServer.start();
@@ -116,6 +117,13 @@
}
+ @AfterClass
+ public static void classCleanup() throws EmbeddableException, ConfigurationException, GatewayException, RegistryException, MalformedURLException
+ {
+ MockRegistry.uninstall();
+ MockCourierFactory.uninstall();
+ }
+
protected static void createWorkDirectories()
{
remoteInputDirName = "/" + ftpServer.getLocalInputDir().getName();
@@ -125,8 +133,7 @@
protected static void createRemoteGatewayListener( ConfigTree configTree )
- throws ConfigurationException, RegistryException, GatewayException
- {
+ throws ConfigurationException, RegistryException, GatewayException {
gatewayListener = new RemoteGatewayListener( configTree );
}
@@ -174,7 +181,7 @@
* inputDir="/input"
* postDir="/upload"
*/
- @Test ( timeout=3000 )
+ @Test //( timeout=3000 )
public void doRun_PostDir_Different_From_InputDir() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException
{
setAbsoluteInputDir();
@@ -186,18 +193,26 @@
File done = ftpServer.getLocalUploadDir();
String doneFileName = testFile.getName() + POST_SUFFIX;
- waitForFile( done, doneFileName );
- stopdoRun( mock );
-
- File processedFile = new File ( done, doneFileName );
- try
- {
- assertTrue ( processedFile.exists() );
- }
- finally
- {
- FtpTestUtil.deleteFile( processedFile );
- }
+ try {
+ mock.onSchedule();
+ } catch (SchedulingException e) {
+ fail(e.getMessage());
+ }
+
+ try {
+ File processedFile = new File ( done, doneFileName );
+ try
+ {
+ assertTrue ( processedFile.exists() );
+ }
+ finally
+ {
+ FtpTestUtil.deleteFile( processedFile );
+ }
+ } finally {
+ mock.stop();
+ mock.destroy();
+ }
}
/**
@@ -216,19 +231,27 @@
File inputDir = ftpServer.getLocalInputDir();
String doneFileName = testFile.getName() + POST_SUFFIX;
-
- waitForFile( inputDir, doneFileName );
- stopdoRun( mock );
-
- File processedFile = new File ( inputDir, doneFileName );
- try
- {
- assertTrue ( processedFile.exists() );
- }
- finally
- {
- FtpTestUtil.deleteFile( processedFile );
- }
+
+ try {
+ mock.onSchedule();
+ } catch (SchedulingException e) {
+ fail(e.getMessage());
+ }
+
+ try {
+ File processedFile = new File ( inputDir, doneFileName );
+ try
+ {
+ assertTrue ( processedFile.exists() );
+ }
+ finally
+ {
+ FtpTestUtil.deleteFile( processedFile );
+ }
+ } finally {
+ mock.stop();
+ mock.destroy();
+ }
}
/**
@@ -250,19 +273,28 @@
File errorDir = ftpServer.getLocalErrorDir();
String errorFileName = testFile.getName() + POST_ERROR_SUFFIX;
- waitForFile( errorDir, errorFileName );
- stopdoRun( mock );
-
- File errorFile = new File ( errorDir, errorFileName );
- try
- {
- assertTrue ( errorFile.exists() );
- }
- finally
- {
- FtpTestUtil.deleteFile( errorFile );
- }
- }
+
+ try {
+ mock.onSchedule();
+ } catch (SchedulingException e) {
+ fail(e.getMessage());
+ }
+
+ try {
+ File errorFile = new File ( errorDir, errorFileName );
+ try
+ {
+ assertTrue ( errorFile.exists() );
+ }
+ finally
+ {
+ FtpTestUtil.deleteFile( errorFile );
+ }
+ } finally {
+ mock.stop();
+ mock.destroy();
+ }
+ }
@Test
public void renameFile_In_Same_Directory() throws GatewayException
@@ -401,35 +433,23 @@
*/
private RemoteGatewayListenerMock createAndStartListener ( ConfigTree configTree, boolean returnValueForCourier ) throws ConfigurationException, GatewayException, RegistryException
{
- final RemoteGatewayListenerMock mock = new RemoteGatewayListenerMock( configTree , returnValueForCourier );
- mock.doInitialise();
-
- Thread thread = new Thread ( new Runnable () {
- public void run()
- {
- mock.doRun();
- }
- });
- thread.start();
-
- return mock;
-
+ final RemoteGatewayListenerMock mock = new RemoteGatewayListenerMock( configTree );
+ try {
+ mock.initialise();
+ mock.start();
+ } catch (ManagedLifecycleException e) {
+ fail(e.getMessage());
+ }
+
+ if(returnValueForCourier) {
+ MockCourierFactory.courierException = null;
+ } else {
+ MockCourierFactory.courierException = new CourierException("Test generated mock exception.");
+ }
+
+ return mock;
}
- private void stopdoRun ( RemoteGatewayListenerMock mock )
- {
- if ( mock == null ) return;
- try
- {
- mock.stop();
- }
- catch ( Exception e )
- {
- if ( ! (e instanceof ManagedLifecycleException ) )
- fail ( e.getMessage() );
- }
- }
-
protected static void assertFileRemoved( File file)
{
assertFalse( "The file was not removed from the filesystem", file.exists() );
@@ -489,55 +509,19 @@
class RemoteGatewayListenerMock extends RemoteGatewayListener
{
private static final long serialVersionUID = 1L;
-
- /* value that will be returned from the getCourier( EPR ) method */
- private boolean returnValueForCourier;
-
+
private boolean finishedOneRun;
/**
* Sole constructor
*
* @param configTree configTree used to configure this RemoteGatewayListener
- * @param returnValueForCourier value to be returned from this objects getCourier( EPR ) method
*
*/
- public RemoteGatewayListenerMock ( ConfigTree configTree, boolean returnValueForCourier) throws ConfigurationException, GatewayException, RegistryException
- {
+ public RemoteGatewayListenerMock ( ConfigTree configTree) throws ConfigurationException, GatewayException, RegistryException {
super ( configTree );
- this.returnValueForCourier = returnValueForCourier;
}
-
- /**
- * Will return a Courier instance that returns the value of the
- * field returnValueForCourier.
- */
- @Override
- protected Courier getCourier( EPR current ) throws CourierException, MalformedEPRException
- {
- return new Courier() {
- public boolean deliver( Message message ) throws CourierException, MalformedEPRException
- {
- return returnValueForCourier;
- }
- public void cleanup() { }
- };
- }
-
- @Override
- protected void doInitialise()
- {
- _targetEprs = new ArrayList<EPR>();
- _targetEprs.add( new JMSEpr( new EPR() ) );
- };
-
- @Override
- protected boolean waitForRunningStateChange(final ManagedLifecycleThreadState state, final long terminationPeriod)
- {
- finishedOneRun = true;
- return super.waitForRunningStateChange( state, terminationPeriod );
- }
-
+
public boolean hasFinishedOneRun()
{
return finishedOneRun;
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/README.TXT
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/README.TXT 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/README.TXT 2007-08-16 18:46:43 UTC (rev 14322)
@@ -47,7 +47,7 @@
1. In a command terminal window in this folder, type 'ant deploy'.
2. Start your favorite SOAP client (e.g. SOAPUI) and load the
'RetailerService' WSDL (http://localhost:18080/active-bpel/services/RetailerService?wsdl).
- 3. Load the SOAP client with the sample order in
+ 3. Load the SOAP client (RetailerServiceBinding/SubmitOrder) with the sample order in
'bpel/resources/sampleData/submit-order-01.xml'.
4. Submit the new order using the SOAP UI client.
5. View the state of the new process in 'Active Processes' on the BPEL
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer2/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer2/test/SendEsbMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer2/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer2/test/SendEsbMessage.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer2/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer2/test/SendEsbMessage.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -20,19 +20,10 @@
*/
package org.jboss.soa.esb.samples.quickstart.webservice_consumer2.test;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPoolContainer;
import org.jboss.soa.esb.client.ServiceInvoker;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.format.MessageType;
-import org.jboss.soa.esb.samples.quickstart.webservice_consumer2.LineItem;
-import org.jboss.soa.esb.samples.quickstart.webservice_consumer2.Order;
public class SendEsbMessage
Modified: labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java 2007-08-16 18:45:22 UTC (rev 14321)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java 2007-08-16 18:46:43 UTC (rev 14322)
@@ -44,7 +44,6 @@
import org.jboss.soa.esb.services.persistence.MessageStore;
import org.jboss.soa.esb.services.persistence.MessageStoreException;
import org.jboss.soa.esb.services.persistence.RedeliverStore;
-import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.util.Util;
import org.jboss.util.Base64;
@@ -324,8 +323,6 @@
isDelivered=true;
} catch (MessageDeliverException e) {
logger.debug(e.getMessage(), e);
- } catch (RegistryException e) {
- logger.error(e.getMessage(), e);
}
if (isDelivered) {
More information about the jboss-svn-commits
mailing list