[jboss-svn-commits] JBL Code SVN: r23642 - in labs/jbossesb/workspace/skeagh: api/src/main/java/org/jboss/esb/api/message and 35 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Oct 31 03:45:16 EDT 2008


Author: beve
Date: 2008-10-31 03:45:16 -0400 (Fri, 31 Oct 2008)
New Revision: 23642

Added:
   labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/exception/ConfigurationException.java
   labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/message/MessageComposer.java
   labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java
   labs/jbossesb/workspace/skeagh/examples/file-router/
   labs/jbossesb/workspace/skeagh/examples/file-router/README.TXT
   labs/jbossesb/workspace/skeagh/examples/file-router/activemq.xml
   labs/jbossesb/workspace/skeagh/examples/file-router/config.properties
   labs/jbossesb/workspace/skeagh/examples/file-router/pom.xml
   labs/jbossesb/workspace/skeagh/examples/file-router/run.bat
   labs/jbossesb/workspace/skeagh/examples/file-router/src/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/org/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/org/jboss/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/org/jboss/esb/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/org/jboss/esb/examples/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/org/jboss/esb/examples/helloworld/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/org/jboss/esb/examples/inboundrouter/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/org/jboss/esb/examples/inboundrouter/file/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/org/jboss/esb/examples/inboundrouter/file/MyTestService.java
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/resources/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/resources/jboss-esb.xml
   labs/jbossesb/workspace/skeagh/examples/file-router/src/main/resources/jndi.properties
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/java/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/java/org/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/java/org/jboss/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/java/org/jboss/esb/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/java/org/jboss/esb/examples/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/java/org/jboss/esb/examples/helloworld/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/java/org/jboss/esb/examples/helloworld/jboss-esb.xml
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/META-INF/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/META-INF/jbossesb/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/META-INF/jbossesb/busconfig/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/META-INF/jbossesb/busconfig/jms/
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/log4j.xml
   labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/sample.txt
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/FileInboundRouter.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/AbstractFileMessageComposer.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileBytesMessageComposer.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileReaderMessageComposer.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileStreamMessageComposer.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileStringMessageComposer.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/package.html
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/AlphabeticFileComparator.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/FileSelector.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/WildcardFileFilter.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/WildcardFileSelector.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/package.html
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycle.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycleFactory.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycle.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycleConfig.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycleFactory.java
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/package.html
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/package.html
   labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/FileInboundRouterTest.java
   labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/MyTestService.java
   labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/file-inbound-router_01.xml
   labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/lifecycle/
   labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycleTest.java
   labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/lifecycle/FileLifecycleTest.java
Removed:
   labs/jbossesb/workspace/skeagh/routing/file/osgi.bnd
   labs/jbossesb/workspace/skeagh/routing/file/src/main/java/overview.html
Modified:
   labs/jbossesb/workspace/skeagh/container/osgi/pom.xml
   labs/jbossesb/workspace/skeagh/examples/pom.xml
   labs/jbossesb/workspace/skeagh/routing/file/pom.xml
   labs/jbossesb/workspace/skeagh/routing/pom.xml
Log:
InboundFileRouter. Still needs work but the example is working.


Added: labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/exception/ConfigurationException.java
===================================================================
--- labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/exception/ConfigurationException.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/exception/ConfigurationException.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors 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.esb.api.exception;
+
+/**
+ * This class indicates a configuration error in the ESB.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class ConfigurationException extends JBossESBException
+{
+    /**
+     * Serial UID.
+     */
+    private static final long serialVersionUID = -7185737242522493682L;
+
+    /**
+     * Constructs an Exception instance by delegating to {@link JBossESBException}.
+     *
+     * @param message The error message.
+     * @param cause The cause of the exeption.
+     */
+    public ConfigurationException(final String message, final Throwable cause)
+    {
+        super(message, cause);
+
+    }
+
+    /**
+     * Constructs an Exception instance by delegating to {@link JBossESBException}.
+     * @param message The error message.
+     */
+    public ConfigurationException(final String message)
+    {
+        super(message);
+
+    }
+}

Added: labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/message/MessageComposer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/message/MessageComposer.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/message/MessageComposer.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors 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.esb.api.message;
+
+import java.util.Properties;
+
+import org.jboss.esb.api.context.InvocationContext;
+
+/**
+ * MessageComposer composes/decomposes ESB Messages
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ * @param <T>
+ */
+public interface MessageComposer<T>
+{
+    /**
+     * Composes/creates a Message object instance using the information from the
+     * passed in type T.
+     *
+     * @param t The class parameter
+     * @param invocationContext The invocation context.
+     * @return Message An ESB Message object that contains the files contents as its payload.
+     * @throws MessageProcessingException If an error occurs while trying to create the Message object.
+     */
+    Message compose(final T t, final InvocationContext invocationContext) throws MessageProcessingException;
+
+    /**
+     * Decompose can be used for operations like cleanup of anything that is needed to
+     * be performed after the message has been processed.
+     *
+     * @param message The ESB message object instance.
+     * @param t The class parameter
+     * @return Object Any Object.
+     *
+     * @throws MessageProcessingException If an error occurs while decomposeing.
+     */
+    Object decompose(final Message message, final T t) throws MessageProcessingException;
+
+    /**
+     * Allows a MessageComposer implementation receive configuration information.
+     *
+     * @param properties The properties.
+     */
+    void setConfiguration(final Properties properties);
+
+}

