[jboss-svn-commits] JBL Code SVN: r12458 - in labs/jbossesb/workspace/dbevenius/product: core/listeners/src/org/jboss/soa/esb/listeners/gateway and 8 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jun 11 14:14:27 EDT 2007


Author: beve
Date: 2007-06-11 14:14:26 -0400 (Mon, 11 Jun 2007)
New Revision: 12458

Added:
   labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListener.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/RemoteFileSystemStrategyException.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheException.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerUnitTest.java
Removed:
   labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java
Modified:
   labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapper.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategy.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/RemoteFileSystemStrategy.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListener.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCache.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerUnitTest.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyUnitTest.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTestUtil.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/ftpfile_cache_test.xml
   labs/jbossesb/workspace/dbevenius/product/docs/ProgrammersGuide.odt
   labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/build.xml
   labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/ftpfile-cache-config.xml
   labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/jboss-esb-readonly-unfiltered.xml
   labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/readme.txt
Log:
Refactored to have a subclass of RemoteGatewayListener.

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapper.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapper.java	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapper.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -30,8 +30,8 @@
 import org.jboss.soa.esb.listeners.config.FtpMessageFilterDocument.FtpMessageFilter;
 import org.jboss.soa.esb.listeners.config.FtpProviderDocument.FtpProvider;
 import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
+import org.jboss.soa.esb.listeners.gateway.ReadOnlyRemoteGatewayListener;
 import org.jboss.soa.esb.listeners.gateway.RemoteGatewayListener;
-import org.jboss.soa.esb.listeners.gateway.remotestrategies.ReadOnlyRemoteFileSystemStrategy;
 import org.w3c.dom.Element;
 
 /**
@@ -79,12 +79,10 @@
 		// Map the <property> elements targeted at the listener - from the listener itself.
 		MapperUtil.mapProperties(listener.getPropertyList(), listenerNode);			
 		if(listener.getIsGateway()) {
-			listenerNode.setAttribute("gatewayClass", RemoteGatewayListener.class.getName());
 			if ( messageFilter.getReadOnly() )
-			{
-				listenerNode.setAttribute(RemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CLASS, 
-						ReadOnlyRemoteFileSystemStrategy.class.getName());
-			}
+				listenerNode.setAttribute("gatewayClass", ReadOnlyRemoteGatewayListener.class.getName());
+			else
+				listenerNode.setAttribute("gatewayClass", RemoteGatewayListener.class.getName());
 			// Map EPR related attributes onto the listener - from the bus and provider and listener.
 			// Note: This will change - the Gateways will also support the EPR element...
 			mapFtpEprProperties(listenerNode, provider, messageFilter);

Added: labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListener.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListener.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListener.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -0,0 +1,218 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.listeners.gateway;
+
+import java.io.File;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.gateway.remotestrategies.ReadOnlyRemoteFileSystemStrategy;
+import org.jboss.soa.esb.listeners.gateway.remotestrategies.RemoteFileSystemStrategy;
+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.services.registry.RegistryException;
+import org.jboss.soa.esb.util.ClassUtil;
+
+/**
+ * Sample Listener Configuration:
+ * <pre>
+ * &lt;ftp-listener name="FtpGateway"
+ *  busidref="helloFTPChannel"
+ *   maxThreads="1"
+ *    is-gateway="true"&gt;
+ *     &lt;property name="pollLatencySeconds" value="5"/&gt; &lt;!-- Interval to poll the remote file system --&gt;
+ *     &lt;property name="remoteFileSystemStrategy-configFile" value="/ftpfile-cache-config.xml"/&gt; &lt;!-- Optional--&gt;
+ *     &lt;property name="remoteFileSystemStrategy-cacheListener" value=""org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.DeleteOnEvictTreeCacheListener"/&gt; &lt;!-- Optional--&gt;
+ *     &lt;property name="remoteFileSystemStrategy-class" value="org.my.MyRemoteGatewayStrategy"/&gt; &lt;!-- Optional--&gt;
+ *&lt;/ftp-listener&gt;
+ * </pre>
+ * 
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>				
+ *
+ */
+public class ReadOnlyRemoteGatewayListener extends RemoteGatewayListener
+{
+	/**
+	 * Property to specify the {@link RemoteFileSystemStrategy} implementation
+	 */
+	public static final String REMOTE_FILE_SYSTEM_STRATEGY_CLASS = "remoteFileSystemStrategy-class";
+	/**
+	 * Property to specify a configuration file for {@link #REMOTE_FILE_SYSTEM_STRATEGY_CLASS} 
+	 */
+	public static final String REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE = "remoteFileSystemStrategy-configFile";
+	/**
+	 * Property to specify if a the TreeCacheListener should be used. See {@link DeleteOnEvictTreeCacheListener} 
+	 */
+	public static final String REMOTE_FILE_SYSTEM_STRATEGY_CACHE_LISTENER = "remoteFileSystemStrategy-cacheListener";
+	/**
+	 * A strategy for handling call related to write operations.
+	 */
+	private RemoteFileSystemStrategy remotefileSystemStrategy;
+    /**
+     * serial version uid for this class
+     */
+    private static final long serialVersionUID = 8505559166811233906L;
+    
+    public ReadOnlyRemoteGatewayListener(ConfigTree config) throws ConfigurationException, RegistryException, GatewayException {
+		super(config);
+		createRemoteFileSystemStrategy();
+	}
+
+	/**
+	 * Delegates to {@link RemoteFileSystemStrategy#deleteFile(File)}
+	 */
+	@Override
+	public boolean deleteFile( File file ) throws GatewayException
+	{
+		try
+		{
+			return remotefileSystemStrategy.deleteFile( file );
+		} 
+		catch (RemoteFileSystemStrategyException e)
+		{
+			throw new GatewayException( e );
+		}
+	}
+
+	/**
+	 * Delegates to {@link RemoteFileSystemStrategy#filterFileList(File[])}
+	 */
+	@Override
+	File[] getFileList() throws GatewayException
+	{
+		try
+		{
+			return remotefileSystemStrategy.filterFileList( super.getFileList() );
+		} 
+		catch (RemoteFileSystemStrategyException e)
+		{
+			throw new GatewayException( e );
+		}
+	}
+
+	/**
+	 * Delegates to {@link RemoteFileSystemStrategy#renameFile(File, File)}
+	 */
+	@Override
+	boolean renameFile(File from, File to) throws GatewayException
+	{
+		try
+		{
+			return remotefileSystemStrategy.renameFile( from, to );
+		} 
+		catch (RemoteFileSystemStrategyException e)
+		{
+			throw new GatewayException( e );
+		}
+	}
+	
+	/**
+	 * Delegates to {@link RemoteFileSystemStrategy#getWorkFileName(File, String)}
+	 */
+	@Override
+	protected File getWorkFileName(File file, String suffix )
+	{
+		return remotefileSystemStrategy.getWorkFileName( file, suffix );
+	}
+	
+	/**
+	 * Set the {@link RemoteFileSystemStrategy } to be used
+	 * @param remotefileSystemStrategy
+	 */
+	public void setRemotefileSystemStrategy( RemoteFileSystemStrategy remotefileSystemStrategy )
+	{
+		this.remotefileSystemStrategy = remotefileSystemStrategy;
+	}
+	
+	protected <T> T getNewInstanceOf( String className ) throws ConfigurationException
+	{
+		if ( className == null )
+			throw new IllegalArgumentException ( "className argument must not be null.");
+		
+		T instance = null;
+		try
+		{
+			@SuppressWarnings ("unchecked")
+            Class<T> type = ClassUtil.forName( className , getClass());
+            instance = (T) type.newInstance();
+		}
+		catch (Exception ex)
+		{
+			_logger.error(ex);
+			throw new ConfigurationException(ex);
+		}
+		return instance;
+	}
+
+	/**
+	 * Stop the service and also after that stop the 
+	 * remotefileSystemStrategy in use
+	 */
+	protected void doStop() throws ManagedLifecycleException
+	{
+		super.doStop();
+		remotefileSystemStrategy.stop();
+	}
+	
+	private void createRemoteFileSystemStrategy() throws ConfigurationException
+	{
+		String strategyClassName = _config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CLASS );
+		RemoteFileSystemStrategy strategy = null;
+		
+		if ( strategyClassName != null )
+			strategy = getNewInstanceOf( strategyClassName );
+		
+		remotefileSystemStrategy = strategy != null ? strategy : new ReadOnlyRemoteFileSystemStrategy();
+
+		String configFile = _config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE );
+		try
+		{
+			remotefileSystemStrategy.init( configFile );
+				
+			if ( remotefileSystemStrategy instanceof ReadOnlyRemoteFileSystemStrategy )
+			{
+				ReadOnlyRemoteFileSystemStrategy rm = (ReadOnlyRemoteFileSystemStrategy) remotefileSystemStrategy;
+				String cacheListener = _config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CACHE_LISTENER );
+				_logger.debug( "cacheListener : " + cacheListener );
+				
+				if ( cacheListener != null )
+				{
+		           Class cacheListenerClass = ClassUtil.forName( cacheListener , getClass() );
+		           rm.setCacheListener( cacheListenerClass );
+				}
+			}
+		}
+		catch( RemoteFileSystemStrategyException e )
+		{
+			_logger.error( "Could not configure the remoteFileSystemStrategy.", e );
+			throw new ConfigurationException(e);
+		} 
+		catch (ClassNotFoundException e)
+		{
+			_logger.error( "Could not configure the remoteFileSystemStrategy.", e );
+			throw new ConfigurationException(e);
+		}
+	}
+
+}

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -31,16 +31,22 @@
 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.gateway.remotestrategies.ReadOnlyRemoteFileSystemStrategy;