Added: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,269 @@
+/*
+ * 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.esb.util;
+
+import org.apache.log4j.Logger;
+
+import java.io.*;
+import java.util.UUID;
+
+/**
+ * Common file utility functions.
+ * @author kevin
+ */
+public class FileUtil
+{
+    public static final String classInstanceUUID = UUID.randomUUID().toString();
+
+    /**
+     * The logger for this class.
+     */
+    private final static Logger LOGGER = Logger.getLogger(FileUtil.class) ;
+
+    /**
+     * Attempt to rename a file
+     * @param from The original file
+     * @param to The destination file.
+     * @return true if the rename succeeded, false otherwise
+     */
+    public static boolean renameTo(final File from, final File to)
+    {
+        AssertArgument.isNotNull(from, "from");
+        AssertArgument.isNotNull(to, "to");
+
+        if(!from.exists())
+        {
+            LOGGER.debug("Unable to rename file '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath() + "'.  '" + from.getAbsolutePath() + "' doesn't exist.");
+            return false;
+        }
+
+        if(to.exists()) {
+            LOGGER.debug("Unable to rename file '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath() + "'.  '" + to.getAbsolutePath() + "' already exist.");
+            return false;
+        }
+
+        if (!from.renameTo(to))
+        {
+            // The rename may have failed because it's really a file move that's being requested i.e.
+            // move the file to a different partition and the local VM doesn't supporting this
+            // in the rename. So we try moving the file...
+            return moveFile(from, to);
+        }
+
+        return true;
+    }
+
+    /**
+     * Moves a "from" file to a "to" file through copying of the file contents.
+     * <p/>
+     * This is not a file rename.
+     *
+     * @param from The source file.
+     * @param to The target file.
+     * @return True if the move was successful, otherwise false.
+     */
+    public static boolean moveFile(File from, File to)
+    {
+        AssertArgument.isNotNull(from, "from");
+        AssertArgument.isNotNull(to, "to");
+
+        if(!from.exists())
+        {
+            LOGGER.debug("Unable to move file '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath() + "'.  '" + from.getAbsolutePath() + "' doesn't exist.");
+            return false;
+        }
+
+        if(to.exists()) {
+            LOGGER.debug("Unable to move file '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath() + "'.  '" + to.getAbsolutePath() + "' already exist.");
+            return false;
+        }
+
+        // Before doing the copy, we perform a local rename of the from file.  This is to make
+        // sure that the file is not picked up by another processor while the copy is taking place.
+        // We prefix and postfix the UUID on the rename file, because we don't know the filter pattern being
+        // used by the processors on picking up these files.  This still doesn't guarantee that the rename file
+        // is not picked up too, but it is "stronger"!
+
+        File fromFileDir = from.getParentFile();
+        File fromLocalRename = new File(fromFileDir, classInstanceUUID + "." + from.getName() + "." + classInstanceUUID);
+
+        if(!from.renameTo(fromLocalRename))
+        {
+                LOGGER.debug("Unable to perform local rename of file '" + from.getAbsolutePath() + "' to '" + fromLocalRename.getAbsolutePath() + "'.  Unable to move file.");
+                return true;
+        }
+
+        if(!fromLocalRename.exists())
+        {
+            LOGGER.debug("Failed to perform local rename of file '" + from.getAbsolutePath() + "' to '" + fromLocalRename.getAbsolutePath() + "'.  Unable to move file.");
+            return true;
+        }
+
+        final File tmpFile ;
+        try
+        {
+            tmpFile = File.createTempFile("copy", ".tmp", to.getParentFile()) ;
+        }
+        catch (final IOException ioe)
+        {
+            LOGGER.debug("Could not create temporary file for writing", ioe) ;
+            return true;
+        }
+
+        try
+        {
+            copyFile(fromLocalRename, tmpFile) ;
+            if (!tmpFile.renameTo(to))
+            {
+                LOGGER.debug("Could not rename temporary file " + tmpFile.getAbsolutePath()) ;
+                return false ;
+            }
+            if(!fromLocalRename.delete()) {
+                LOGGER.debug("Failed to delete local rename file '" + fromLocalRename.getAbsolutePath() + "'.");
+                // This is not desireable, but shouldn't be fatal because the from file no longer exists
+                // and the to file has been successfully created.
+            }
+        }
+        finally
+        {
+            tmpFile.delete() ;
+        }
+
+        return true;
+    }
+
+    /**
+     * Attempt to copy the file.
+     * @param from The original file
+     * @param to The destination file.
+     */
+    private static boolean copyFile(final File from, final File to)
+    {
+        final FileInputStream fis;
+        try
+        {
+            fis = new FileInputStream(from);
+        }
+        catch (final IOException ioe)
+        {
+            LOGGER.debug("Could not open input file for reading", ioe) ;
+            return false ;
+        }
+        try
+        {
+            final FileOutputStream fos;
+            try
+            {
+                fos = new FileOutputStream(to);
+            }
+            catch (final IOException ioe)
+            {
+                LOGGER.debug("Could not open output file for writing", ioe);
+                return false ;
+            }
+
+            try
+            {
+                final long filesize = from.length();
+                final byte[] buffer = (filesize > 256 ? new byte[256]
+                                : new byte[(int) filesize]);
+                while (true)
+                {
+                    final int count = fis.read(buffer);
+                    if (count <= 0)
+                    {
+                        break;
+                    }
+                    fos.write(buffer, 0, count);
+                }
+            }
+            catch (final IOException ioe)
+            {
+                LOGGER.debug("Error copying file", ioe);
+                to.delete() ;
+                return false ;
+            }
+            finally
+            {
+                    try
+                    {
+                            fos.close();
+                    }
+                    catch (final IOException ioe) {} // ignore
+            }
+        }
+        finally
+        {
+            try
+            {
+                    fis.close();
+            }
+            catch (final IOException ioe) {} // ignore
+        }
+        return true ;
+    }
+
+    /**
+     * Read the file into a String.
+     * @param file - the file to be read
+     * @return String with the content of the file
+     * @throws IOException - when we can't read the file
+     */
+    public static String readTextFile(File file) throws IOException
+    {
+        StringBuffer sb = new StringBuffer(1024);
+        BufferedReader reader = new BufferedReader(new FileReader(file.getPath()));
+        char[] chars = new char[1];
+        while( (reader.read(chars)) > -1){
+            sb.append(String.valueOf(chars));
+            chars = new char[1];
+        }
+        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/workspace/skeagh/container/osgi/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/pom.xml	2008-10-31 07:35:07 UTC (rev 23641)
+++ labs/jbossesb/workspace/skeagh/container/osgi/pom.xml	2008-10-31 07:45:16 UTC (rev 23642)
@@ -40,6 +40,7 @@
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
+                        <Export-Package>org.jboss.esb.schedule</Export-Package>
                         <Private-Package>org.jboss.esb.osgi</Private-Package>
                         <Import-Package>org.jboss.esb.api.*, *;resolution:=optional</Import-Package> <!-- TODO: Replace global import with explicit package imports? -->
                         <Bundle-Activator>org.jboss.esb.osgi.EsbServiceDeploymentActivator</Bundle-Activator>

Added: labs/jbossesb/workspace/skeagh/examples/file-router/README.TXT
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/README.TXT	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/README.TXT	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,40 @@
+About This Example:
+===================
+     This example illustrates a simple JBossESB 5.0 File Router example.
+
+
+How to Run?
+===========
+     Requirements:
+        1.  JDK 1.5
+        2.  Maven 2.x (http://maven.apache.org/download.html)
+
+     Running:
+        1.  Run "mvn activemq:run". This starts the JMS Provider.
+        2.  Open a new console window ("Window 2")
+        3.  Run "mvn clean install pax:provision". This starts the OSGi container (Felix) and deploys the ESB.
+        4.  Open a new console window ("Window 3")
+        5.  Copy src/text/resources/sample.txt to target/input. This file will be picked up by the the ESB. 
+
+Things to try
+=============
+	JBossESB:
+	* Try updating the schedule in src/main/resources/jboss-esb.xml.
+	
+	Felix:
+	# Stop/Start bundle:
+	  At the felix commmand prompt ("Window 2"):
+	  >ps 			// will list all bundles
+	  >stop <id>	// use the id of the JBoss ESB - Helloworld Example (5.0.0.SNAPSHOT)
+	  >start <id> 	// use the id of the JBoss ESB - Helloworld Example (5.0.0.SNAPSHOT)
+	  Notice how the esb undeploy and deploys the bundle.
+
+	# Enable Felix logging:
+	  <properties>
+        <felix.log.level>1</felix.log.level><!-- 4=debug -->
+      </properties>
+
+	
+
+
+

Added: labs/jbossesb/workspace/skeagh/examples/file-router/activemq.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/activemq.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/activemq.xml	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,20 @@
+<beans
+        xmlns="http://www.springframework.org/schema/beans"
+        xmlns:amq="http://activemq.org/config/1.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.org/config/1.0 http://activemq.apache.org/schema/activemq-core.xsd
+  http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
+
+    <!-- Allows us to use system properties as variables in this configuration file -->
+    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+
+    <broker xmlns="http://activemq.org/config/1.0" useJmx="false"  dataDirectory="${activemq.base}/target/activemq">
+
+        <transportConnectors>
+            <transportConnector uri="tcp://localhost:61717"/>
+        </transportConnectors>
+
+    </broker>
+
+</beans>
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/examples/file-router/config.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/config.properties	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/config.properties	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,485 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#
+# Framework config properties.
+#
+org.osgi.framework.system.packages=org.osgi.framework; version=1.4.0, \
+ org.osgi.service.packageadmin; version=1.2.0, \
+ org.osgi.service.startlevel; version=1.1.0, \
+ org.osgi.service.url; version=1.0.0, \
+ org.osgi.util.tracker; version=1.3.3 \
+ ${jre-${java.specification.version}}
+
+m2.path=${user.home}/.m2/repository
+apache.m2.path=${m2.path}/org/apache
+jbossesb.m2.path=${m2.path}/jboss/jbossesb
+
+#org.osgi.framework.bootdelegation=sun.*,com.sun.*
+#felix.cache.profile=foo
+felix.auto.start.1= \
+ "file:${apache.m2.path}/felix/org.apache.felix.shell/1.0.2/org.apache.felix.shell-1.0.2.jar" \
+ "file:${apache.m2.path}/felix/org.apache.felix.shell.tui/1.0.2/org.apache.felix.shell.tui-1.0.2.jar" \
+ "file:${apache.m2.path}/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar" \
+ "file:${jbossesb.m2.path}/jbossesb-api/5.0-SNAPSHOT/jbossesb-api-5.0-SNAPSHOT.jar" \
+ "file:${jbossesb.m2.path}/jbossesb-osgi-runtime/5.0-SNAPSHOT/jbossesb-osgi-runtime-5.0-SNAPSHOT.jar" \
+ "file:${jbossesb.m2.path}/jbossesb-routing-jms/5.0-SNAPSHOT/jbossesb-routing-jms-5.0-SNAPSHOT.jar" \
+ "file:${jbossesb.m2.path}/jbossesb-examples-helloworld/5.0-SNAPSHOT/jbossesb-examples-helloworld-5.0-SNAPSHOT.jar"
+
+felix.log.level=1
+felix.startlevel.framework=1
+felix.startlevel.bundle=1
+#felix.service.urlhandlers=false
+
+#
+# Bundle config properties.
+#
+org.osgi.service.http.port=8080
+osgi.shell.telnet=on
+obr.repository.url=http://felix.apache.org/obr/releases.xml
+
+
+#
+# Java platform package export properties.
+#
+jre-1.3=, \
+ javax.accessibility; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ version="1.3.0"
+
+jre-1.4=, \
+ javax.accessibility; \
+ javax.crypto; \
+ javax.crypto.interfaces; \
+ javax.crypto.spec; \
+ javax.imageio; \
+ javax.imageio.event; \
+ javax.imageio.metadata; \
+ javax.imageio.plugins.jpeg; \
+ javax.imageio.spi; \
+ javax.imageio.stream; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.net; \
+ javax.net.ssl; \
+ javax.print; \
+ javax.print.attribute; \
+ javax.print.attribute.standard; \
+ javax.print.event; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.security.auth; \
+ javax.security.auth.callback; \
+ javax.security.auth.kerberos; \
+ javax.security.auth.login; \
+ javax.security.auth.spi; \
+ javax.security.auth.x500; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.sql; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ javax.transaction.xa; \
+ javax.xml.parsers; \
+ javax.xml.transform; \
+ javax.xml.transform.dom; \
+ javax.xml.transform.sax; \
+ javax.xml.transform.stream; \
+ org.ietf.jgss; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextExtPackage; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.Dynamic; \
+ org.omg.DynamicAny; \
+ org.omg.DynamicAny.DynAnyFactoryPackage; \
+ org.omg.DynamicAny.DynAnyPackage; \
+ org.omg.IOP; \
+ org.omg.IOP.CodecFactoryPackage; \
+ org.omg.IOP.CodecPackage; \
+ org.omg.Messaging; \
+ org.omg.PortableInterceptor; \
+ org.omg.PortableInterceptor.ORBInitInfoPackage; \
+ org.omg.PortableServer; \
+ org.omg.PortableServer.CurrentPackage; \
+ org.omg.PortableServer.POAManagerPackage; \
+ org.omg.PortableServer.POAPackage; \
+ org.omg.PortableServer.portable; \
+ org.omg.PortableServer.ServantLocatorPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ org.w3c.dom; \
+ org.w3c.dom.css; \
+ org.w3c.dom.events; \
+ org.w3c.dom.html; \
+ org.w3c.dom.stylesheets; \
+ org.w3c.dom.traversal; \
+ org.w3c.dom.views; \
+ org.xml.sax; \
+ org.xml.sax.ext; \
+ org.xml.sax.helpers; \
+ version="1.4.0"
+
+jre-1.5=, \
+ javax.accessibility; \
+ javax.activity; \
+ javax.crypto; \
+ javax.crypto.interfaces; \
+ javax.crypto.spec; \
+ javax.imageio; \
+ javax.imageio.event; \
+ javax.imageio.metadata; \
+ javax.imageio.plugins.bmp; \
+ javax.imageio.plugins.jpeg; \
+ javax.imageio.spi; \
+ javax.imageio.stream; \
+ javax.management; \
+ javax.management.loading; \
+ javax.management.modelmbean; \
+ javax.management.monitor; \
+ javax.management.openmbean; \
+ javax.management.relation; \
+ javax.management.remote; \
+ javax.management.remote.rmi; \
+ javax.management.timer; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.net; \
+ javax.net.ssl; \
+ javax.print; \
+ javax.print.attribute; \
+ javax.print.attribute.standard; \
+ javax.print.event; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.rmi.ssl; \
+ javax.security.auth; \
+ javax.security.auth.callback; \
+ javax.security.auth.kerberos; \
+ javax.security.auth.login; \
+ javax.security.auth.spi; \
+ javax.security.auth.x500; \
+ javax.security.sasl; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.sql; \
+ javax.sql.rowset; \
+ javax.sql.rowset.serial; \
+ javax.sql.rowset.spi; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.plaf.synth; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ javax.transaction.xa; \
+ javax.xml; \
+ javax.xml.datatype; \
+ javax.xml.namespace; \
+ javax.xml.parsers; \
+ javax.xml.transform; \
+ javax.xml.transform.dom; \
+ javax.xml.transform.sax; \
+ javax.xml.transform.stream; \
+ javax.xml.validation; \
+ javax.xml.xpath; \
+ org.ietf.jgss; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextExtPackage; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.Dynamic; \
+ org.omg.DynamicAny; \
+ org.omg.DynamicAny.DynAnyFactoryPackage; \
+ org.omg.DynamicAny.DynAnyPackage; \
+ org.omg.IOP; \
+ org.omg.IOP.CodecFactoryPackage; \
+ org.omg.IOP.CodecPackage; \
+ org.omg.Messaging; \
+ org.omg.PortableInterceptor; \
+ org.omg.PortableInterceptor.ORBInitInfoPackage; \
+ org.omg.PortableServer; \
+ org.omg.PortableServer.CurrentPackage; \
+ org.omg.PortableServer.POAManagerPackage; \
+ org.omg.PortableServer.POAPackage; \
+ org.omg.PortableServer.portable; \
+ org.omg.PortableServer.ServantLocatorPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ org.omg.stub.javax.management.remote.rmi; \
+ org.w3c.dom; \
+ org.w3c.dom.bootstrap; \
+ org.w3c.dom.css; \
+ org.w3c.dom.events; \
+ org.w3c.dom.html; \
+ org.w3c.dom.ls; \
+ org.w3c.dom.ranges; \
+ org.w3c.dom.stylesheets; \
+ org.w3c.dom.traversal; \
+ org.w3c.dom.views; \
+ org.xml.sax; \
+ org.xml.sax.ext; \
+ org.xml.sax.helpers; \
+ version="1.5.0"
+
+jre-1.6=, \
+ javax.accessibility; \
+ javax.activation; \
+ javax.activity; \
+ javax.annotation; \
+ javax.annotation.processing; \
+ javax.crypto; \
+ javax.crypto.interfaces; \
+ javax.crypto.spec; \
+ javax.imageio; \
+ javax.imageio.event; \
+ javax.imageio.metadata; \
+ javax.imageio.plugins.bmp; \
+ javax.imageio.plugins.jpeg; \
+ javax.imageio.spi; \
+ javax.imageio.stream; \
+ javax.jws; \
+ javax.jws.soap; \
+ javax.lang.model; \
+ javax.lang.model.element; \
+ javax.lang.model.type; \
+ javax.lang.model.util; \
+ javax.management; \
+ javax.management.loading; \
+ javax.management.modelmbean; \
+ javax.management.monitor; \
+ javax.management.openmbean; \
+ javax.management.relation; \
+ javax.management.remote; \
+ javax.management.remote.rmi; \
+ javax.management.timer; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.net; \
+ javax.net.ssl; \
+ javax.print; \
+ javax.print.attribute; \
+ javax.print.attribute.standard; \
+ javax.print.event; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.rmi.ssl; \
+ javax.script; \
+ javax.security.auth; \
+ javax.security.auth.callback; \
+ javax.security.auth.kerberos; \
+ javax.security.auth.login; \
+ javax.security.auth.spi; \
+ javax.security.auth.x500; \
+ javax.security.cert; \
+ javax.security.sasl; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.sql; \
+ javax.sql.rowset; \
+ javax.sql.rowset.serial; \
+ javax.sql.rowset.spi; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.plaf.synth; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.tools; \
+ javax.transaction; \
+ javax.transaction.xa; \
+ javax.xml; \
+ javax.xml.bind; \
+ javax.xml.bind.annotation; \
+ javax.xml.bind.annotation.adapters; \
+ javax.xml.bind.attachment; \
+ javax.xml.bind.helpers; \
+ javax.xml.bind.util; \
+ javax.xml.crypto; \
+ javax.xml.crypto.dom; \
+ javax.xml.crypto.dsig; \
+ javax.xml.crypto.dsig.dom; \
+ javax.xml.crypto.dsig.keyinfo; \
+ javax.xml.crypto.dsig.spec; \
+ javax.xml.datatype; \
+ javax.xml.namespace; \
+ javax.xml.parsers; \
+ javax.xml.soap; \
+ javax.xml.stream; \
+ javax.xml.stream.events; \
+ javax.xml.stream.util; \
+ javax.xml.transform; \
+ javax.xml.transform.dom; \
+ javax.xml.transform.sax; \
+ javax.xml.transform.stax; \
+ javax.xml.transform.stream; \
+ javax.xml.validation; \
+ javax.xml.ws; \
+ javax.xml.ws.handler; \
+ javax.xml.ws.handler.soap; \
+ javax.xml.ws.http; \
+ javax.xml.ws.soap; \
+ javax.xml.ws.spi; \
+ javax.xml.xpath; \
+ org.ietf.jgss; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextExtPackage; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.Dynamic; \
+ org.omg.DynamicAny; \
+ org.omg.DynamicAny.DynAnyFactoryPackage; \
+ org.omg.DynamicAny.DynAnyPackage; \
+ org.omg.IOP; \
+ org.omg.IOP.CodecFactoryPackage; \
+ org.omg.IOP.CodecPackage; \
+ org.omg.Messaging; \
+ org.omg.PortableInterceptor; \
+ org.omg.PortableInterceptor.ORBInitInfoPackage; \
+ org.omg.PortableServer; \
+ org.omg.PortableServer.CurrentPackage; \
+ org.omg.PortableServer.POAManagerPackage; \
+ org.omg.PortableServer.POAPackage; \
+ org.omg.PortableServer.portable; \
+ org.omg.PortableServer.ServantLocatorPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ org.omg.stub.javax.management.remote.rmi; \
+ org.w3c.dom; \
+ org.w3c.dom.bootstrap; \
+ org.w3c.dom.css; \
+ org.w3c.dom.events; \
+ org.w3c.dom.html; \
+ org.w3c.dom.ls; \
+ org.w3c.dom.ranges; \
+ org.w3c.dom.stylesheets; \
+ org.w3c.dom.traversal; \
+ org.w3c.dom.views; \
+ org.w3c.dom.xpath; \
+ org.xml.sax; \
+ org.xml.sax.ext; \
+ org.xml.sax.helpers; \
+ version=\"1.6.0\"

Added: labs/jbossesb/workspace/skeagh/examples/file-router/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/pom.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/pom.xml	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>jboss.jbossesb</groupId>
+        <artifactId>examples</artifactId>
+		<version>${jboss.esb.version}</version>
+    </parent>
+    <name>JBoss ESB - File Router Example</name>
+    <groupId>jboss.jbossesb</groupId>
+    <artifactId>jbossesb-examples-file-router</artifactId>
+    <version>${jboss.esb.version}</version>
+    <url>http://www.jboss.org/jbossesb/</url>
+	<packaging>bundle</packaging>
+
+	<properties>
+		<felix.log.level>1</felix.log.level><!-- 4=debug -->
+	</properties>
+
+	<dependencies>
+        <dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.14</version>
+		</dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.main</artifactId>
+            <version>1.2.1</version>
+        </dependency>
+		<dependency>
+            <groupId>org.apache.activemq</groupId>
+            <artifactId>activemq-core</artifactId>
+            <version>4.1.2</version>
+        </dependency>
+		<dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>10.1.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>mx4j</groupId>
+            <artifactId>mx4j</artifactId>
+            <version>3.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jms_1.1_spec</artifactId>
+            <version>1.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
+            <version>1.0-M1</version>
+        </dependency>
+		<dependency>
+			<groupId>javax.jms</groupId>
+			<artifactId>jms</artifactId>
+			<version>1.1</version>
+		</dependency> 
+        <dependency>
+            <groupId>mx4j</groupId>
+            <artifactId>mx4j-tools</artifactId>
+            <version>3.0.1</version>
+        </dependency>
+		<dependency>
+			<groupId>backport-util-concurrent</groupId>
+			<artifactId>backport-util-concurrent</artifactId>
+			<version>3.1</version>
+		</dependency> 
+		<dependency>
+			<groupId>commons-logging</groupId>
+			<artifactId>commons-logging</artifactId>
+			<version>1.1.1</version>
+		</dependency> 
+
+		<!-- JBossESB OSGi bundle -->
+        <dependency>
+            <groupId>jboss.jbossesb</groupId>
+            <artifactId>jbossesb-api</artifactId>
+            <version>${jboss.esb.version}</version>
+        </dependency>
+		<dependency>
+			<groupId>jboss.jbossesb</groupId>
+			<artifactId>jbossesb-osgi-runtime</artifactId>
+			<version>${jboss.esb.version}</version>
+		</dependency>
+
+		<!-- JBossESB File Routing bundle -->
+		<dependency>
+			<groupId>jboss.jbossesb</groupId>
+			<artifactId>jbossesb-routing-file</artifactId>
+			<version>${jboss.esb.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>jboss.jbossesb</groupId>
+			<artifactId>jbossesb-routing-jms</artifactId>
+			<version>${jboss.esb.version}</version>
+		</dependency>
+	</dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.activemq.tooling</groupId>
+                <artifactId>maven-activemq-plugin</artifactId>
+                <version>4.1.2</version>
+                <configuration>
+                    <configFile>./activemq.xml</configFile>
+                    <fork>false</fork>
+                </configuration>
+            </plugin>
+			<plugin>
+				<artifactId>maven-antrun-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>build-config-files</id>
+						<phase>compile</phase>
+						<goals>
+							<goal>run</goal>
+						</goals>
+						<configuration>
+							<tasks>
+								<property name="runtime-classpath" refid="maven.runtime.classpath"/>
+								<mkdir dir="${basedir}/target/input"/>
+								<mkdir dir="${basedir}/target/output"/>
+								<mkdir dir="${basedir}/target/error"/>
+							</tasks>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+            <plugin>
+                <groupId>org.ops4j</groupId>
+                <artifactId>maven-pax-plugin</artifactId>
+                <version>1.3</version>
+                <extensions>true</extensions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>1.4.0</version>
+                <extensions>true</extensions>
+				<configuration>
+                    <instructions>
+                        <Export-Package>org.jboss.esb.examples.inboundrouter.file, org.apache.activemq.jndi</Export-Package>
+                        <Import-Package>org.jboss.esb.file, org.jboss.esb.schedule,org.jboss.esb.api.routing, *;resolution:=optional</Import-Package> <!-- TODO: Replace global import with explicit package imports? -->
+                        <Embed-Dependency>activemq-core, backport-util-concurrent, log4j, commons-logging, geronimo-j2ee-management_1.1_spec</Embed-Dependency>
+                        <Embed-Transitive>true</Embed-Transitive>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Added: labs/jbossesb/workspace/skeagh/examples/file-router/run.bat
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/run.bat	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/run.bat	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,15 @@
+ at echo off
+
+setlocal
+
+set JAVA_OPTS=
+
+if "%1" == "-debug" (
+	set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%
+)
+
+set FELIX_JAR="%USERPROFILE%\.m2\repository\org\apache\felix\org.apache.felix.main\1.2.1\org.apache.felix.main-1.2.1.jar"
+
+"%JAVA_HOME%\bin\java" %JAVA_OPTS% -jar %FELIX_JAR%
+
+endlocal
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/org/jboss/esb/examples/inboundrouter/file/MyTestService.java
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/org/jboss/esb/examples/inboundrouter/file/MyTestService.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/src/main/java/org/jboss/esb/examples/inboundrouter/file/MyTestService.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, Red Hat Middleware LLC, 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-2008, JBoss Inc.
+ */
+package org.jboss.esb.examples.inboundrouter.file;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.service.Service;
+import org.jboss.esb.api.service.ServiceException;
+
+/**
+ * Simple Test service.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public final class MyTestService implements Service
+{
+    /**
+     * Processes the message.
+     *
+     * @param msg - the esb message object instance.
+     * @return Messsage - the esb message object instance.
+     * @throws ServiceException - if an exception occurs during processing.
+     */
+    public Message process(final Message msg) throws ServiceException
+    {
+        System.out.println("MyTestService message payload : " + msg.getPayload());
+        return msg;
+    }
+
+}

Added: labs/jbossesb/workspace/skeagh/examples/file-router/src/main/resources/jboss-esb.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/src/main/resources/jboss-esb.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/src/main/resources/jboss-esb.xml	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,25 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+	<resources>
+        <resource id="schedule1" class="org.jboss.esb.schedule.SimpleSchedule">
+            <property name="frequency">5000</property>
+        </resource>
+    </resources>
+    
+    <services>
+        <service serviceCategory="examples" serviceName="InboundRouter-File" serviceDescription="First Example" class="org.jboss.esb.examples.inboundrouter.file.MyTestService">
+            <inRouter name="fileRouter" class="org.jboss.esb.file.FileInboundRouter">
+                <property name="scheduleResourceId">schedule1</property>
+                <property name="inputDir">../target/input</property>
+                <property name="fileSelectorPattern">*.txt</property>
+                <property name="workingRenamePattern">${name}.working</property>
+                <property name="processedRenamePattern">${name}.done</property>
+                <property name="errrorRenamePattern">${name}.error</property>
+                <property name="fileEncoding">UTF-8</property>
+                <property name="fileSelector">org.jboss.esb.file.filtering.WildcardFileSelector</property>
+                <property name="messageComposer">org.jboss.esb.file.composers.FileStringMessageComposer</property>
+                <property name="fileLifecycleFactory">org.jboss.esb.file.lifecycle.DefaultFileLifecycleFactory</property>
+            </inRouter>
+        </service>
+    </services>
+</jbossesb>

Added: labs/jbossesb/workspace/skeagh/examples/file-router/src/main/resources/jndi.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/src/main/resources/jndi.properties	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/src/main/resources/jndi.properties	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,16 @@
+java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
+java.naming.provider.url=tcp://localhost:61717
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as. 
+connectionFactoryNames = connectionFactory, ConnectionFactory, queueConnectionFactory, topicConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.jbossesb.TestQueue = jbossesb.TestQueue
+
+queue.jbossesb.jms.bus = jbossesb.jms.bus
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+topic.jbossesb.deployment.coordintation.topic = jbossesb.deployment.coordintation.topic

Added: labs/jbossesb/workspace/skeagh/examples/file-router/src/test/java/org/jboss/esb/examples/helloworld/jboss-esb.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/src/test/java/org/jboss/esb/examples/helloworld/jboss-esb.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/src/test/java/org/jboss/esb/examples/helloworld/jboss-esb.xml	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,9 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+    <services>
+        <service serviceCategory="service-cat" serviceName="service-a" 
+        		serviceDescription="TestService" class="org.jboss.esb.examples.helloworld.MyTestService"/>
+    </services> 
+    
+
+</jbossesb>
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,20 @@
+###########################################################################################
+# Default JMS bus config for testing.
+#
+# Using ActiveMQ because it's so easy to embed.  Apparently JBM v2.0 will also be
+# easy to embed.  We might be able to switch to that then!!
+##########################################################################################
+
+# JNDI Settings...
+# NOTE: The JNDI settings in this config file must be the same as those
+# set in the JMSTestRunner class!!
+java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
+java.naming.provider.url=tcp://localhost:61717
+
+# Bus Queues and Topics...
+deployment.coordintation.topic=jbossesb.deployment.coordintation.topic
+deployment.bus.queue=jbossesb.jms.bus
+
+# ActiveMQ Queue and Topic deployments...
+topic.jbossesb.deployment.coordintation.topic=jbossesb.deployment.coordintation.topic
+queue.jbossesb.jms.bus=jbossesb.jms.bus

Added: labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/log4j.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/log4j.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/log4j.xml	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Log4j Configuration                                                  -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<!--
+   | For more configuration infromation and examples see the Jakarta Log4j
+   | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+   <!-- ============================== -->
+   <!-- Append messages to the console -->
+   <!-- ============================== -->
+
+   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+      <param name="Target" value="System.out"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <!-- The default pattern: Date Priority [Category] Message\n -->
+         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
+      </layout>
+   </appender>
+
+   <!-- ================ -->
+   <!-- Limit categories -->
+
+   <category name="org.milyn">
+      <priority value="error"/>
+   </category>
+   
+   <category name="org.quartz">
+      <priority value="error"/>
+   </category>
+   
+   <category name="org.jboss">
+      <priority value="error"/>
+   </category>
+
+   <category name="org.jboss.esb.examples.helloworld">
+      <priority value="info"/>
+   </category>
+   
+   <category name="org.apache.activemq">
+      <priority value="ERROR"/>
+   </category>
+
+   <!-- ======================= -->
+   <!-- Setup the Root category -->
+   <!-- ======================= -->
+
+   <root>
+      <appender-ref ref="CONSOLE"/>
+   </root>
+
+</log4j:configuration>
+

Added: labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/sample.txt
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/sample.txt	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/file-router/src/test/resources/sample.txt	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,2 @@
+File Router Example:
+This is an example file used with the file-router exemple

Modified: labs/jbossesb/workspace/skeagh/examples/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/pom.xml	2008-10-31 07:35:07 UTC (rev 23641)
+++ labs/jbossesb/workspace/skeagh/examples/pom.xml	2008-10-31 07:45:16 UTC (rev 23642)
@@ -21,6 +21,7 @@
 
     <modules>
         <module>helloworld</module>
+        <module>file-router</module>
     </modules>
 
 </project>

Deleted: labs/jbossesb/workspace/skeagh/routing/file/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/osgi.bnd	2008-10-31 07:35:07 UTC (rev 23641)
+++ labs/jbossesb/workspace/skeagh/routing/file/osgi.bnd	2008-10-31 07:45:16 UTC (rev 23642)
@@ -1,5 +0,0 @@
-#-----------------------------------------------------------------
-# Use this file to add customized Bnd instructions for the bundle
-#-----------------------------------------------------------------
-
-Export-Package: org.jboss.esb.file*

Modified: labs/jbossesb/workspace/skeagh/routing/file/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/pom.xml	2008-10-31 07:35:07 UTC (rev 23641)
+++ labs/jbossesb/workspace/skeagh/routing/file/pom.xml	2008-10-31 07:45:16 UTC (rev 23642)
@@ -13,5 +13,31 @@
     <version>${jboss.esb.version}</version>
     <url>http://www.jboss.org/jbossesb/</url>
 	<packaging>bundle</packaging>
+	
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>1.4.0</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Export-Package>org.jboss.esb.file*</Export-Package>
+                        <Import-Package>*;resolution:=optional</Import-Package> 
+                        <Embed-Dependency>jbossesb-commons, log4j</Embed-Dependency>
+                        <Embed-Transitive>true</Embed-Transitive>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 
+    <repositories>
+        <repository>
+            <id>jboss</id>
+            <url>http://repository.jboss.com/maven2</url>
+        </repository>
+    </repositories>
+
 </project>

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/FileInboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/FileInboundRouter.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/FileInboundRouter.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,452 @@
+/*
+ * 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.esb.file;
+
+import java.io.File;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.jboss.esb.api.annotations.Initialize;
+import org.jboss.esb.api.annotations.Property;
+import org.jboss.esb.api.annotations.Property.Use;
+import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageComposer;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.api.routing.InboundRouter;
+import org.jboss.esb.api.routing.MessageDispatcher;
+import org.jboss.esb.classpath.ClassUtil;
+import org.jboss.esb.file.composers.FileBytesMessageComposer;
+import org.jboss.esb.file.filtering.FileSelector;
+import org.jboss.esb.file.filtering.WildcardFileFilter;
+import org.jboss.esb.file.lifecycle.FileLifecycle;
+import org.jboss.esb.file.lifecycle.FileLifecycleFactory;
+import org.jboss.esb.schedule.AbstractScheduleListener;
+import org.jboss.esb.schedule.SchedulingException;
+
+/**
+ * Simple schedule based file {@link InboundRouter}.
+ * A FileInboundRouter is configured by specifying a reference to a
+ * configured schedule configured in the resources element.
+ * <p/>
+ *
+ * Example config:<br/>
+ * <pre>@{code
+ * <resources>
+ *     <resource id="schedule1" class="org.jboss.esb.schedule.SimpleSchedule">
+ *         <property name="frequency">100</property>
+ *         <property name="execCount">1</property>
+ *     </resource>
+ * </resources>
+ *
+ * <inRouter name="fileRouter" class="org.jboss.esb.file.FileInboundRouter">
+ *     <property name="scheduleResourceId">schedule1</property>
+ *     <property name="inputDir">target/</property>
+ *     <property name="fileSelectorPattern">*.txt</property>
+ * </inRouter>
+ * }</pre>
+ * <p/>
+ * Property description:
+ * <lu>
+ *  <li>scheduleResourceId      - the id of the schedule that this router will use.</li>
+ *  <li>inputDir                - the directory from where files will be picked up.</li>
+ *  <li>fileSelectorPattern     - the file matching pattern used to filter files to pick up from the inputDir. Default: '*'</li>
+ *  <li>fileSelector            - the concrete {@link FileSelector} implementation to use. Default: org.jboss.esb.file.filtering.WildcardFileSelector </li>
+ *  <li>fileEncoding            - the file encoding to use when reading the file. Default: UTF-8.</li>
+ *  <li>workingRenamePattern    - the pattern used for naming files that the esb is processing. Default: ${name}.working</li>
+ *  <li>errorRenamePattern      - the pattern used for naming files when a processing error occurs. Default: ${name}.error</li>
+ *  <li>processedRenamePattern  - the pattern used for naming files that have be processed successfully. Default: ${name}.processed}</li>
+ *  <li>messageComposer         - the concrete {@link MessageComposer} implementation to use. Default: org.jboss.esb.file.composers.FileStringMessageComposer</li>
+ *  <li>fileLifecycleFactory    - the concrete {@link FileLifecycleFactory} implementation to use. Default: org.jboss.esb.file.lifecycle.DefaultFileLifecycleFactory</li>
+ * </lu>
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class FileInboundRouter extends AbstractScheduleListener implements InboundRouter
+{
+    /**
+     * Logger.
+     */
+    private static Logger logger = Logger.getLogger(FileInboundRouter.class);
+
+    /**
+     * Name of the directory to "listen" to.
+     */
+    @Property(use = Use.REQUIRED, name = "inputDir")
+    private String inputDirName;
+
+    /**
+     * The file selector pattern use.
+     */
+     @Property(use = Use.OPTIONAL, name = "fileSelectorPattern", defaultVal = "*")
+    private String fileSelectorPattern;
+
+    /**
+     * The file selector implementation to use.
+     */
+     @Property(use = Use.OPTIONAL, name = "fileSelector", defaultVal = "org.jboss.esb.file.filtering.WildcardFileSelector")
+    private String fileSelectorImpl;
+
+    /**
+     * The file encoding of the file being read.
+     */
+     @Property(use = Use.OPTIONAL, name = "fileEncoding", defaultVal = "UTF-8")
+    private String fileEncoding;
+
+    /**
+     * The rename pattern for a file that is in the working state.
+     */
+    @Property(use = Use.OPTIONAL, name = "workingRenamePattern", defaultVal = "${name}.working")
+    private String workingRenamePattern;
+
+    /**
+     * The rename pattern for a file when an error occurs.
+     */
+    @Property(use = Use.OPTIONAL, name = "errorRenamePattern", defaultVal = "${name}.error")
+    private String errorRenamePattern;
+
+    /**
+     * The processed rename pattern for a successfully processed file.
+     */
+    @Property(use = Use.OPTIONAL, name = "processedRenamePattern", defaultVal = "${name}.processed")
+    private String processedRenamePattern;
+
+    /**
+     * The message composer to use.
+     */
+     @Property(use = Use.OPTIONAL, name = "messageComposer", defaultVal = "org.jboss.esb.file.composers.FileBytesMessageComposer")
+    private String messageComposerClass;
+
+    /**
+     * The file lifecycle factory to use.
+     */
+     @Property(use = Use.REQUIRED, name = "fileLifecycleFactory", defaultVal = "org.jboss.esb.file.lifecycle.DefaultFileLifecycleFactory")
+    private String fileLifecycleFactoryName;
+
+    /**
+     * Additional properties.
+     * Any properties specified in the configuration that are not matched to fields of
+     * this class. These will be passed along to the message composer, file selector,
+     * and the lifecycle factory.
+     */
+    @org.jboss.esb.api.annotations.Properties
+    private Properties properties = new Properties();
+
+    /**
+     * The file object identifying the input directory.
+     */
+    private File inputDir;
+
+    /**
+     * FileSelector strategy.
+     */
+    private FileSelector fileSelector;
+
+    /**
+     * Lifecycle factory.
+     */
+    private FileLifecycleFactory fileLifecycleFactory;
+
+    /**
+     * MessageComposer strategy.
+     */
+    private MessageComposer<FileLifecycle> messageComposer;
+
+    /**
+     * The Message Dispatcher to be used with this inbound router.
+     */
+    private MessageDispatcher dispatcher;
+
+    /**
+     * Name of this router. Will be injected by the deployment runtime.
+     */
+    private Object objectName;
+
+    /**
+     * Will check that the {@link #inputDirName} is valid.
+     * Will also set up the file selector, fileLifecycleFactory and message composer.
+     *
+     * @throws ConfigurationException If a configuration error occurs.
+     */
+    @Initialize
+    public final void initialize() throws ConfigurationException
+    {
+        inputDir = getFileDir();
+
+        // Config the file selector...
+        properties.put(WildcardFileFilter.MATCH_PATTERN, fileSelectorPattern);
+        fileSelector = FileSelector.Factory.newInstance(fileSelectorImpl, properties);
+
+        // Config the file lifecycle factory...
+        properties.setProperty(FileLifecycle.WORKING_RENAME_PATTERN, workingRenamePattern);
+        properties.setProperty(FileLifecycle.ERROR_RENAME_PATTERN, errorRenamePattern);
+        properties.setProperty(FileLifecycle.PROCESSED_RENAME_PATTERN, processedRenamePattern);
+        fileLifecycleFactory = FileLifecycleFactory.Factory.newInstance(fileLifecycleFactoryName, properties);
+
+        // Config the message composer...
+        messageComposer = createMessageComposer(messageComposerClass);
+        properties.put("encoding", fileEncoding);
+        messageComposer.setConfiguration(properties);
+
+        if (logger.isDebugEnabled())
+        {
+            logger.debug("-------- Config for FileInboundRouter '" + objectName + "'");
+            logger.debug("Listening for files in dir '" + inputDir.getAbsolutePath() + "'");
+            logger.debug("FileSelector : '" + fileSelector.getClass().getName() + "'");
+            logger.debug("FileLifecycleFactory : '" + fileLifecycleFactory.getClass().getName() + "'");
+            logger.debug("MessageComposer : '" + messageComposer.getClass().getName() + "'");
+            logger.debug("-------- End Config for FileInboundRouter '" + objectName + "'");
+        }
+
+        //TODO: remove this and fix up logging with osgi bundles instead.
+        System.out.println("-------- Config for FileInboundRouter '" + objectName + "'");
+        System.out.println("Listening for files in dir '" + inputDir.getAbsolutePath() + "'");
+        System.out.println("FileSelector : '" + fileSelector.getClass().getName() + "'");
+        System.out.println("FileLifecycleFactory : '" + fileLifecycleFactory.getClass().getName() + "'");
+        System.out.println("MessageComposer : '" + messageComposer.getClass().getName() + "'");
+        System.out.println("-------- End Config for FileInboundRouter '" + objectName + "'");
+    }
+
+    /**
+     * Called every time the schedule linked with this FileInboundRouter is triggered.
+     * <p/>
+     * This method will create a {@link Message} object by delegating the
+     * actual creation to the configured MessageComposer strategy.
+     *
+     * @throws SchedulingException If an exception occurs during processing.
+     */
+    @Override
+    public final void onSchedule() throws SchedulingException
+    {
+        logger.info(" schedule triggered...");
+        System.out.println(" schedule triggered...");
+        final InvocationContext invocationContext = new InvocationContext();
+
+        final Message message = createEsbMessage(invocationContext);
+        if (message == null)
+        {
+            final FileLifecycle fileLifecycle = getFileLifeCycle(invocationContext);
+            try
+            {
+                dispatcher.dispatch(message, invocationContext);
+                fileLifecycle.toProcessed();
+            }
+            catch (final Exception e)
+            {
+                fileLifecycle.toError();
+                throw new SchedulingException(e.getMessage(), e);
+            }
+        }
+        //onProcessingComplete(message, fileLifecycle);
+    }
+
+    /**
+     * Cleanup. Currently this method does nothing.
+     */
+    public void uninitialize()
+    {
+        //NoOp
+    }
+
+    /**
+     * Sets the {@link MessageDispatcher} that will be used with this Router.
+     *
+     * @param dispatcher The dispatcher used to dispatch to the ESB.
+     */
+    public final void setDispatcher(final MessageDispatcher dispatcher)
+    {
+        this.dispatcher = dispatcher;
+    }
+
+    /**
+     * Gets the name of the input directoy that this router listens to.
+     *
+     * @return String   The name of the input directory.
+     */
+    public final String getInputDirName()
+    {
+        return inputDirName;
+    }
+
+    /**
+     * Creates an esb Message Object by taking the content of one file and
+     * setting it as the messages payload.
+     *
+     * @param invocationContext The invocation context.
+     * @return Message  Esb Message or null if no files were found.
+     *
+     * @throws SchedulingException If en exception occurs while trying to compose the message.
+     */
+    private Message createEsbMessage(final InvocationContext invocationContext) throws SchedulingException
+    {
+        final File[] files = fileSelector.select(inputDir);
+
+        if (files.length == 0)
+        {
+            return null;
+        }
+
+        // Store the FileLifecycle in the invocation context.
+        final FileLifecycle fileLifecycle = fileLifecycleFactory.newInstance();
+        invocationContext.setContextObject(FileLifecycle.class.getName(), fileLifecycle);
+
+        for (int i = 0; i < files.length; i++)
+        {
+            final File file = files[i];
+
+            fileLifecycle.setFile(file);
+            if (fileLifecycle.toWorking() != null)
+            {
+                // Moved the file to the working state. Break out fo the loop.
+                break;
+            }
+            else if (i == files.length - 1)
+            {
+                // No more file.  Just return and come back in again onSchedule ...
+                return null;
+            }
+            else
+            {
+                // Another listener has already transitioned the file to working (in between calls).  Try the next file...
+            }
+        }
+
+        try
+        {
+            return messageComposer.compose(fileLifecycle, invocationContext);
+        }
+        catch (final MessageProcessingException e)
+        {
+            throw new SchedulingException("Unable to compose message from file '" + files[0].getAbsolutePath() + "'.", e);
+        }
+    }
+
+    /**
+     * Will return a File object referens to {@link #inputDirName}.
+     *
+     * @return File File object referens to {@link #inputDirName}.
+     *
+     * @throws ConfigurationException If the directory does not exist, is not a directory, or not read/write able.
+     */
+    private File getFileDir() throws ConfigurationException
+    {
+        final File fileDir = new File(inputDirName);
+
+        // Check the file listen directory...
+        if (!fileDir.exists())
+        {
+            throw new ConfigurationException("Directory '" + fileDir.getAbsolutePath() + "' doesn't exist.");
+        }
+        if (!fileDir.isDirectory())
+        {
+            throw new ConfigurationException("File '" + fileDir.getAbsolutePath() + "' is not a directory.");
+        }
+        if (!fileDir.canRead() || !fileDir.canWrite())
+        {
+            throw new ConfigurationException("Directory '" + fileDir.getAbsolutePath() + "' must be readable and writeable.");
+        }
+
+        return fileDir;
+    }
+
+    /**
+     * Gets the FileLifecycle from the invocation context.
+     *
+     * @param invocationContext The invocation context.
+     * @return FileLifecycle From the context.
+     */
+    private FileLifecycle getFileLifeCycle(final InvocationContext invocationContext)
+    {
+        return (FileLifecycle)invocationContext.getContextObject(FileLifecycle.class.getName());
+    }
+
+    /**
+     * TODO: not sure if this method is actually needed.
+     *
+     * @param message The ESB Message object.
+     * @param fileLifecycle The FileLifecycle.
+     * @return Message The ESB Message object.
+     * @throws SchedulingException If an exception occurs while decomposing.
+     */
+    @SuppressWarnings("unused")
+    private Message onProcessingComplete(final Message message, final FileLifecycle fileLifecycle) throws SchedulingException
+    {
+        try
+        {
+            // The composer can decide whether or not to write out a response...
+            if (message != null)
+            {
+                messageComposer.decompose(message, fileLifecycle);
+            }
+        }
+        catch (final MessageProcessingException e)
+        {
+            throw new SchedulingException("Unable to decompose message from file '" + fileLifecycle.getFile().getAbsolutePath() + "'.", e);
+        }
+        return null;
+    }
+
+    /**
+     * Creates a new instance of the passed in class name. It must implement
+     * MessageComposer.
+     *
+     * @param className The name of the class to create.
+     * @return MessageComposer  The newly created instance.
+     * @throws ConfigurationException If it was not able to create the class.
+     */
+    @SuppressWarnings("unchecked")
+    private MessageComposer<FileLifecycle> createMessageComposer(final String className) throws ConfigurationException
+    {
+        String messageComposerClassName = getMessageComposerClassName(className);
+        try
+        {
+            Class<?> forName = ClassUtil.forName(messageComposerClassName, FileInboundRouter.class);
+            return (MessageComposer<FileLifecycle>) forName.newInstance();
+        }
+        catch (final ClassNotFoundException e)
+        {
+            throw new ConfigurationException("Could not load message composer class '" + messageComposerClassName + "'. Exception was: " + e);
+        }
+        catch (final InstantiationException e)
+        {
+            throw new ConfigurationException("InstantiationException:" + e);
+        }
+        catch (final IllegalAccessException e)
+        {
+            throw new ConfigurationException("IllegalAccessException:" + e);
+        }
+    }
+
+    /**
+     * @param className The name of the class.
+     * @return String The name of the class.
+     */
+    private String getMessageComposerClassName(final String className)
+    {
+        // We may need to expand the classname...
+        if (className.indexOf('.') == -1)
+        {
+            return FileBytesMessageComposer.class.getPackage().getName() + "." + className;
+        }
+        return className;
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/AbstractFileMessageComposer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/AbstractFileMessageComposer.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/AbstractFileMessageComposer.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,188 @@
+/*
+ * 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.esb.file.composers;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.log4j.Logger;
+import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageComposer;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.file.lifecycle.FileLifecycle;
+import org.jboss.esb.lifecycle.Closeable;
+import org.jboss.esb.util.AssertArgument;
+
+/**
+ * Abstract File MessageComposer.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ * @param <T>
+ */
+public abstract class AbstractFileMessageComposer<T extends FileLifecycle> implements MessageComposer<T>
+{
+    /**
+     * Logger.
+     */
+    private static Logger logger = Logger.getLogger(FileBytesMessageComposer.class);
+
+    /**
+     * Key used in the InvocationContext for the FileLifecycle.
+     */
+    public static final String PROP_FILE_LIFECYCLE = "in-file-lifecycle";
+
+    /**
+     * Key used in the InvocationContext for the File object.
+     */
+    public static final String PROP_FILE_OBJ = "in-file-obj";
+
+    /**
+     * Key used in the InvocationContext for the absolute path to the File.
+     */
+    public static final String PROP_FILE_PATH = "in-file-path";
+
+    /**
+     * Key used in the InvocationContext for the file lenght.
+     */
+    public static final String PROP_FILE_LENGTH = "in-file-length";
+
+    /**
+     * Key used in the InvocationContext for the files last modified date.
+     */
+    public static final String PROP_FILE_LASTMOD = "in-file-lastmod";
+
+    /**
+     * Composes/creates an ESB Messag object instance and popluates its payload
+     * with the contents of the file(via the FileLifecycle).
+     *
+     * @param fileLifecycle The {@link FileLifecycle}.
+     * @param invocationContext The invocation context.
+     * @return Message  A new ESB Message object instance with its payload set to the files content.
+     *
+     * @throws MessageProcessingException If the payload could not be extracted from the file.
+     *
+     */
+    public final Message compose(final T fileLifecycle, final InvocationContext invocationContext) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(fileLifecycle, "fileLifecycle");
+
+        final File currentFile = fileLifecycle.getFile();
+        if (!currentFile.exists())
+        {
+            throw new MessageProcessingException("Invalid File payload.  File '" + currentFile.getAbsolutePath() + "' doesn't exist.");
+        }
+
+        final Message message = new Message();
+        try
+        {
+            final Object payload = getPayload(currentFile);
+            message.setPayload(payload);
+
+            // We store the original payload on the lifecycle. Might be needed during cleanup...
+            fileLifecycle.setPayload(payload);
+        }
+        catch (final IOException e)
+        {
+            throw new MessageProcessingException("Error reading input file '" + currentFile.getAbsolutePath() + "'.", e);
+        }
+        catch (final Throwable t)
+        {
+            throw new MessageProcessingException("Error creating message from input file '" + currentFile.getAbsolutePath() + "'.", t);
+        }
+
+        setFileMetadata(fileLifecycle, invocationContext);
+
+        return message;
+    }
+
+    /**
+     * Sets metadata information into the InvocationContext.
+     * The following properties are currently set:
+     * <lu>
+     *  <li>{@link #PROP_FILE_LIFECYCLE} - The {@link FileLifecycle}</li>
+     *  <li>{@link #PROP_FILE_OBJ} - The File object itself</li>
+     *  <li>{@link #PROP_FILE_PATH} - The absolute path to the file</li>
+     *  <li>{@link #PROP_FILE_LENGTH} - The lenght of the file</li>
+     *  <li>{@link #PROP_FILE_LASTMOD} - The last modified date for the file</li>
+     * </lu>
+     * Subclasses can override this method to add additional properties.
+     *
+     * @param fromFileLifecycle The {@link FileLifecycle}.
+     * @param toContext The {@link InvocationContext}.
+     */
+    protected final void setFileMetadata(final T fromFileLifecycle, final InvocationContext toContext)
+    {
+        // Add some metadata about the file to the InvocationContext.
+        final File currentFile = fromFileLifecycle.getFile();
+        toContext.setContextObject(PROP_FILE_LIFECYCLE, fromFileLifecycle);
+        toContext.setContextObject(PROP_FILE_OBJ, currentFile);
+        toContext.setContextObject(PROP_FILE_PATH, currentFile.getAbsolutePath());
+        toContext.setContextObject(PROP_FILE_LENGTH, currentFile.length());
+        toContext.setContextObject(PROP_FILE_LASTMOD,currentFile.lastModified());
+    }
+
+    /**
+     * Decompose closes the payload if it is {@link org.jboss.esb.lifecycle.Closeable}.
+     *
+     * @param message The ESB Message object.
+     * @param fileLifecycle The {@link FileLifecycle}.
+     * @return Object The payload from the passed in message.
+     * @throws MessageProcessingException If an exception occurs while decomposing.
+     */
+    public final Object decompose(final Message message, final T fileLifecycle) throws MessageProcessingException
+    {
+        final Object initialPayload = fileLifecycle.getPayload();
+        final Object payload = message.getPayload();
+
+        // If the compose step opened a stream, reader etc... make sure it's closed...
+        if (initialPayload instanceof Closeable)
+        {
+            try
+            {
+                ((Closeable) initialPayload).close();
+            }
+            catch (final Throwable e)
+            {
+                if (logger.isDebugEnabled())
+                {
+                    logger.debug("File '" + fileLifecycle.getFile().getAbsolutePath() + "' already closed.");
+                }
+            }
+        }
+
+        return payload;
+    }
+
+    /**
+     * Retrieves the contents of a file and returns it in a format
+     * specific to the subclass implementing this method.
+     * Some subclasses might return the contents as a String, others
+     * will return a Stream to the file.
+     *
+     * @param file The file object.
+     * @return Object Object specific to the implementing subclass.
+     * @throws IOException If an error occurs while trying to read from the file.
+     */
+    protected abstract Object getPayload(final File file) throws IOException;
+
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileBytesMessageComposer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileBytesMessageComposer.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileBytesMessageComposer.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,59 @@
+/*
+ * 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.esb.file.composers;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.jboss.esb.file.lifecycle.FileLifecycle;
+import org.jboss.esb.util.FileUtil;
+
+/**
+ * Local file byte[] message composer.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @param <T>
+ */
+public class FileBytesMessageComposer<T extends FileLifecycle> extends AbstractFileMessageComposer<T>
+{
+    /**
+     * Get the payload from the passed in file.
+     *
+     * @param file The file to retrieve the payload from.
+     * @return Object The files contents as a byte array.
+     * @throws IOException If an error occurs while trying to read the file.
+     */
+    @Override
+    protected final Object getPayload(final File file) throws IOException
+    {
+        return FileUtil.readFile(file);
+    }
+
+    /**
+     * Implemented as a No Operation.
+     *
+     * @param properties The properties.
+     */
+    public void setConfiguration(final Properties properties)
+    {
+        // NoOp
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileReaderMessageComposer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileReaderMessageComposer.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileReaderMessageComposer.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,67 @@
+/*
+ * 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.esb.file.composers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Properties;
+
+import org.jboss.esb.file.lifecycle.FileLifecycle;
+
+/**
+ * Local file {@link Reader} message composer.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ *
+ * @param <T>
+ */
+public class FileReaderMessageComposer<T extends FileLifecycle> extends AbstractFileMessageComposer<T>
+{
+    /**
+     * The encoding to use.
+     */
+    private String encoding;
+
+    /**
+     * Creates a new InputStreamReader using the passed-in file.
+     *
+     * @param file  The file object.
+     * @return Object A new InputStreamReader instance.
+     * @throws IOException If the InputStreamReader could not be created.
+     */
+    @Override
+    protected final Object getPayload(final File file) throws IOException
+    {
+        return new InputStreamReader(new FileInputStream(file), encoding);
+    }
+
+    /**
+     * Extracts an optional "encoding" property from the passed in
+     * properties object as set the encoding.
+     *
+     * @param properties Properties instance that may optionally contain a propery named "encoding".
+     */
+    public final void setConfiguration(final Properties properties)
+    {
+        encoding = properties.getProperty("encoding", "UTF-8");
+    }
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileStreamMessageComposer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileStreamMessageComposer.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileStreamMessageComposer.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,59 @@
+/*
+ * 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.esb.file.composers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.jboss.esb.file.lifecycle.FileLifecycle;
+
+/**
+ * Local file {@link java.io.InputStream} message composer.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @param <T>
+ */
+public class FileStreamMessageComposer<T extends FileLifecycle> extends AbstractFileMessageComposer<T>
+{
+    /**
+     * Get the payload from the passed in file.
+     *
+     * @param file The file to retrieve the payload from.
+     * @return Object FileInputStream created with the passed in file.
+     * @throws IOException If the InputStreamReader could not be created.
+     */
+    @Override
+    protected final Object getPayload(final File file) throws IOException
+    {
+        return new FileInputStream(file);
+    }
+
+    /**
+     * Implemented as a No Operation.
+     *
+     * @param properties The properties.
+     */
+    public void setConfiguration(final Properties properties)
+    {
+        // NoOp
+    }
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileStringMessageComposer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileStringMessageComposer.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/FileStringMessageComposer.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,59 @@
+/*
+ * 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.esb.file.composers;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.jboss.esb.file.lifecycle.FileLifecycle;
+import org.jboss.esb.util.FileUtil;
+
+/**
+ * Local file String message composer.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * @param <T>
+ */
+public class FileStringMessageComposer<T extends FileLifecycle> extends AbstractFileMessageComposer<T>
+{
+    /**
+     * Get the payload from the passed in file.
+     *
+     * @param file The file to retrieve the payload from.
+     * @return Object The files contents as a String.
+     * @throws IOException If the file contents could not be read.
+     */
+    @Override
+    public final Object getPayload(final File file) throws IOException
+    {
+        return FileUtil.readTextFile(file);
+    }
+
+    /**
+     * Implemented as a No Operation.
+     *
+     * @param properties The properties.
+     */
+    public void setConfiguration(final Properties properties)
+    {
+        // NoOp
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/package.html	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/composers/package.html	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+JBoss Routing - File - Composers.
+
+<h1>Overview</h1>
+</body>
+</html>
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/AlphabeticFileComparator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/AlphabeticFileComparator.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/AlphabeticFileComparator.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,48 @@
+/*
+ * 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.esb.file.filtering;
+
+import java.io.File;
+import java.util.Comparator;
+
+/**
+ * Comparator for use in alphabetic sorting of file lists based on the file
+ * names.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @param <T>
+ */
+public class AlphabeticFileComparator<T extends File> implements Comparator<T>
+{
+    /**
+     * Compares the filenames.
+     * @param file1 File to compare.
+     * @param file2 File to compare to.
+     * @return  the value <code>0</code> if the argument string is equal to
+     *          this string; a value less than <code>0</code> if this string
+     *          is lexicographically less than the string argument; and a
+     *          value greater than <code>0</code> if this string is
+     *          lexicographically greater than the string argument.
+     */
+    public final int compare(final T file1, final T file2)
+    {
+        return file1.getName().compareTo(file2.getName());
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/FileSelector.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/FileSelector.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/FileSelector.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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-2008, JBoss Inc.
+ */
+package org.jboss.esb.file.filtering;
+
+import java.io.File;
+import java.util.Properties;
+
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.jboss.esb.classpath.ClassUtil;
+
+/**
+ * File Selector.
+ * <p/>
+ * This interface is very similar to the {@link java.io.FileFilter} interface.  The difference
+ * is that you have more control over the resultant File list because implementations of this class
+ * can see the full list of files before returning the list, whereas {@link java.io.FileFilter}
+ * implementations can only see one file at a time.  Implemenations of this interface can be used
+ * as a layer on top of the {@link java.io.FileFilter} based filtering.
+ * <p/>
+ * This is useful because it allows you to (for example) truncate the List to a fixed size,
+ * or perform secondary filtering based on the contents of the list, or sort the list in some way.
+ * Implementations of this class may actually use a {@link java.io.FileFilter}
+ * implementation to produce an initial list that's filtered further by the implementation
+ * itself.
+ * <p/>
+ * Implementation are useful to the likes of the {@link org.jboss.esb.file.FileInboundRouter} because
+ * if means that more controlled filtering can be injected.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public interface FileSelector
+{
+    /**
+     * Select (aka "filter") a list of files from the supplied directory.
+     *
+     * @param dir Directory to filer files from.
+     * @return The list of filtered files.  An empty array should be returned where no matching
+     *         files are found in the target directory.
+     */
+    File[] select(final File dir);
+
+    /**
+     * Configure the File Selector instance.
+     *
+     * @param properties Additional properties that a FileSelector implementation might need.
+     * @throws ConfigurationException Configuration exception due to an invalid selector configuration.
+     */
+    void configure(final Properties properties) throws ConfigurationException;
+
+    /**
+     * FileSelector factory.
+     */
+    public static final class Factory
+    {
+        /**
+         * Private constructor.
+         */
+        private Factory()
+        {
+
+        }
+
+        /**
+         * Factory method for creating the selector instance.
+         *
+         * @param className The selector class name.
+         * @param config    The selector config.
+         * @return The selector instance.
+         * @throws ConfigurationException Configuration exception due to selector configuration.
+         */
+        public static FileSelector newInstance(final String className, final Properties config) throws ConfigurationException
+        {
+            try
+            {
+                FileSelector selector = (FileSelector) ClassUtil.forName(className, FileSelector.class).newInstance();
+                selector.configure(config);
+                return selector;
+            }
+            catch (final ClassCastException e)
+            {
+                throw new ConfigurationException("Class '" + className + "' must implement '" + FileSelector.class.getName() + "'.");
+            }
+            catch (final ClassNotFoundException e)
+            {
+                throw new ConfigurationException("Class '" + className + "' not found.");
+            }
+            catch (final IllegalAccessException e)
+            {
+                throw new ConfigurationException("Cannot instantiate class '" + className + "'.", e);
+            }
+            catch (final InstantiationException e)
+            {
+                throw new ConfigurationException("Cannot instantiate class '" + className + "'.", e);
+            }
+        }
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/WildcardFileFilter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/WildcardFileFilter.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/WildcardFileFilter.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,84 @@
+/*
+ * 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.esb.file.filtering;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.esb.api.exception.ConfigurationException;
+
+/**
+ * Wildcard file filter. <p/> Supports file filtering using the standard
+ * "*.xml", "a?b.xml" type notation.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class WildcardFileFilter implements FileFilter
+{
+    /**
+     * Key used in properties map.
+     */
+    public static final String MATCH_PATTERN = "matchPattern";
+
+    /**
+     * The compiled mattern to match.
+     */
+    private Pattern matchPattern;
+
+    /**
+     * Detemines if the this filter accepts file like the one passed in.
+     *
+     * @param file The file to check.
+     * @return true If this filter accepts the file.
+     */
+    public final boolean accept(final File file)
+    {
+        if (matchPattern == null)
+        {
+            throw new IllegalStateException("Illegal call to accept().  Filter not yet configured (via setConfiguration()).");
+        }
+
+        Matcher matcher = matchPattern.matcher(file.getName());
+        return matcher.matches();
+    }
+
+    /**
+     * Set the pattern to match by extracting the value from properties instance.
+     *
+     * @param properties The properties object. Must contains an entry for {@value #MATCH_PATTERN}.
+     * @throws ConfigurationException If no {@value #MATCH_PATTERN} property value exists in the passed in properties.
+     */
+    public final void setConfiguration(final Properties properties) throws ConfigurationException
+    {
+        String matchPatternConfig = properties.getProperty(MATCH_PATTERN);
+        if (matchPatternConfig == null)
+        {
+            throw new ConfigurationException("Properties was missing a value from '" + MATCH_PATTERN + "'.");
+        }
+
+        matchPatternConfig = matchPatternConfig.replace(".", "\\.");
+        matchPatternConfig = matchPatternConfig.replace("*", ".*");
+        matchPatternConfig = matchPatternConfig.replace("?", ".?");
+        matchPattern = Pattern.compile(matchPatternConfig);
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/WildcardFileSelector.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/WildcardFileSelector.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/WildcardFileSelector.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,108 @@
+/*
+ * 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.esb.file.filtering;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Properties;
+
+import org.jboss.esb.api.exception.ConfigurationException;
+
+/**
+ * Wildcard file selector. This is just a basic file selector that uses the
+ * {@link WildcardFileFilter}.
+ * It adds additional guaranteed sorting (assending alphabetic) of the resultant File list.
+ * <p/>
+ * Extend this class and override the {@link #select(java.io.File)} method if secondary
+ * filtering is required. Create a new {@link FileSelector} implementation that uses an
+ * overriden version of {@link WildcardFileFilter} if more fine grained control over
+ * wildcard based filtering is required.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class WildcardFileSelector implements FileSelector
+{
+    /**
+     *
+     */
+    private WildcardFileFilter filter = new WildcardFileFilter();
+
+    /**
+     *
+     */
+    private AlphabeticFileComparator<File> sortComparator = new AlphabeticFileComparator<File>();
+
+    /**
+     * No-args constructor.
+     */
+    public WildcardFileSelector()
+    {
+    }
+
+    /**
+     * Will call {@link #setConfiguration(Properties)}.
+     *
+     * @param properties Properties that will be passed to {@link #setConfiguration(Properties)}.
+     * @throws ConfigurationException If an invalid properties value is passed.
+     */
+    public WildcardFileSelector(final Properties properties) throws ConfigurationException
+    {
+        setConfiguration(properties);
+    }
+
+    /**
+     * Selects files from the passed in dir, using the delegating
+     * to {@link WildcardFileFilter} and sorting the files
+     * returned from using {@link AlphabeticFileComparator}.
+     *
+     * @param dir The directory to search for files.
+     * @return File[] Array of files that were found. Sorted using {@link AlphabeticFileComparator}.
+     */
+    public final File[] select(final File dir)
+    {
+        final File[] files = dir.listFiles(filter);
+        Arrays.sort(files, sortComparator);
+        return files;
+    }
+
+    /**
+     * Delegates to {@link WildcardFileFilter#setConfiguration(Properties)} to configure
+     * the filter.
+     *
+     * @param properties The properties object. Must contains an entry for {@value #MATCH_PATTERN}.
+     * @throws ConfigurationException If no {@value #MATCH_PATTERN} property value exists in the passed in properties.
+     */
+    public final void setConfiguration(final Properties properties) throws ConfigurationException
+    {
+        filter.setConfiguration(properties);
+    }
+
+    /**
+     * Delegates to {@link #setConfiguration(Properties)} to configure
+     * the filter.
+     *
+     * @param properties The properties object. Must contains an entry for {@value #MATCH_PATTERN}.
+     * @throws ConfigurationException If no {@value #MATCH_PATTERN} property value exists in the passed in properties.
+     */
+    public final void configure(final Properties properties) throws ConfigurationException
+    {
+        setConfiguration(properties);
+    }
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/package.html	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/filtering/package.html	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+JBoss Routing - File - Filtering.
+
+<h1>Overview</h1>
+</body>
+</html>
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycle.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycle.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycle.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,240 @@
+/*
+ * 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.esb.file.lifecycle;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * Default file lifecycle. <p/> If the "processedRenamePattern" property is not
+ * specified, the file is deleted.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class DefaultFileLifecycle implements FileLifecycle
+{
+    /**
+     * Serial version uid.
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * The name of the file currently being processed.
+     */
+    private String fileName;
+
+    /**
+     * The files prefix.
+     */
+    private String prefix;
+
+    /**
+     * The files suffix.
+     */
+    private String suffix;
+
+    /**
+     * The configuration for this FileLifecycle.
+     */
+    private FileLifecycleConfig config;
+
+    /**
+     * Holds the file currently being processed.
+     */
+    private List<File> fileHistory = new ArrayList<File>();
+
+    /**
+     * Id for this lifecycle.
+     */
+    private String lifecycleId = UUID.randomUUID().toString();
+
+    /**
+     * The payload object for this file.
+     */
+    private Object payload;
+
+    /**
+     * Sets the file currently being processed.
+     * @param file  The file currently being processed.
+     */
+    public final void setFile(final File file)
+    {
+        fileName = file.getName();
+        int lastDotIndex = fileName.lastIndexOf('.');
+        if (lastDotIndex != -1 && lastDotIndex != (fileName.length() - 1))
+        {
+            prefix = fileName.substring(0, lastDotIndex);
+            suffix = fileName.substring(lastDotIndex + 1);
+        }
+
+        fileHistory.clear();
+        fileHistory.add(file);
+    }
+
+    /**
+     * Rename file using the working rename patterns, which
+     * can be optionally specified in the {@link FileLifecycleConfig}.
+     *
+     * @return File A File object to the renamed file.
+     */
+    public final File toWorking()
+    {
+        return renameFile(config.getWorkingRenamePattern());
+    }
+
+    /**
+     * Rename file using the error rename patterns, which
+     * can be optionally specified in the {@link FileLifecycleConfig}.
+     *
+     * @return File A File object to the renamed file.
+     */
+    public final File toError()
+    {
+        return renameFile(config.getErrorRenamePattern());
+    }
+
+    /**
+     * Rename file using the processed rename patterns, which
+     * can be optionally specified in the {@link FileLifecycleConfig}.
+     *
+     * @return File A File object to the renamed file.
+     */
+    public final File toProcessed()
+    {
+        if (config.getProcessedRenamePattern() != null)
+        {
+            return renameFile(config.getProcessedRenamePattern());
+        }
+        else
+        {
+            fileHistory.get(fileHistory.size() - 1).delete();
+            return null;
+        }
+    }
+
+    /**
+     * Get the file currently being processed.
+     * @return File The file currently being processed.
+     */
+    public final File getFile()
+    {
+        return fileHistory.get(fileHistory.size() - 1);
+    }
+
+    /**
+     * Get the file history list.
+     * @return List List of Files.
+     */
+    public final List<File> getFileHistory()
+    {
+        return fileHistory;
+    }
+
+    /**
+     * This methods replaces the following variables in the passed in string.
+     * <lu>
+     *  <li>${name}         - the files name</li>
+     *  <li>${${prefix}     - the files prefix</li>
+     *  <li>${${suffix}     - the files prefix</li>
+     *  <li>${${lifecycleid}- this lifecycles id</li>
+     * </lu>
+     *
+     * @param renameExpression The string that will have its "variables" substituted.
+     * @return String The passed in string with replaced variables.
+     */
+    public final String evalNameExpression(final String renameExpression)
+    {
+        String newName = renameExpression;
+
+        newName = newName.replace(FILE_NAME, fileName);
+        newName = newName.replace(LIFECYCLE_ID_TOKEN, lifecycleId);
+        if (prefix != null)
+        {
+            newName = newName.replace(PREFIX_TOKEN, prefix);
+        }
+        if (suffix != null)
+        {
+            newName = newName.replace(SUFFIX_TOKEN, suffix);
+        }
+        return newName;
+    }
+
+    /**
+     * Set the payload.
+     * @param payload The object to set as the payload.
+     */
+    public final void setPayload(final Object payload)
+    {
+        this.payload = payload;
+    }
+
+    /**
+     * Gets the payload.
+     * @return Object The payload.
+     */
+    public final Object getPayload()
+    {
+        return payload;
+    }
+
+    /**
+     * Sets the lifecycle configuration.
+     *
+     * @param lifecycleConfig The configuration for this lifecycle.
+     */
+    public final void setConfiguration(final FileLifecycleConfig lifecycleConfig)
+    {
+        this.config = lifecycleConfig;
+    }
+
+    /**
+     * Renames the file(getFile()) using the passed in rename expression.
+     *
+     * @param renameExpression The name expression for the destination file.
+     * @return File File object to the renamed file, or null if the current file does not have a parent directory.
+     */
+    private File renameFile(final String renameExpression)
+    {
+        final File currentRevision = getFile();
+        final String newName = evalNameExpression(renameExpression);
+
+        final File dir = currentRevision.getParentFile();
+        if (dir != null)
+        {
+            final File toFile = new File(dir, newName);
+
+            if (!toFile.exists())
+            {
+                dir.mkdirs();
+                currentRevision.renameTo(toFile);
+                if (toFile.exists())
+                {
+                    fileHistory.add(toFile);
+                    return toFile;
+                }
+            }
+        }
+
+        return null;
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycleFactory.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycleFactory.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycleFactory.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,73 @@
+/*
+ * 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.esb.file.lifecycle;
+
+import java.util.Properties;
+
+import org.jboss.esb.api.exception.ConfigurationException;
+
+/**
+ * Default FileLifecycleFactory.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class DefaultFileLifecycleFactory implements FileLifecycleFactory
+{
+    /**
+     * Configuration.
+     */
+    private FileLifecycleConfig lifecycleConfig;
+
+    /**
+     * Creates a new {@link FileLifecycleConfig} using the passed in
+     * properties.
+     *
+     * @param properties Properties to initialize the FileLifecycleConfig.
+     * @throws ConfigurationException If an invalid property was passed.
+     */
+    public final void setConfiguration(final Properties properties) throws ConfigurationException
+    {
+        lifecycleConfig = new FileLifecycleConfig();
+        lifecycleConfig.setConfiguration(properties);
+    }
+
+    /**
+     * Creates a FileLifecycle.
+     *
+     * @return {@link FileLifecycle} A newly created FileLifecycle.
+     */
+    public final FileLifecycle newInstance()
+    {
+        DefaultFileLifecycle lifecycle = new DefaultFileLifecycle();
+        lifecycle.setConfiguration(lifecycleConfig);
+        return lifecycle;
+    }
+
+    /**
+     * Configures this FileLifecycleFactory.
+     *
+     * @param properties The properties to initialize the life cycle object.
+     * @throws ConfigurationException If an invalid property was passed.
+     */
+    public final void configure(final Properties properties) throws ConfigurationException
+    {
+        setConfiguration(properties);
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycle.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycle.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycle.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,187 @@
+/*
+ * 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.esb.file.lifecycle;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.List;
+
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.jboss.esb.classpath.ClassUtil;
+
+/**
+ * File lifecycle interface.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public interface FileLifecycle extends Serializable
+{
+    /**
+     * Key used in properties map.
+     */
+    String WORKING_RENAME_PATTERN = "workingRenamePattern";
+
+    /**
+     * Key used in properties map.
+     */
+    String ERROR_RENAME_PATTERN = "errorRenamePattern";
+
+    /**
+     * Key used in properties map.
+     */
+    String PROCESSED_RENAME_PATTERN = "processedRenamePattern";
+
+    /**
+     * String used as a replacement key.
+     */
+    String FILE_NAME = "${name}";
+
+    /**
+     * String used as a replacement key.
+     */
+    String PREFIX_TOKEN = "${prefix}";
+
+    /**
+     * String used as a replacement key.
+     */
+    String SUFFIX_TOKEN = "${suffix}";
+
+    /**
+     * String used as a replacement key.
+     */
+    String LIFECYCLE_ID_TOKEN = "${lifecycleid}";
+
+    /**
+     * Set the file currently being processed.
+     *
+     * @param file The file object representing the file being processed.
+     */
+    void setFile(File file);
+
+    /**
+     * Gets the File currently being processed.
+     *
+     * @return File The file object currently being processed.
+     */
+    File getFile();
+
+    /**
+     * Sets the payload.
+     *
+     * @param payload The payload to set.
+     */
+    void setPayload(Object payload);
+
+    /**
+     * Get the payload.
+     *
+     * @return Object The payload
+     */
+    Object getPayload();
+
+    /**
+     * Set this FileLifecycles configuration.
+     *
+     * @param config This instances {@link FileLifecycleConfig}.
+     */
+    void setConfiguration(final FileLifecycleConfig config);
+
+    /**
+     * @return List File history list.
+     */
+    List<File> getFileHistory();
+
+
+    /**
+     * Perform any operation required when moving to the state working.
+     * Subclasses might want to rename this file for example.
+     *
+     * @return File The file object that can be worked with.
+     */
+    File toWorking();
+
+    /**
+     * Perform any operation required when moving to the error state.
+     *
+     * @return File The file object.
+     */
+    File toError();
+
+    /**
+     * Perform any operation required after successfull processing.
+     *
+     * @return File The file object.
+     */
+    File toProcessed();
+
+    /**
+     *
+     * @param renameExpression The string to be evaluated.
+     * @return String
+     */
+    String evalNameExpression(final String renameExpression);
+
+    /**
+     *
+     */
+    public static final class Factory
+    {
+        /**
+         * Private constructor.
+         */
+        private Factory()
+        {
+        }
+
+        /**
+         * Factory method.
+         *
+         * @param className The name of the class to create. Must be an instance of {@link FileLifecycle}.
+         * @param lifecycleConfig The {@link FileLifecycleConfig} to use to configure the newly created class.
+         * @return FileLifecycle The newly created FileLifecycle with its FileLifecycleConfig set.
+         * @throws ConfigurationException If an error occurs during class creation.
+         */
+        public static FileLifecycle newInstance(final String className, final FileLifecycleConfig lifecycleConfig) throws ConfigurationException
+        {
+            try
+            {
+                FileLifecycle lifecycle = (FileLifecycle) ClassUtil.forName(className, FileLifecycle.class).newInstance();
+                lifecycle.setConfiguration(lifecycleConfig);
+                return lifecycle;
+            }
+            catch (final ClassCastException e)
+            {
+                throw new ConfigurationException("Class '" + className + "' must implement '" + FileLifecycle.class.getName() + "'.");
+            }
+            catch (final ClassNotFoundException e)
+            {
+                throw new ConfigurationException("Class '" + className + "' not found.");
+            }
+            catch (final IllegalAccessException e)
+            {
+                throw new ConfigurationException("Cannot instantiate class '" + className + "'.", e);
+            }
+            catch (final InstantiationException e)
+            {
+                throw new ConfigurationException("Cannot instantiate class '" + className + "'.", e);
+            }
+        }
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycleConfig.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycleConfig.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycleConfig.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,81 @@
+/*
+ * 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.esb.file.lifecycle;
+
+import java.util.Properties;
+
+/**
+ * File Lifecycle Configuration.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class FileLifecycleConfig
+{
+    /**
+     * The pattern used for renaming a file when entering the working state.
+     */
+    private String workingRenamePattern;
+
+    /**
+     * The pattern used for renaming a file when an error occurs.
+     */
+    private String errorRenamePattern;
+
+    /**
+     * The pattern used for renaming a file when entering the processed state.
+     */
+    private String processedRenamePattern;
+
+    /**
+     * Configures this instance.
+     *
+     * @param properties The properties used in initialize this instance.
+     */
+    public final void setConfiguration(final Properties properties)
+    {
+        workingRenamePattern = properties.getProperty(FileLifecycle.WORKING_RENAME_PATTERN, FileLifecycle.PREFIX_TOKEN + "." + FileLifecycle.SUFFIX_TOKEN + ".working");
+        errorRenamePattern = properties.getProperty(FileLifecycle.ERROR_RENAME_PATTERN, FileLifecycle.PREFIX_TOKEN + "." + FileLifecycle.SUFFIX_TOKEN + ".error");
+        processedRenamePattern = properties.getProperty(FileLifecycle.PROCESSED_RENAME_PATTERN);
+    }
+
+    /**
+     * @return String The working rename pattern.
+     */
+    public final String getWorkingRenamePattern()
+    {
+        return workingRenamePattern;
+    }
+
+    /**
+     * @return String The error rename pattern.
+     */
+    public final String getErrorRenamePattern()
+    {
+        return errorRenamePattern;
+    }
+
+    /**
+     * @return String The procesed rename pattern.
+     */
+    public final String getProcessedRenamePattern()
+    {
+        return processedRenamePattern;
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycleFactory.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycleFactory.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/FileLifecycleFactory.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,95 @@
+/*
+ * 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.esb.file.lifecycle;
+
+import java.util.Properties;
+
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.jboss.esb.classpath.ClassUtil;
+
+/**
+ * FileLifecycle Factory.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public interface FileLifecycleFactory
+{
+    /**
+     * Factory method..
+     *
+     * @return FileLifecycle A newly created FileLifecycle instance.
+     */
+    FileLifecycle newInstance();
+
+    /**
+     * Configures this factory.
+     *
+     * @param properties The properties used to initialize this instance.
+     * @throws ConfigurationException If an invalid property is passed in.
+     */
+    void configure(final Properties properties) throws ConfigurationException;
+
+    /**
+     * Factory for creating FileLifecycleFactories.
+     */
+    public static final class Factory
+    {
+        /**
+         * Private constructor.
+         */
+        private Factory()
+        {
+        }
+
+        /**
+         * Factory method.
+         *
+         * @param className The name of the class to create. Must implement FileLifecycleFactory.
+         * @param properties The properties used to initialize this instance.
+         * @return FileLifycycleFactory A newly created and configured instance.
+         * @throws ConfigurationException If an invalid property is passed in.
+         */
+        public static FileLifecycleFactory newInstance(final String className, final Properties properties) throws ConfigurationException
+        {
+            try
+            {
+                FileLifecycleFactory factory = (FileLifecycleFactory) ClassUtil.forName(className, FileLifecycleFactory.class).newInstance();
+                factory.configure(properties);
+                return factory;
+            }
+            catch (final ClassCastException e)
+            {
+                throw new ConfigurationException("Class '" + className + "' must implement '" + FileLifecycleFactory.class.getName() + "'.");
+            }
+            catch (final ClassNotFoundException e)
+            {
+                throw new ConfigurationException("Class '" + className + "' not found.");
+            }
+            catch (final IllegalAccessException e)
+            {
+                throw new ConfigurationException("Cannot instantiate class '" + className + "'.", e);
+            }
+            catch (final InstantiationException e)
+            {
+                throw new ConfigurationException("Cannot instantiate class '" + className + "'.", e);
+            }
+        }
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/package.html	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/lifecycle/package.html	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+JBoss Routing - File - Lifecycle.
+
+<h1>Overview</h1>
+</body>
+</html>
\ No newline at end of file

Deleted: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/overview.html
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/overview.html	2008-10-31 07:35:07 UTC (rev 23641)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/overview.html	2008-10-31 07:45:16 UTC (rev 23642)
@@ -1,8 +0,0 @@
-<html>
-<head></head>
-<body>
-JBoss Routing - File.
-
-<h1>Overview</h1>
-</body>
-</html>
\ No newline at end of file

Copied: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/package.html (from rev 23607, labs/jbossesb/workspace/skeagh/routing/file/src/main/java/overview.html)
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/package.html	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/package.html	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+JBoss Routing - File.
+
+<h1>Overview</h1>
+</body>
+</html>
\ No newline at end of file


Property changes on: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/package.html
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/FileInboundRouterTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/FileInboundRouterTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/FileInboundRouterTest.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,168 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors 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.esb.file;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.routing.MessageDispatcher;
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentUtil;
+import org.jboss.esb.deploy.config.InboundRouterConfig;
+import org.jboss.esb.file.composers.AbstractFileMessageComposer;
+import org.jboss.esb.schedule.SchedulingException;
+import org.jboss.esb.util.FileUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Unit test for {@link FileInboundRouter}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class FileInboundRouterTest
+{
+    private static DeploymentRuntime runtime;
+    private static InboundRouterConfig inboundRouterConfig;
+
+    private File testFile;
+    private String testPayload = "Some payload text..";
+
+    @Test
+    public void onSchedule() throws IOException, SchedulingException, ConfigurationException
+    {
+        FileInboundRouter fileRouter = (FileInboundRouter) inboundRouterConfig.getRouter();
+
+        MockDispatcher dispatcher = new MockDispatcher();
+        fileRouter.setDispatcher(dispatcher);
+
+        fileRouter.initialize();
+        fileRouter.onSchedule();
+
+        File processedFile = new File(testFile.getAbsoluteFile() + ".processed");
+        assertTrue(processedFile.exists());
+        assertEquals(testPayload, new String(FileUtil.readTextFile(processedFile)));
+    }
+
+    @Test
+    public void verifyThatFileMetaDataHasBeenSetOnInvocationContext() throws SchedulingException, ConfigurationException
+    {
+        FileInboundRouter fileRouter = (FileInboundRouter) inboundRouterConfig.getRouter();
+        MockDispatcher dispatcher = new MockDispatcher();
+        fileRouter.setDispatcher(dispatcher);
+        fileRouter.initialize();
+        fileRouter.onSchedule();
+
+        InvocationContext context = dispatcher.getInvocationContext();
+        assertNotNull(context.getContextObject(AbstractFileMessageComposer.PROP_FILE_LASTMOD));
+        assertNotNull(context.getContextObject(AbstractFileMessageComposer.PROP_FILE_PATH));
+        assertNotNull(context.getContextObject(AbstractFileMessageComposer.PROP_FILE_LIFECYCLE));
+        assertNotNull(context.getContextObject(AbstractFileMessageComposer.PROP_FILE_OBJ));
+        assertNotNull(context.getContextObject(AbstractFileMessageComposer.PROP_FILE_LENGTH));
+    }
+
+    @Before
+    public void createFile() throws IOException
+    {
+        testFile = createFile((FileInboundRouter) inboundRouterConfig.getRouter(), testPayload);
+    }
+
+    @After
+    public void deleteFile()
+    {
+        if (testFile != null)
+        {
+            testFile.delete();
+        }
+
+        File processedFile = new File(testFile.getAbsoluteFile() + ".processed");
+        if (processedFile.exists())
+        {
+           processedFile.delete();
+        }
+    }
+
+    @BeforeClass
+    public static void classSetup() throws DeploymentException, IOException
+    {
+        runtime = DeploymentUtil.createRuntime(FileInboundRouterTest.class.getResourceAsStream("file-inbound-router_01.xml"));
+        inboundRouterConfig = DeploymentUtil.getInboundRouter("fileRouter", runtime);
+        assertNotNull("There should have been an router named 'fileRouter' in the config", inboundRouterConfig);
+    }
+
+    private File createFile(final FileInboundRouter fileRouter, final String payload) throws IOException
+    {
+        final File workingDir = new File(fileRouter.getInputDirName());
+        final File file = new File(workingDir, "fileRouterTest.txt");
+
+        final FileWriter fileWriter = new FileWriter(file);
+        try
+        {
+            fileWriter.write(payload);
+        }
+        finally
+        {
+            fileWriter.close();
+        }
+        return file;
+    }
+
+    private class MockDispatcher implements MessageDispatcher
+    {
+        private Message message;
+        public Message getMessage()
+        {
+            return message;
+        }
+
+        public InvocationContext getInvocationContext()
+        {
+            return invocationContext;
+        }
+
+        private InvocationContext invocationContext;
+
+        public void dispatch(Message message, InvocationContext invocationContext)
+        {
+            this.message = message;
+            this.invocationContext = invocationContext;
+        }
+
+        public boolean isProcessingMessages()
+        {
+            return false;
+        }
+
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/MyTestService.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/MyTestService.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/MyTestService.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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-2008, JBoss Inc.
+ */
+package org.jboss.esb.file;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.service.Service;
+import org.jboss.esb.api.service.ServiceException;
+
+/**
+ * Simple Test service
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class MyTestService implements Service
+{
+    private static Message message;
+
+    public Message process(Message message) throws ServiceException
+    {
+        MyTestService.message = message;
+        return message;
+    }
+
+    public static Message getMessage()
+    {
+        return message;
+    }
+
+
+
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/file-inbound-router_01.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/file-inbound-router_01.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/file-inbound-router_01.xml	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,20 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+	<resources>
+        <resource id="schedule1" class="org.jboss.esb.schedule.SimpleSchedule">
+            <property name="frequency">100</property>
+            <property name="execCount">1</property>
+        </resource>
+    </resources>
+
+    <services>
+        <service serviceCategory="service-cat" serviceName="service-a" serviceDescription="TestService" class="org.jboss.esb.file.MyTestService">
+            <inRouter name="fileRouter" class="org.jboss.esb.file.FileInboundRouter">
+                <property name="scheduleResourceId">schedule1</property>
+                <property name="inputDir">target/</property>
+                <property name="fileSelectorPattern">*.txt</property>
+            </inRouter>
+        </service>
+    </services> 
+    
+</jbossesb>
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycleTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycleTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/lifecycle/DefaultFileLifecycleTest.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors 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.esb.file.lifecycle;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.junit.Test;
+
+/**
+ * Test for {@link DefaultFileLifecycle}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class DefaultFileLifecycleTest
+{
+    @Test
+    public void setFile() throws IOException
+    {
+        DefaultFileLifecycle fileLifecycle = new DefaultFileLifecycle();
+        File file = File.createTempFile("junit", ".test");
+        fileLifecycle.setFile(file);
+
+        List<File> fileHistory = fileLifecycle.getFileHistory();
+        assertEquals(1, fileHistory.size());
+
+        file = File.createTempFile("junit2", ".test");
+        fileLifecycle.setFile(file);
+        assertEquals(1, fileHistory.size());
+    }
+
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/lifecycle/FileLifecycleTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/lifecycle/FileLifecycleTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/lifecycle/FileLifecycleTest.java	2008-10-31 07:45:16 UTC (rev 23642)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors 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.esb.file.lifecycle;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Properties;
+
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.junit.Test;
+
+
+/**
+ * Test for {@link FileLifecycle}
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class FileLifecycleTest
+{
+    @Test
+    public void newInstance() throws ConfigurationException
+    {
+        FileLifecycleConfig fileLifecycleConfig = new FileLifecycleConfig();
+        Properties properties = new Properties();
+        properties.setProperty(FileLifecycle.WORKING_RENAME_PATTERN, ".work");
+
+        fileLifecycleConfig.setConfiguration(properties);
+        FileLifecycle newInstance = FileLifecycle.Factory.newInstance("org.jboss.esb.file.lifecycle.DefaultFileLifecycle", fileLifecycleConfig);
+        assertNotNull(newInstance);
+        assertTrue(newInstance instanceof DefaultFileLifecycle);
+    }
+
+}

Modified: labs/jbossesb/workspace/skeagh/routing/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/pom.xml	2008-10-31 07:35:07 UTC (rev 23641)
+++ labs/jbossesb/workspace/skeagh/routing/pom.xml	2008-10-31 07:45:16 UTC (rev 23642)
@@ -15,7 +15,7 @@
     <url>http://www.jboss.org/jbossesb/</url>
 
     <modules>
-        <!-- module>file</module -->
+        <module>file</module>
         <module>jms</module>
     </modules>
 




More information about the jboss-svn-commits mailing list