-import org.jboss.soa.esb.listeners.gateway.remotestrategies.RemoteFileSystemStrategy;
 import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.util.ClassUtil;
 import org.jboss.soa.esb.util.FtpClientUtil;
 import org.jboss.soa.esb.util.RemoteFileSystem;
 import org.jboss.soa.esb.util.RemoteFileSystemException;
 import org.jboss.soa.esb.util.RemoteFileSystemFactory;
 
 /**
+ * Sample Listener Configuration:
+ * <pre>
+ * &lt;ftp-listener name="FtpGateway"
+ *  busidref="helloFTPChannel"
+ *   maxThreads="1"
+ *    is-gateway="true"&gt;
+ *     &lt;property name="pollLatencySeconds" value="5"/&gt; &lt;!-- Interval to poll the remote file system --&gt;
+ *&lt;/ftp-listener&gt;
+ * </pre>
  * 
  * @author John Doe				
  * @author Daniel Bevenius				
@@ -48,16 +54,6 @@
  */
 public class RemoteGatewayListener extends FileGatewayListener
 {
-	/**
-	 * Property name
-	 */
-	public static final String REMOTE_FILE_SYSTEM_STRATEGY_CLASS = "remoteFileSystemStrategy-class";
-	public static final String REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE = "remoteFileSystemStrategy-configFile";
-	public static final String REMOTE_FILE_SYSTEM_STRATEGY_CACHE_LISTENER = "remoteFileSystemStrategy-deleteOnEviction";
-	/**
-	 * A strategy from handling call related to write operations 
-	 */
-	protected RemoteFileSystemStrategy remotefileSystemStrategy = new DefaultRemoteFileSystemStrategy();
     /**
      * serial version uid for this class
      */
@@ -68,7 +64,7 @@
         checkMyParms() ;
 	}
 
-	private void checkMyParms() throws ConfigurationException, RegistryException, GatewayException
+	protected void checkMyParms() throws ConfigurationException, RegistryException, GatewayException
 	{
 		try
 		{
@@ -98,42 +94,8 @@
 			throw new ConfigurationException(ex);
 		}
 		
-		createStrategy();
-		
 	}
 
-	private void createStrategy() throws ConfigurationException
-	{
-		String strategyClassName = _config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CLASS );
-		if ( strategyClassName != null )
-		{
-			RemoteFileSystemStrategy strategy = getNewInstanceOf( strategyClassName );
-			if ( strategy != null )
-			{
-				remotefileSystemStrategy = strategy;
-				String configFile = _config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE );
-				try
-				{
-					remotefileSystemStrategy.init( configFile );
-					
-					if ( remotefileSystemStrategy instanceof ReadOnlyRemoteFileSystemStrategy )
-					{
-						String deleteOnEvition = _config.getAttribute( REMOTE_FILE_SYSTEM_STRATEGY_CACHE_LISTENER, "false"  );
-						_logger.debug( "deleteOnEviction : " + deleteOnEvition );
-						if ( Boolean.valueOf( deleteOnEvition ))
-							((ReadOnlyRemoteFileSystemStrategy) remotefileSystemStrategy).setDeleteOnEviction();
-					}
-				}
-				catch( Exception e )
-				{
-					_logger.error( "Could not configure the remoteFileSystemStrategy.", e );
-					throw new ConfigurationException(e);
-				}
-			}
-		}
-	}
-	
-
 	@Override
 	protected void seeIfOkToWorkOnDir(File p_oDir) throws GatewayException
 	{
@@ -143,13 +105,33 @@
 		// p_oDir exists 
 		// p_oDir writable 
 		// p_oDir readable 
-
 	}
 
 	@Override
 	public boolean deleteFile(File file) throws GatewayException
 	{
-		return remotefileSystemStrategy.deleteFile( file );
+		RemoteFileSystem rfs = null;
+		try
+		{
+			EPR epr = ListenerUtil.assembleEpr(_config);
+			if (epr instanceof FTPEpr)  {
+				FTPEpr ftpEpr = (FTPEpr) epr;
+				rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
+				rfs.setRemoteDir(FtpClientUtil.fileToFtpString(_inputDirectory));
+				rfs.deleteRemoteFile(file.toString());
+				return true;
+			} else {
+				throw new GatewayException("This Gateway only accepts FTP and SFTP.");
+			}
+			
+		} catch (Exception e)
+		{
+			throw new GatewayException(e);
+		} finally
+		{
+			if (null != rfs)
+				rfs.quit();
+		}
 	}
 
 	@Override
@@ -200,7 +182,6 @@
 				if (null != sa)
 					for (String sCurr : sa)
 						oaRet[i1++] = new File(sCurr);
-//				return oaRet;
 			} else {
 				throw new GatewayException("This Gateway only accepts FTP and SFTP.");
 			}
@@ -210,121 +191,39 @@
 			if (null != rfs)
 				rfs.quit();
 		}
-		return remotefileSystemStrategy.filterFileList(oaRet);
+		return oaRet;
 	}
 
 	@Override
 	boolean renameFile(File from, File to) throws GatewayException
 	{
-		return remotefileSystemStrategy.renameFile( from, to );
-	}
-	
-	@Override
-	protected File getWorkFileName(File file, String suffix )
-	{
-		return remotefileSystemStrategy.getWorkFileName( file, suffix );
-	}
-	
-	class DefaultRemoteFileSystemStrategy implements RemoteFileSystemStrategy
-	{
-		
-		public boolean deleteFile(File file) throws GatewayException
+		RemoteFileSystem rfs = null;
+		try
 		{
-			RemoteFileSystem rfs = null;
-			try
-			{
-				EPR epr = ListenerUtil.assembleEpr(_config);
-				if (epr instanceof FTPEpr)  {
-					FTPEpr ftpEpr = (FTPEpr) epr;
-					rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
-					rfs.setRemoteDir(FtpClientUtil.fileToFtpString(_inputDirectory));
-					rfs.deleteRemoteFile(file.toString());
-					return true;
-				} else {
-					throw new GatewayException("This Gateway only accepts FTP and SFTP.");
-				}
-				
-			} catch (Exception e)
-			{
-				throw new GatewayException(e);
-			} finally
-			{
-				if (null != rfs)
-					rfs.quit();
+			EPR epr = ListenerUtil.assembleEpr(_config);
+			if (epr instanceof FTPEpr)  {
+				FTPEpr ftpEpr = (FTPEpr) epr;
+				rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
+				rfs.setRemoteDir(FtpClientUtil.fileToFtpString(_inputDirectory));
+				rfs.remoteRename( from, to );
+				return true;
+			} else {
+				throw new GatewayException("This Gateway only accepts FTP and SFTP.");
 			}
+		} catch (Exception e) {
+			throw new GatewayException(e);
+		} finally {
+			if (null != rfs)
+				rfs.quit();
 		}
-
-		public boolean renameFile(File from, File to) throws GatewayException
-		{
-			RemoteFileSystem rfs = null;
-			try
-			{
-				EPR epr = ListenerUtil.assembleEpr(_config);
-				if (epr instanceof FTPEpr)  {
-					FTPEpr ftpEpr = (FTPEpr) epr;
-					rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
-					rfs.setRemoteDir(FtpClientUtil.fileToFtpString(_inputDirectory));
-					rfs.remoteRename( from, to );
-					return true;
-				} else {
-					throw new GatewayException("This Gateway only accepts FTP and SFTP.");
-				}
-			} catch (Exception e) {
-				throw new GatewayException(e);
-			} finally {
-				if (null != rfs)
-					rfs.quit();
-			}
-		}
-
-		public File getWorkFileName( File file, String suffix )
-		{
-			return new File( file.toString() + suffix);
-		}
-
-		/**
-		 * Does not filter the passed in files array
-		 * 
-		 * @return File[]	the unmodified file[] array passed in.
-		 */
-		public File[] filterFileList( final File[] files ) throws GatewayException
-		{
-			return files;
-		}
-
-		public void init( String configFile )
-		{
-			// no initialization needed
-		}
-
 	}
-
-	public void setRemotefileSystemStrategy(
-			RemoteFileSystemStrategy remotefileSystemStrategy )
-	{
-		this.remotefileSystemStrategy = remotefileSystemStrategy;
-	}
 	
-	protected <T> T getNewInstanceOf( String className ) throws ConfigurationException
+	@Override
+	protected File getWorkFileName(File file, String suffix )
 	{
-		if ( className == null )
-			throw new IllegalArgumentException ( "className argument must not be null.");
-		
-		T instance = null;
-		try
-		{
-			@SuppressWarnings ("unchecked")
-            Class<T> type = ClassUtil.forName( className , getClass());
-            instance = (T) type.newInstance();
-		}
-		catch (Exception ex)
-		{
-			_logger.debug(ex);
-			throw new ConfigurationException(ex);
-		}
-		return instance;
+		return new File( file.toString() + suffix);
 	}
-
+	
 	@Override
 	void bytesToFile(byte[] bytes, File file) throws GatewayException 
 	{
@@ -351,5 +250,5 @@
 				rfs.quit();
 		}
 	}
-
+	
 }

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategy.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategy.java	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategy.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -28,16 +28,17 @@
 
 import org.apache.log4j.Logger;
 import org.jboss.cache.CacheException;
-import org.jboss.soa.esb.listeners.gateway.GatewayException;
 import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.FtpFileCache;
+import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.FtpFileCacheException;
 
 /**
  * Read-only implementation of {@link RemoteFileSystemStrategy}.
- * 
- *  An instance of this class can be used when a remote file system does
- *  not support write operations.
+ * <p> 
+ * An instance of this class can be used when a remote file system does
+ * not support write operations.
+ * </p>
  *  
- * @author Daniel Bevenius
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>				
  *
  */
 public class ReadOnlyRemoteFileSystemStrategy implements RemoteFileSystemStrategy
@@ -45,12 +46,22 @@
 	private Logger log = Logger .getLogger( ReadOnlyRemoteFileSystemStrategy.class );
 	
 	private FtpFileCache ftpFileCache;
-
-	public void init( String configFile ) throws Exception 
+	
+	/**
+	 * Configures and starts the underlying FtpFileCache
+	 */
+	public void init( String configFile ) throws RemoteFileSystemStrategyException
 	{
-		ftpFileCache = new FtpFileCache( configFile );
+		try
+		{
+			ftpFileCache = new FtpFileCache( configFile );
 		
-		ftpFileCache.start();
+			ftpFileCache.start();
+		}
+		catch ( FtpFileCacheException e )
+		{
+			throw new RemoteFileSystemStrategyException ( e );
+		}
 	}
 
 	/**
@@ -59,7 +70,7 @@
 	 * @param file		the file to delete. Ignored
 	 * @return true	always returns true without deleting the filee
 	 */
-	public boolean deleteFile( File file ) throws GatewayException
+	public boolean deleteFile( File file ) throws RemoteFileSystemStrategyException
 	{
 		return true;
 	}
@@ -71,7 +82,7 @@
 	 * @param to		the new file. Ignored
 	 * @return true	always returns true without deleting the filee
 	 */
-	public boolean renameFile( File from, File to ) throws GatewayException
+	public boolean renameFile( File from, File to ) throws RemoteFileSystemStrategyException
 	{
 		return true;
 	}
@@ -93,7 +104,7 @@
 	 * Returns a File[] that only contains files that have not previously 
 	 * been through this method.
 	 */
-	public File[] filterFileList( File[] files ) throws GatewayException
+	public File[] filterFileList( File[] files ) throws RemoteFileSystemStrategyException
 	{
 		if ( files == null )
 			return files;
@@ -139,4 +150,16 @@
 		return ftpFileCache.getCacheListeners();
 	}
 
+	public void setCacheListener( Class cacheListenerClass ) throws RemoteFileSystemStrategyException 
+	{
+		try
+		{
+			ftpFileCache.setCacheListener( cacheListenerClass );
+		} 
+		catch (FtpFileCacheException e)
+		{
+			throw new RemoteFileSystemStrategyException( e );
+		}
+	}
+
 }

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/RemoteFileSystemStrategy.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/RemoteFileSystemStrategy.java	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/RemoteFileSystemStrategy.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -6,21 +6,26 @@
 /**
  * A strategy for handling remote write operations.
  * 
- * @author Daniel Bevenius				
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>				
  *
  */
 public interface RemoteFileSystemStrategy
 {
+	/**
+	 * Initialize this RemoteFileSystemStrategy
+	 * 
+	 * @param configFile
+	 * @throws Exception
+	 */
+	void init( String configFile ) throws RemoteFileSystemStrategyException;
 	
-	void init( String configFile ) throws Exception;
-	
 	/**
 	 * filters the file array passed in. 
 	 * 
 	 * @return	File[]	list of files that should worked on
 	 * @throws GatewayException
 	 */
-	File[] filterFileList( File[] files ) throws GatewayException;
+	File[] filterFileList( File[] files ) throws RemoteFileSystemStrategyException;
 	
 	/**
 	 * 
@@ -28,7 +33,7 @@
 	 * @return true	if the file was sucessfully deleted
 	 * @throws GatewayException
 	 */
-	boolean deleteFile( File file ) throws GatewayException;
+	boolean deleteFile( File file ) throws RemoteFileSystemStrategyException;
 	
 	/**
 	 * 
@@ -37,7 +42,7 @@
 	 * @return true	if the file was sucessfully renamed
 	 * @throws GatewayException
 	 */
-	boolean renameFile( File from, File to ) throws GatewayException;
+	boolean renameFile( File from, File to ) throws RemoteFileSystemStrategyException;
 	
 	/**
 	 * 
@@ -47,5 +52,12 @@
 	 * 					without.This depends on the implementation.
 	 */
 	File getWorkFileName( File file, String suffix );
+	
+	/**
+	 * Stop of clean upp anything that needs to be perforemed 
+	 * upon shutdown.
+	 *
+	 */
+	void stop();
 
 }

Added: labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/RemoteFileSystemStrategyException.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/RemoteFileSystemStrategyException.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/RemoteFileSystemStrategyException.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2006, JBoss Inc., and
+ * individual contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.remotestrategies;
+
+/**
+ * 
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>				
+ *
+ */
+public class RemoteFileSystemStrategyException extends Exception
+{
+
+	public RemoteFileSystemStrategyException()
+	{
+		super();
+	}
+
+	public RemoteFileSystemStrategyException(String message, Throwable cause)
+	{
+		super( message, cause );
+	}
+
+	public RemoteFileSystemStrategyException(String message)
+	{
+		super( message );
+	}
+
+	public RemoteFileSystemStrategyException(Throwable cause)
+	{
+		super( cause );
+	}
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+}

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListener.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListener.java	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListener.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -31,11 +31,13 @@
 /**
  * This listener will upon node eviction events delete the 
  * node from the cache. 
- * This listener should be used in combination with a cache loader 
- * so that it is possible to set an eviction policy and when nodes
+ * <p> 
+ * This listener should be used in combination with a cache loader <br>
+ * so that it is possible to set an eviction policy and when nodes <br>
  * are evicted they are also deleted from the cache loaders store
+ * </p>
  * 
- * @author Daniel Bevenius
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>				
  *
  */
 public class DeleteOnEvictTreeCacheListener implements TreeCacheListener
@@ -61,7 +63,7 @@
 	{
 		try
 		{
-			treeCache.removeData( fqn );
+			treeCache.remove( fqn );
 			log.debug( "removed fqn : " + fqn );
 		} 
 		catch (CacheException e)

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCache.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCache.java	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCache.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -6,6 +6,8 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Map;
 
 import org.apache.log4j.Logger;
@@ -13,11 +15,12 @@
 import org.jboss.cache.PropertyConfigurator;
 import org.jboss.cache.TreeCache;
 import org.jboss.cache.TreeCacheListener;
+import org.jboss.soa.esb.util.ClassUtil;
 
 /**
  * Implements a cache of file names which can be replicated in a cluster. 
  * 
- * @author Daniel Bevenius
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>				
  *
  */
 public class FtpFileCache
@@ -49,24 +52,31 @@
 	 * @param config	either an absolute path of a relative path
 	 * @throws Exception
 	 */
-	public FtpFileCache ( String config ) throws Exception
+	public FtpFileCache ( String config ) throws FtpFileCacheException
 	{
 		if ( config == null )
 			config = DEFAULT_CONFIG_FILE;
 		
 		this.config = config;
 		
-		treeCache = new TreeCache();
-		InputStream in = getConfigInputStream( this.config );
+		InputStream in = null;
 		try
 		{
+			treeCache = new TreeCache();
+			in = getConfigInputStream( this.config );
 			PropertyConfigurator configurator = new PropertyConfigurator();
 			configurator.configure( treeCache, in );
 		}
+		catch ( Exception e )
+		{
+			log.error( e );
+			throw new FtpFileCacheException ( e );
+		}
 		finally
 		{
 			close( in );
 		}
+			
 		
 	}
 	
@@ -101,7 +111,7 @@
 		else
 		{
 			log.debug("Reading jgroups configuration classpath : " + path );
-			in = getClass().getResourceAsStream( path );
+			in = ClassUtil.getResourceAsStream( path, getClass() );
 		}
 		return in;
 	}
@@ -110,9 +120,17 @@
 	 * Start the cache
 	 * @throws Exception
 	 */
-	public void start() throws Exception
+	public void start() throws FtpFileCacheException
 	{
-		treeCache.startService();
+		try
+		{
+			treeCache.startService();
+		} 
+		catch (Exception e)
+		{
+			log.error( e );
+			throw new FtpFileCacheException( e );
+		}
 	}
 	
 	/**
@@ -220,6 +238,52 @@
 		return treeCache.getTreeCacheListeners();
 	}
 	
+	public void setCacheListener( Class cacheListenerClass ) throws FtpFileCacheException
+	{
+		if ( cacheListenerClass == null )
+			return;
+		try
+		{
+			Constructor constructor = cacheListenerClass.getConstructor( TreeCache.class );
+			Object object = constructor.newInstance( treeCache );
+			if ( object instanceof TreeCacheListener )
+			{
+				TreeCacheListener listener = ( TreeCacheListener ) object;
+				treeCache.addTreeCacheListener( listener );
+			}
+		} 
+		catch (SecurityException e)
+		{
+			throw createFtpFileCacheException( e );
+		} 
+		catch (NoSuchMethodException e)
+		{
+			throw createFtpFileCacheException( e );
+		} 
+		catch (IllegalArgumentException e)
+		{
+			throw createFtpFileCacheException( e );
+		} 
+		catch (InstantiationException e)
+		{
+			throw createFtpFileCacheException( e );
+		} 
+		catch (IllegalAccessException e)
+		{
+			throw createFtpFileCacheException( e );
+		} 
+		catch (InvocationTargetException e)
+		{
+			throw createFtpFileCacheException( e );
+		}
+	}
+	
+	private FtpFileCacheException createFtpFileCacheException( Exception e )
+	{
+		log.error( e );
+		return new FtpFileCacheException( e );
+	}
+	
 	private void close( Closeable c )
 	{
 		if ( c == null )
@@ -235,5 +299,4 @@
 		}
 	}
 
-}
-
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheException.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheException.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheException.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2006, JBoss Inc., and
+ * individual contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.remotestrategies.cache;
+
+/**
+ * 
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>				
+ *
+ */
+public class FtpFileCacheException extends Exception
+{
+
+	public FtpFileCacheException()
+	{
+		super();
+	}
+
+	public FtpFileCacheException(String message, Throwable cause)
+	{
+		super( message, cause );
+	}
+
+	public FtpFileCacheException(String message)
+	{
+		super( message );
+	}
+
+	public FtpFileCacheException(Throwable cause)
+	{
+		super( cause );
+	}
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+}

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -36,7 +36,7 @@
 import org.jboss.soa.esb.listeners.config.FtpBusDocument.FtpBus;
 import org.jboss.soa.esb.listeners.config.FtpListenerDocument.FtpListener;
 import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
-import org.jboss.soa.esb.listeners.gateway.RemoteGatewayListener;
+import org.jboss.soa.esb.listeners.gateway.ReadOnlyRemoteGatewayListener;
 import org.junit.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -51,6 +51,7 @@
  */
 public class FtpListenerMapperTest
 {
+	@SuppressWarnings("unused")
 	private Logger log = Logger.getLogger(FtpListenerMapperTest.class);
 	
 	private static final String ESB_CONFIG_READ_ONLY = "jbossesb_config_readonly.xml";
@@ -80,13 +81,7 @@
 		NamedNodeMap attributes = ftpMapperListener.getAttributes();
 		Node gatewayClass = attributes.getNamedItem( GATEWAY_CLASS_ATTRIBUTE );
 		assertNotNull( "gatewayClass should have been set", gatewayClass );
-		log.debug( gatewayClass );
-		assertEquals( RemoteGatewayListener.class.getName(), gatewayClass.getNodeValue() );
-		
-		Node remoteStrategyClass = attributes.getNamedItem( RemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CLASS );
-		assertNotNull( RemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CLASS + " should have been set", 
-				remoteStrategyClass );
-		
+		assertEquals( ReadOnlyRemoteGatewayListener.class.getName(), gatewayClass.getNodeValue() );
 	}
 	
 	private XMLBeansModel getXmlBeanModel( String fileName ) throws ConfigurationException, IOException

Added: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerUnitTest.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -0,0 +1,323 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.gateway;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.JUnit4TestAdapter;
+
+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.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.couriers.CourierException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.gateway.remotestrategies.ReadOnlyRemoteFileSystemStrategy;
+import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.DeleteOnEvictTreeCacheListener;
+import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.FtpFileCacheTestUtil;
+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.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Unit test for ReadOnlyRemoteGatewayListener that uses an embedded ftp server.
+ * 
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>				
+ *
+ */
+public class ReadOnlyRemoteGatewayListenerUnitTest extends RemoteGatewayListenerUnitTest
+{
+	
+	@SuppressWarnings("unused")
+	private Logger log = Logger .getLogger( ReadOnlyRemoteGatewayListenerUnitTest.class );
+	
+	@BeforeClass
+	public static void classSetup() throws EmbeddableException, ConfigurationException, GatewayException, RegistryException, MalformedURLException
+	{
+		ftpServer = createFtpServer();
+		ftpServer.start();
+		
+		createWorkDirectories();
+		configTree = createConfigTree();
+		createRemoteGatewayListener( configTree );
+	}
+	
+	@Test
+	public void deleteFile() throws GatewayException 
+	{
+		File remoteFile = createAbsoluteFromFile();
+				
+		gatewayListener.deleteFile( remoteFile );
+		assertTrue( "Remote file was deleted which should not be possible!",  testFile.exists() );
+	}
+	
+	@Test
+	public void getFileListFromRemoteDir() throws GatewayException
+	{
+		File[] fileListFromRemoteDir = gatewayListener.getFileList();
+			
+		assertNotNull ( fileListFromRemoteDir );
+		assertTrue ( fileListFromRemoteDir.length > 0 );
+			
+		List<File> fileList = Arrays.asList( fileListFromRemoteDir );
+		assertTrue( "The test file was not included in the List! " , fileList.contains( new File ( testFile.getName() )  ));
+	}
+	
+	@Test ( timeout=3000 )
+	public void doRun_PostDir_Same_As_InputDir() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException
+	{
+		setAbsoluteInputDir();
+		setAbsolutePostDirToInputDir();
+		boolean getCourierReturnValue = true;
+		
+		RemoteGatewayListenerMock mock = createAndStartListener ( configTree,  getCourierReturnValue );
+		
+		File inputDir =  ftpServer.getLocalInputDir();
+		String doneFileName = testFile.getName();
+		
+		waitForFile( inputDir, doneFileName );
+		stopdoRun( mock );
+		
+		File processedFile = new File ( inputDir,  doneFileName );
+		try
+		{
+			assertTrue ( processedFile.exists() );
+		}
+		finally
+		{
+			FtpTestUtil.deleteFile( processedFile );
+		}
+	}
+	
+	/**
+	 * This is a "negtive" test. It verifies that the file was not
+	 * renamed. The name of the method is kept so that it overrides 
+	 * the super classes method.
+	 */
+	@Test
+	public void renameFile_In_Same_Directory() throws GatewayException 
+	{ 
+		File from = createAbsoluteFromFile();
+		File to = createAbsoluteToFile();
+			
+		gatewayListener.renameFile( from, to );
+			
+		renamedFile = new File ( ftpServer.getLocalInputDir(), to.getName() );
+		assertFileExists( testFile );
+		assertFalse( renamedFile.exists() );
+	}
+	
+	@Test 
+	public void getNewInstanceNegative() 
+	{
+		ReadOnlyRemoteGatewayListener listener = (ReadOnlyRemoteGatewayListener) gatewayListener;
+		try
+		{
+			listener.getNewInstanceOf( null );
+			fail ( "an IllegalArgumentException should have been thrown" );
+		} 
+		catch ( Exception e)
+		{
+			assertTrue ( e instanceof IllegalArgumentException );
+		}
+		
+		try
+		{
+			listener.getNewInstanceOf( "some.package.class" );
+			fail ( "a ConfigurationException should have been thrown" );
+		} 
+		catch ( Exception e)
+		{
+			assertTrue ( e instanceof ConfigurationException );
+		}
+	}
+	
+	@Test 
+	public void getNewInstance() throws ConfigurationException
+	{
+		ReadOnlyRemoteGatewayListener listener = (ReadOnlyRemoteGatewayListener) gatewayListener;
+		ReadOnlyRemoteFileSystemStrategy instance = listener.getNewInstanceOf( ReadOnlyRemoteFileSystemStrategy.class.getName() );
+		assertNotNull( "The instance should not be null!", instance );
+	}
+	
+	/**
+	 * Not a valid test for this impl
+	 */
+	@Override
+	public void renameFile_In_Different_Directory() throws GatewayException { }
+	
+	/**
+	 * Not a valid test for this impl
+	 */
+	@Override
+	public void doRun_PostDir_Different_From_InputDir() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException { }
+	
+	/**
+	 * Not a valid test for this impl
+	 */
+	@Override
+	public void doRun_Negative() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException {}
+	
+	/**
+	 * Override createConfigTree and add the ReadOnlyFileSystem strategy.
+	 * 
+	 * @return
+	 */
+	public static ConfigTree createConfigTree()
+	{
+		ConfigTree configTree = RemoteGatewayListenerUnitTest.createConfigTree();
+		configTree.setAttribute( ReadOnlyRemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CLASS, ReadOnlyRemoteFileSystemStrategy.class.getName() );
+		configTree.setAttribute( ReadOnlyRemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE, FtpFileCacheTestUtil.getCacheConfigFile() );
+		configTree.setAttribute( ReadOnlyRemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CACHE_LISTENER, DeleteOnEvictTreeCacheListener.class.getName() );
+		return configTree;
+	}
+	
+	protected static void createRemoteGatewayListener( ConfigTree configTree )
+	throws ConfigurationException, RegistryException, GatewayException
+	{
+		gatewayListener = new ReadOnlyRemoteGatewayListener( configTree );
+	}
+	
+	/**
+	 * Creates a RemoteGatewayListenerMock instance with the passed in arguments, and then starts
+	 * the ReadOnlyRemoteGatewayListener's doRun() method in a new Thread.
+	 * 
+	 * @param configTree The configTree to use to configure the RemoteGatewayListenerMock object
+	 * @param returnValueForCourier	the return value for the getCourier method of the RemoteGatewayListenerMock object
+	 * @return RemoteGatewayListenerMock Mock impl of a RemoteGatewayListener.
+	 */
+	protected 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;
+		
+	}
+	
+	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
+		{
+			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;
+		}
+	}
+	
+	/*
+	 * Just here to help Ant to find annotated test.
+	 */
+	public static junit.framework.Test suite()
+	{
+		return new JUnit4TestAdapter( ReadOnlyRemoteGatewayListenerUnitTest.class);
+	}
+	
+}

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerUnitTest.java	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListenerUnitTest.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -46,8 +46,6 @@
 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.gateway.RemoteGatewayListener.DefaultRemoteFileSystemStrategy;
-import org.jboss.soa.esb.listeners.gateway.remotestrategies.RemoteFileSystemStrategy;
 import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
 import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleThreadState;
 import org.jboss.soa.esb.message.Message;
@@ -99,7 +97,7 @@
 	private static final String POST_DEL = "false";
 	private static final String RENAMED_SUFFIX = ".renamed";
 	
-	private static final String TEST_FILE_CONTENT = RemoteGatewayListenerUnitTest.class.getName() + " junit ftp test";
+	protected static final String TEST_FILE_CONTENT = RemoteGatewayListenerUnitTest.class.getName() + " junit ftp test";
 
 	protected File testFile;
 
@@ -235,7 +233,7 @@
 	
 	/**
 	 *  This test will assert that the work file is renamed into the error directory.
-	 * Test with the following configuration:
+	 *  Test with the following configuration:
 	 *	postDir="/input" 
 	 *	errorDir="/error" 
 	 *
@@ -320,42 +318,8 @@
 		byte[] fileContents = gatewayListener.getFileContents( remoteFileName );
 			
 		assertEquals( TEST_FILE_CONTENT, new String ( fileContents ) );
-		assertTrue( "The remote file should not have been removed.",  testFile.exists() );
 	}
 	
-	@Test
-	public void testRemoteFileSystemStrategy() throws ConfigurationException, GatewayException, RegistryException
-	{
-		final RemoteGatewayListenerMock mock = new RemoteGatewayListenerMock( configTree , false );
-		log.debug( configTree );
-		RemoteFileSystemStrategy remoteFileSystemStrategy = mock.getRemoteFileSystemStrategy();
-		assertTrue ( remoteFileSystemStrategy instanceof DefaultRemoteFileSystemStrategy );
-	}
-	
-	@Test 
-	public void getNewInstanceNegative() 
-	{
-		try
-		{
-			gatewayListener.getNewInstanceOf( null );
-			fail ( "an IllegalArgumentException should have been thrown" );
-		} 
-		catch ( Exception e)
-		{
-			assertTrue ( e instanceof IllegalArgumentException );
-		}
-		
-		try
-		{
-			gatewayListener.getNewInstanceOf( "some.package.class" );
-			fail ( "a ConfigurationException should have been thrown" );
-		} 
-		catch ( Exception e)
-		{
-			assertTrue ( e instanceof ConfigurationException );
-		}
-	}
-	
 	/*
 	 * Will create a configTree that looks like the following:
 	 *  <junitRemoteGatewayListenerTest 
@@ -435,7 +399,7 @@
 	 * @param returnValueForCourier					the return value for the getCourier method of the RemoteGatewayListenerMock object
 	 * @return RemoteGatewayListenerMock		Mock impl of a RemoteGatewayListener.
 	 */
-	protected RemoteGatewayListenerMock createAndStartListener ( ConfigTree configTree,  boolean returnValueForCourier ) throws ConfigurationException, GatewayException, RegistryException
+	private RemoteGatewayListenerMock createAndStartListener ( ConfigTree configTree,  boolean returnValueForCourier ) throws ConfigurationException, GatewayException, RegistryException
 	{
 		final RemoteGatewayListenerMock mock = new RemoteGatewayListenerMock( configTree , returnValueForCourier );
 		mock.doInitialise();
@@ -452,7 +416,7 @@
 		
 	}
 	
-	protected void stopdoRun ( RemoteGatewayListenerMock mock )
+	private void stopdoRun ( RemoteGatewayListenerMock mock )
 	{
 		if ( mock == null ) return;
 		try 
@@ -574,11 +538,6 @@
 			return super.waitForRunningStateChange( state, terminationPeriod );
 		}
 		
-		public RemoteFileSystemStrategy getRemoteFileSystemStrategy()
-		{
-			return this.remotefileSystemStrategy;
-		}
-
 		public boolean hasFinishedOneRun()
 		{
 			return finishedOneRun;

Deleted: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -1,207 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated 
- * by the @authors tag. All rights reserved. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-package org.jboss.soa.esb.listeners.gateway;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.JUnit4TestAdapter;
-
-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.util.embedded.ftp.NoConfigFileFtpServer;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.gateway.remotestrategies.ReadOnlyRemoteFileSystemStrategy;
-import org.jboss.soa.esb.listeners.gateway.remotestrategies.RemoteFileSystemStrategy;
-import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.FtpFileCacheTestUtil;
-import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Unit test for RemoteGatewayListener that uses an embedded ftp server.
- * 
- * Tests the RemoteGatewayListener with a readonly RemoteFileSystemStrategy.
- * 
- * @author Daniel Bevenius
- *
- */
-public class RemoteGatewayListener_ReadOnlyStrategyUnitTest extends RemoteGatewayListenerUnitTest
-{
-	@SuppressWarnings("unused")
-	private Logger log = Logger .getLogger( RemoteGatewayListener_ReadOnlyStrategyUnitTest.class );
-	
-	@BeforeClass
-	public static void classSetup() throws EmbeddableException, ConfigurationException, GatewayException, RegistryException, MalformedURLException
-	{
-		ftpServer = createFtpServer();
-		ftpServer.start();
-		
-		createWorkDirectories();
-		configTree = createConfigTree();
-		createRemoteGatewayListener( configTree );
-	}
-	
-	@Test
-	public void deleteFile() throws GatewayException 
-	{
-		File remoteFile = createAbsoluteFromFile();
-				
-		gatewayListener.deleteFile( remoteFile );
-		assertTrue( "Remote file was deleted which should not be possible!",  testFile.exists() );
-	}
-	
-	@Test
-	public void getFileListFromRemoteDir() throws GatewayException
-	{
-		File[] fileListFromRemoteDir = gatewayListener.getFileList();
-			
-		assertNotNull ( fileListFromRemoteDir );
-		assertTrue ( fileListFromRemoteDir.length > 0 );
-			
-		List<File> fileList = Arrays.asList( fileListFromRemoteDir );
-		assertTrue( "The test file was not included in the List! " , fileList.contains( new File ( testFile.getName() )  ));
-	}
-	
-	@Test ( timeout=3000 )
-	public void doRun_PostDir_Same_As_InputDir() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException
-	{
-		setAbsoluteInputDir();
-		setAbsolutePostDirToInputDir();
-		boolean getCourierReturnValue = true;
-		
-		RemoteGatewayListenerMock mock = createAndStartListener ( configTree,  getCourierReturnValue );
-		
-		File inputDir =  ftpServer.getLocalInputDir();
-		String doneFileName = testFile.getName();
-		
-		waitForFile( inputDir, doneFileName );
-		stopdoRun( mock );
-		
-		File processedFile = new File ( inputDir,  doneFileName );
-		try
-		{
-			assertTrue ( processedFile.exists() );
-		}
-		finally
-		{
-			FtpTestUtil.deleteFile( processedFile );
-		}
-	}
-	
-	@Test
-	public void testRemoteFileSystemStrategy() throws ConfigurationException, GatewayException, RegistryException
-	{
-		final RemoteGatewayListenerMock mock = new RemoteGatewayListenerMock( configTree , false );
-		
-		RemoteFileSystemStrategy remoteFileSystemStrategy = mock.getRemoteFileSystemStrategy();
-		assertTrue ( remoteFileSystemStrategy instanceof ReadOnlyRemoteFileSystemStrategy );
-		
-		ReadOnlyRemoteFileSystemStrategy roStrategy = (ReadOnlyRemoteFileSystemStrategy) remoteFileSystemStrategy;
-		Map cacheListeners = roStrategy.getCacheListeners();
-		assertTrue ( cacheListeners.size() > 1 );
-		assertTrue ( "Should always return true", remoteFileSystemStrategy.deleteFile( null  ));
-		assertTrue ( "Should always return true", remoteFileSystemStrategy.renameFile(  null, null  ));
-	}
-	
-	/**
-	 * This is a "negtive" test. It verifies that the file was not
-	 * renamed. The name of the method is kept so that it overrides 
-	 * the super classes method.
-	 */
-	@Test
-	public void renameFile_In_Same_Directory() throws GatewayException 
-	{ 
-		File from = createAbsoluteFromFile();
-		File to = createAbsoluteToFile();
-			
-		gatewayListener.renameFile( from, to );
-			
-		renamedFile = new File ( ftpServer.getLocalInputDir(), to.getName() );
-		assertFileExists( testFile );
-		assertFalse( renamedFile.exists() );
-	}
-	
-	@Test 
-	public void getNewInstance() throws ConfigurationException
-	{
-		ReadOnlyRemoteFileSystemStrategy instance = gatewayListener.getNewInstanceOf( ReadOnlyRemoteFileSystemStrategy.class.getName() );
-		assertNotNull( "The instance should not be null!", instance );
-	}
-	
-	/**
-	 * Not a valid test for this impl
-	 */
-	@Override
-	public void renameFile_In_Different_Directory() throws GatewayException { }
-	
-	/**
-	 * Not a valid test for this impl
-	 */
-	@Override
-	public void doRun_PostDir_Different_From_InputDir() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException { }
-	
-	/**
-	 * Not a valid test for this impl
-	 */
-	@Override
-	public void doRun_Negative() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException {}
-	
-	/**
-	 * Override createConfigTree and add the ReadOnlyFileSystem strategy.
-	 * 
-	 * @return
-	 */
-	public static ConfigTree createConfigTree()
-	{
-		ConfigTree configTree = RemoteGatewayListenerUnitTest.createConfigTree();
-		configTree.setAttribute( RemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CLASS, ReadOnlyRemoteFileSystemStrategy.class.getName() );
-		configTree.setAttribute( RemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE, FtpFileCacheTestUtil.getCacheConfigFile() );
-		configTree.setAttribute( RemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CACHE_LISTENER, String.valueOf( true ) );
-		return configTree;
-	}
-	
-	public static NoConfigFileFtpServer createFtpServer()
-	{
-		ftpServer = new NoConfigFileFtpServer();
-		ftpServer.setPort( 2221 );
-		return ftpServer;
-	}
-	
-	/*
-	 * Just here to help Ant to find annotated test.
-	 */
-	public static junit.framework.Test suite()
-	{
-		return new JUnit4TestAdapter( RemoteGatewayListener_ReadOnlyStrategyUnitTest.class);
-	}
-	
-}

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyUnitTest.java	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyUnitTest.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -8,7 +8,6 @@
 
 import org.apache.log4j.Logger;
 import org.jboss.cache.CacheException;
-import org.jboss.soa.esb.listeners.gateway.GatewayException;
 import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.FtpFileCacheTestUtil;
 import org.jboss.soa.esb.testutils.HsqldbUtil;
 import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
@@ -19,7 +18,7 @@
 
 /**
  * 
- * @author Daniel Bevenius				
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>				
  *
  */
 public class ReadOnlyRemoteFileSystemStrategyUnitTest
@@ -45,14 +44,14 @@
 		{
 			strategy.filterFileList( null );
 		} 
-		catch (GatewayException e)
+		catch (RemoteFileSystemStrategyException e)
 		{
 			fail("Should be ok to pass null as the file array!");
 		}
 	}
 	
 	@Test
-	public void listFiles() throws GatewayException 
+	public void listFiles() throws RemoteFileSystemStrategyException 
 	{
 		File[] filteredFileList = strategy.filterFileList( expectedFileList );
 		assertEquals( expectedFileList, filteredFileList );

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTestUtil.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTestUtil.java	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTestUtil.java	2007-06-11 18:14:26 UTC (rev 12458)
@@ -34,7 +34,6 @@
 /**
  * Simple helper class with util method for getting a cache config
  * file.
- * Only created this to save duplicating the getCacheConfigFile method.
  * 
  * @author Daniel Bevenius				
  *

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/ftpfile_cache_test.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/ftpfile_cache_test.xml	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/ftpfile_cache_test.xml	2007-06-11 18:14:26 UTC (rev 12458)
@@ -50,7 +50,7 @@
                 <FD_SOCK/>
                 <VERIFY_SUSPECT timeout="1500" up_thread="false" down_thread="false"/>
                 <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800" max_xmit_size="8192" up_thread="false" down_thread="false"/>
-                <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10" down_thread="false"/>
+                <UNICAST timeout="600,1200,2400" down_thread="false"/>
                 <pbcast.STABLE desired_avg_gossip="20000" up_thread="false" down_thread="false"/>
                 <FRAG frag_size="8192" down_thread="false" up_thread="false"/>
                 <pbcast.GMS join_timeout="5000" join_retry_timeout="2000" shun="true" print_local_addr="true"/>

Modified: labs/jbossesb/workspace/dbevenius/product/docs/ProgrammersGuide.odt
===================================================================
(Binary files differ)

Modified: labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/build.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/build.xml	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/build.xml	2007-06-11 18:14:26 UTC (rev 12458)
@@ -4,6 +4,8 @@
 		${ant.project.name}
 		${line.separator}
 	</description>
+
+	<property name="additional.deploys" value="ftpfile-cache-config.xml,lib/cache.jar,lib/jgroups.jar"/>
 	
 	<import file="../conf/base-build.xml"/>
   
@@ -55,6 +57,20 @@
 			<param name="esb.config.file" value="${readonly.esb.config.file}"/>
 		</antcall>
 	</target>
+
+	<target name="deploy-readonly" description="deploy the readonly version">
+		<copy file="ftpfile-cache-config.xml" todir="${basedir}/classes"/>
+        <property name="readonly.mode" value="true"/>
+
+        <antcall target="filter_jboss-esb.xml">
+            <param name="file.name" value="${basedir}/jboss-esb-readonly-unfiltered.xml"/>
+            <param name="to.file.name" value="${basedir}/jboss-esb.xml"/>
+        </antcall>
+
+        <antcall target="deploy"/>
+
+	</target>
+
 	
 	
 	<target name="filter_jboss-esb.xml">

Modified: labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/ftpfile-cache-config.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/ftpfile-cache-config.xml	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/ftpfile-cache-config.xml	2007-06-11 18:14:26 UTC (rev 12458)
@@ -1,22 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--
-	This file is a copy of the one in core/listeners/test/resources/etc and only here
-	to test the ability to specify a configuration file relative to the classes classpath.
--->
 <server>
 
-    <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
-
     <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache">
 
         <depends>jboss:service=Naming</depends>
         <depends>jboss:service=TransactionManager</depends>
 
-        <!-- Configure the TransactionManager -->
+        <!-- Configure the TransactionManager 
         <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute>
+		-->
 
         <!-- Isolation level : SERIALIZABLE REPEATABLE_READ (default) READ_COMMITTED READ_UNCOMMITTED NONE -->
-        <!--attribute name="IsolationLevel">REPEATABLE_READ</attribute-->
         <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
 
         <!-- Valid modes are LOCAL, REPL_ASYNC and REPL_SYNC -->
@@ -46,11 +40,10 @@
                     loopback="false"/>
                 <PING timeout="2000" num_initial_members="2" up_thread="false" down_thread="false"/>
                 <MERGE2 min_interval="10000" max_interval="20000"/>
-                <!--        <FD shun="true" up_thread="true" down_thread="true" />-->
                 <FD_SOCK/>
                 <VERIFY_SUSPECT timeout="1500" up_thread="false" down_thread="false"/>
                 <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800" max_xmit_size="8192" up_thread="false" down_thread="false"/>
-                <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10" down_thread="false"/>
+                <UNICAST timeout="600,1200,2400" down_thread="false"/>
                 <pbcast.STABLE desired_avg_gossip="20000" up_thread="false" down_thread="false"/>
                 <FRAG frag_size="8192" down_thread="false" up_thread="false"/>
                 <pbcast.GMS join_timeout="5000" join_retry_timeout="2000" shun="true" print_local_addr="true"/>
@@ -81,7 +74,7 @@
         <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
 		<attribute name="EvictionPolicyConfig">
 			<config>
-				<attribute name="wakeUpIntervalSeconds">5</attribute>
+				<attribute name="wakeUpIntervalSeconds">60</attribute>
 				<!-- Cache wide default -->
 				<region name="/_default_">
 				<attribute name="maxNodes">5000</attribute>
@@ -89,8 +82,8 @@
 				</region>
 				<region name="/ftp/cache">
 					<attribute name="maxNodes">5000</attribute>
-					<attribute name="timeToLiveSeconds">20</attribute>
-					<attribute name="maxAgeSeconds">20</attribute>
+					<attribute name="timeToLiveSeconds">60</attribute>
+					<attribute name="maxAgeSeconds">60</attribute>
 		      </region>
 		   </config>
 		</attribute>
@@ -102,7 +95,6 @@
 				
 				<!-- comma delimited FQNs to preload -->
 				<preload>/ftp/cache</preload>
-				
 				<!-- are the cache loaders shared in a cluster? -->
 				<shared>false</shared>
 				
@@ -135,12 +127,4 @@
         
     </mbean>
 
-
-   <!--  Uncomment to get a graphical view of the TreeCache MBean above -->
-   <!--   <mbean code="org.jboss.cache.TreeCacheView" name="jboss.cache:service=TreeCacheView">-->
-   <!--      <depends>jboss.cache:service=TreeCache</depends>-->
-   <!--      <attribute name="CacheService">jboss.cache:service=TreeCache</attribute>-->
-   <!--   </mbean>-->
-
-
 </server>

Modified: labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/jboss-esb-readonly-unfiltered.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/jboss-esb-readonly-unfiltered.xml	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/jboss-esb-readonly-unfiltered.xml	2007-06-11 18:14:26 UTC (rev 12458)
@@ -48,8 +48,8 @@
             		maxThreads="1"
             		is-gateway="true">
             		<property name="pollLatencySeconds" value="5"/> 
-            		<property name="remoteFileSystemStrategy-configFile" value="./ftpfile-cache-config.xml"/> 
-            		<property name="remoteFileSystemStrategy-deleteOnEviction" value="true"/> 
+            		<property name="remoteFileSystemStrategy-configFile" value="/ftpfile-cache-config.xml"/> 
+            		<property name="remoteFileSystemStrategy-cacheListener" value="org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.DeleteOnEvictTreeCacheListener"/> 
             	</ftp-listener>
                 <jms-listener name="helloWorldFileAction"
                               busidref="quickstartEsbChannel"

Modified: labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/readme.txt
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/readme.txt	2007-06-11 17:49:09 UTC (rev 12457)
+++ labs/jbossesb/workspace/dbevenius/product/samples/quickstarts/helloworld_ftp_action/readme.txt	2007-06-11 18:14:26 UTC (rev 12458)
@@ -2,7 +2,7 @@
 =========
   	This is a very basic example that demonstrates how to configure the FTP gateway
  	so that it picks up messages from an ftp server, routes them through a JMS queue
- 	and finally to your action class for processing.
+ 	and finally to your action class for processing. 
 
 Running this quickstart:
 ========================
@@ -12,11 +12,11 @@
 Before Running:
 ===============
     1.  Make sure the you have set the jboss.ftp properties in either install/deployment.properties
-		or in sample/quickstarts/conf/quickstarts.properties.
+		or in samples/quickstarts/conf/quickstarts.properties.
 	2.  Make sure you have read/write access to an FTP server.  Write access is required
 		so that a file can be marked as "completed" (or just deleted) and not reprocessed 
-		again and again.
-    3.  In a command terminal window in the quickstart folder type 'ant deploy-jms-queues'.
+		again and again. Write access is not needed for the read-only version.
+    3.  In a command terminal window in the quickstart folder type 'ant deploy-jms-dests'.
 
 To Run standalone mode:
 =======================
@@ -30,12 +30,12 @@
     1.  In a command terminal window in this folder ("Window1"), type 'ant run-readonly'.
     1.  In another command terminal window in this folder ("Window2"), type 'ant run-readonly'.
     2.  Open another command terminal window in this folder ("Window3"), type 'ant runtest'.
-    3.  You should see the file contents displayed in the one of the listener windows
+    3.  You should see the file contents displayed in the one of the listener windows.
 		Log onto the ftpserver and see that the file has not been renamed.
 	4.  Examine the jboss-esb-readonly-unfiltered.xml file and specifically this ftp-listener
 		section:
 			<property name="remoteFileSystemStrategy-configFile" value="./ftpfile-cache-config.xml"/>
-			<property name="remoteFileSystemStrategy-deleteOnEviction" value="true"/>
+			<property name="remoteFileSystemStrategy-cacheListener" value="org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.DeleteOnEvictTreeCacheListener"/> 
 		Setting the deleteOnEviction to true will cause the file name to be deleted from the 
 		cacheloader. You can set the eviction time in ftpfile-cache-config.xml:
 			<region name="/ftp/cache">
@@ -50,17 +50,35 @@
 
 What to consider in this Quickstart:
 ===================================	
-1) The FTP configuration has been initialised in ../conf/quickstarts.properties
+	1) The FTP configuration has been initialised in ../conf/quickstarts.properties
 
-2) The FTP directory is accessable and can be written to as the "in process"
-and "completed" files are renamed accordingly. 
+	2) The FTP directory is accessable and can be written to as the "in process"
+	and "completed" files are renamed accordingly. 
 	
-If you do not have write access you will receive an error that looks something like the 
-following:
-     [java] 20:41:36,625 ERROR [Thread-5][AbstractFileGateway] Problems renaming
- file new_file.dat to new_file.dat.esbWorking
+	If you do not have write access you will receive an error that looks something like the 
+	following:
+		 [java] 20:41:36,625 ERROR [Thread-5][AbstractFileGateway] Problems renaming
+	 file new_file.dat to new_file.dat.esbWorking
 
-3) Running the read-only version: note that the cacheloader used is hypersonic and 
-it is an inmemory database. This means that if you close all the ESBs running('ant run-readonly' windows
-all files will be retrieved once more. This would not be the case with a persistent database.
+	3) Running the read-only version: 
+	Note that the cacheloader used is hypersonic and it is an inmemory database. This means that if 
+	you close all the ESBs running('ant run-readonly' windows all files will be retrieved once 
+	more. This would not be the case with a persistent database.
 
+Project file descriptions:
+==========================
+
+    jboss-esb-unfiltered.xml:
+	The jboss-esb configuration file before it is filtered by Ant to add the proper values for the
+	remote ftp server. Ant will generate a file name jboss-esb.xml.
+
+    jboss-esb-readonly-unfiltered.xml:
+	Same as the file above but configured for a readonly ftp server. Ant will generate an file named
+	jboss-esb-XX.xml. The reason for this is that if two standalone instances of the ESB are started 
+	in the same directory and use the same config file they will interfere with each other on startup. 
+	The one already started will think that it file as changed. Just run 'ant clean' to get rid of all
+	the generated files.
+
+	ftpfile-cache-config.xml
+	JBossTreeCache configuration file used with the readonly version.	
+




More information about the jboss-svn-commits mailing list