[jboss-svn-commits] JBL Code SVN: r6548 - in labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions: . converters routing templates

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Oct 3 09:46:42 EDT 2006


Author: mark.little at jboss.com
Date: 2006-10-03 09:46:32 -0400 (Tue, 03 Oct 2006)
New Revision: 6548

Added:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/ByteArrayToString.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/FileToByteArray.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/ObjectToCSVString.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/ObjectToXStream.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/routing/
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/routing/FileCopier.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/routing/JMSRouter.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/routing/ObjectToFileWriter.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockAction.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockFileAction.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockSqlRowAction.java
Removed:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyAction.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyFileAction.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToFileWriter.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToXStream.java
Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java
Log:
http://jira.jboss.com/jira/browse/JBESB-152

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/AbstractFileAction.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -28,7 +28,7 @@
  * <p/>
  * Extend this class if you need to implement an action class intended to process one file at a time.
  * <p/>
- * See {@link org.jboss.soa.esb.actions.FileCopier} as an example.
+ * See {@link org.jboss.soa.esb.actions.routing.FileCopier} as an example.
  * <p/>
  * This class are stateful.
  * @author Esteban.

Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-
-import org.jboss.soa.esb.helpers.KeyValuePair;
-
-/**
- * Byte Array to String processor.
- * <p/>
- * Sample Action Configuration:
- * <pre>
- * &lt;Action name="Bytes-To-UTF-8-String" processor="ByteArrayToString"&gt;
- *     &lt;property name="encoding" value="UTF-8" /&gt; &lt;!-- Default of "UTF-8". --&gt;
- * &lt;/Action&gt;
- * </pre>
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class ByteArrayToString implements ActionProcessor {
-    
-    private String encoding;
-    
-    /**
-     * Public constructor.
-     * @param actionName Processing action name.
-     * @param properties Action properties.
-     */
-    public ByteArrayToString(String actionName, List<KeyValuePair> properties) {
-        encoding = KeyValuePair.getValue("encoding", properties, "UTF-8");
-    }
-    
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
-     */
-    public Object process(Object message) throws ActionProcessingException {
-        byte[] bytes;
-        
-        try {
-            bytes = (byte[])message;
-        } catch(ClassCastException e) {
-            throw new ActionProcessingException("Message must be an array of bytes. Is " + message.getClass().getName());
-        }
-        
-        try {
-            return new String(bytes, encoding);
-        } catch (UnsupportedEncodingException e) {
-            throw new ActionProcessingException("Unable to decode byte[] to String. Unsupported character encoding configuration: " + encoding, e);
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
-     */
-    public Serializable getOkNotification(Object message) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
-     */
-    public Serializable getErrorNotification(Object message) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-}

Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyAction.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyAction.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -1,45 +0,0 @@
-package org.jboss.soa.esb.actions;
-
-import java.io.Serializable;
-import java.text.SimpleDateFormat;
-
-import org.apache.log4j.Logger;
-
-
-/**
- * Use this class to tune your XML configurations <p/>Once your config works
- * with this dummy class, you can switch to your own action class <p/>You will
- * have to implement these three methods in your own action class
- * 
- * @author Esteban
- * 
- */
-public class DummyAction implements ActionProcessor {
-    /**
-     * Class Logger.
-     */
-    private static Logger logger = Logger.getLogger(DummyAction.class);
-
-    public Object process(Object message) {
-        logger.info("process was called with <<" + message.toString() + ">>");
-        return message;
-    } // ________________________________
-
-    private SimpleDateFormat s_oTS = new SimpleDateFormat(
-            "yyyy/MM/dd hh:mm:ss.SSS");
-
-    private String getStamp() {
-        return s_oTS.format(new java.util.Date(System.currentTimeMillis()));
-    }
-
-    public Serializable getOkNotification(Object message) {
-        return getStamp() + " Notif OK - <"
-                + ((null == message) ? "null" : message.toString()) + ">";
-    } // ________________________________
-
-    public Serializable getErrorNotification(Object message) {
-        return getStamp() + " Notif ERROR - <"
-                + ((null == message) ? "null" : message.toString()) + ">";
-    } // ________________________________
-
-} // ____________________________________________________________________________

Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyFileAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyFileAction.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummyFileAction.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -1,48 +0,0 @@
-package org.jboss.soa.esb.actions;
-
-import java.io.File;
-import java.io.Serializable;
-import java.text.SimpleDateFormat;
-
-import org.apache.log4j.Logger;
-
-/**
- * Use this class to tune your XML configurations
- * <p/>Once your config works with this dummy class, you can
- * switch to your own action class
- * <p/>You will have to implement these three methods 
- * in your own action class
- * 
- * @author Esteban
- *
- */
-public class DummyFileAction extends AbstractFileAction 
-{
-    private static Logger logger = Logger.getLogger(DummyFileAction.class);
-	
-	@Override
-	public Object process(File file) throws ActionProcessingException 
-	{
-        logger.info("processObject was called with <<" + file.getAbsolutePath() + ">>");
-        return file;
-	} //________________________________
-	
-	private SimpleDateFormat s_oTS = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS");
-	private String getStamp() 
-		{ return s_oTS.format(new java.util.Date(System.currentTimeMillis())); }
-
-	public Serializable getOkNotification(Object message)
-	{
-		return getStamp()+" Notif OK - <"
-		+((null==message)?"null":message.toString())
-		+">";
-	} //________________________________
-
-	public Serializable getErrorNotification(Object message)
-	{
-		return getStamp()+" Notif ERROR - <"
-		+((null==message)?"null":message.toString())
-		+">";
-	} //________________________________
-	
-} //____________________________________________________________________________

Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/DummySqlRowAction.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -1,59 +0,0 @@
-package org.jboss.soa.esb.actions;
-
-import java.io.Serializable;
-import java.text.SimpleDateFormat;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.jboss.soa.esb.helpers.KeyValuePair;
-
-/**
- * Use this class to tune your XML configurations
- * <p/>Once your config works with this dummy class, you can
- * switch to your own action class
- * <p/>You will have to implement these three methods 
- * in your own action class
- * 
- * @author Esteban
- *
- */
-public class DummySqlRowAction extends AbstractSqlRowAction 
-{
-    
-    public static List<Map> params = new Vector<Map>();
-
-    public DummySqlRowAction(String actionName, List<KeyValuePair> properties) throws Exception {
-        super(actionName, properties);
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.AbstractSqlRowAction#processSQL()
-     */
-    @Override
-    protected Object process(Map resultSet) {
-        logger.info("processResultset was called with <<"
-                + resultSet.toString()+">>");
-        params.add(resultSet);
-        
-        return resultSet;
-    }
-	
-	private SimpleDateFormat s_oTS = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS");
-	private String getStamp() 
-		{ return s_oTS.format(new java.util.Date(System.currentTimeMillis())); }
-
-	public Serializable getOkNotification(Object message)
-	{
-		return getStamp()+" Notif OK - <"
-		+((null==message)?"null":message.toString())
-		+">";
-	} //________________________________
-
-	public Serializable getErrorNotification(Object message)
-	{
-		return getStamp()+" Notif ERROR - <"
-		+((null==message)?"null":message.toString())
-		+">";
-	} //________________________________
-} //____________________________________________________________________________

Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -1,142 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.KeyValuePair;
-import org.jboss.soa.esb.listeners.DirectoryPoller.WorkingFile;
-
-/**
- * File copy action.
- * <p/>
- * Copy the file specified by the "fileParams" arg in {@link #process(File)} to the location specified by the 
- * action config properties.
- * <p/>
- * Sample Action Configuration:
- * <pre>
- * &lt;Action name="Copy-To-XXX" processor="FileCopier"&gt;
- *     &lt;property name="copyToDirURI" value="file:///..." /&gt;
- *     &lt;property name="copyToSuffix" value=".fileCopierOutput" /&gt;
- * &lt;/Action&gt;
- * </pre>
- * 
- * @author Esteban
- */
-public class FileCopier extends AbstractFileAction {
-    
-    private static Logger logger = Logger.getLogger(FileCopier.class);
-    
-    private static final String TMP_SUFFIX = ".notReady";
-
-    private static final String PARMS_OUTDIR = "copyToDirURI";
-
-    private static final String PARMS_OUTSFX = "copyToSuffix";
-
-    private File outputDir;
-    private String copyToSuffix;
-
-    /**
-     * Public constructor.
-     * @param actionName Action name.
-     * @param properties Action Properties.
-     * @throws ConfigurationException Action not properly configured.
-     */
-    public FileCopier(String actionName, List<KeyValuePair> properties) throws URISyntaxException {
-        String outputDirParam = KeyValuePair.getValue(PARMS_OUTDIR, properties);
-        
-        try {
-            outputDir = new File(new URI(outputDirParam));
-        } catch(Exception e) {
-            outputDir = new File(outputDirParam);
-        }
-        copyToSuffix = KeyValuePair.getValue(PARMS_OUTSFX, properties, ".copy");
-    } // __________________________________
-
-    public Object process(File file) throws ActionProcessingException {
-        WorkingFile workingFile;
-        
-        try {
-            workingFile = (WorkingFile)file;
-        } catch(ClassCastException e) {
-            throw new ActionProcessingException("File must be an instance of " + WorkingFile.class.getName());
-        }
-        
-        File outputFile = new File(outputDir, workingFile.getInputFile().getName() + copyToSuffix);
-        
-        try {
-            File tempFile = File.createTempFile(workingFile.getName(), TMP_SUFFIX, outputDir);
-            FileInputStream inputFileStream = new FileInputStream(workingFile);
-            FileOutputStream outputFileStream;
-            
-            outputFileStream = new FileOutputStream(tempFile);
-    
-            // Perform Copy
-            byte[] ba = new byte[1024];
-            while (true) {
-                int iQ = inputFileStream.read(ba);
-                
-                if (iQ < 0) {
-                    break;
-                }
-    
-                outputFileStream.write(ba, 0, iQ);
-            }
-            // Close
-            inputFileStream.close();
-            outputFileStream.close();
-    
-            // Rename
-            outputFile.delete();
-            tempFile.renameTo(outputFile);
-            
-            if(logger.isDebugEnabled()) {
-                logger.debug("Successfully copied file " + workingFile.getAbsolutePath() + " to file " + outputFile.getAbsolutePath());
-            }
-        } catch(IOException e) {
-            throw new ActionProcessingException("IOException copying " + workingFile.getAbsolutePath() + " to " + outputFile.getAbsolutePath(), e);
-        }
-        
-        return workingFile;
-    } // __________________________________
-
-    public Serializable getOkNotification(Object message) {
-        return "File " + ((WorkingFile)message).getInputFile().getAbsolutePath()
-                + " successfully copied to all destination";
-    }
-
-    public Serializable getErrorNotification(Object message) {
-        return "Problems copying " + ((WorkingFile)message).getInputFile().getAbsolutePath()
-                + " to configured destination";
-    }
-
-} // ____________________________________________________________________________

Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -1,95 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.Serializable;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.listeners.DirectoryPoller.WorkingFile;
-
-/**
- * File data to byte array reader {@link org.jboss.soa.esb.actions.ActionProcessor}.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class FileToByteArray extends AbstractFileAction {
-    
-    /**
-     * Logger.
-     */
-    private static Logger logger = Logger.getLogger(FileToByteArray.class);
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.AbstractFileAction#process(java.io.File)
-     */
-    @Override
-    protected Object process(File file) throws ActionProcessingException {
-        ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream();
-        FileInputStream fileInputStream = null;
-        
-        try {
-            fileInputStream = new FileInputStream(file);
-        } catch (FileNotFoundException e) {
-            throw new ActionProcessingException("IOException reading file contents. File not found.", e);
-        }
-        
-        try {
-            byte[] readBuffer = new byte[512];
-            int readCount = 0;
-            
-            while((readCount = fileInputStream.read(readBuffer)) != -1) {
-                outputBuffer.write(readBuffer, 0, readCount);
-            }            
-        } catch (IOException e) {
-            throw new ActionProcessingException("IOException reading file contents.", e);
-        } finally {
-            try {
-                fileInputStream.close();
-            } catch (IOException e) {
-                logger.warn("Error closing input file.", e);
-            }
-        }
-        
-        return outputBuffer.toByteArray();
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
-     */
-    public Serializable getOkNotification(Object message) {
-        return "Successfully read file contents of " + ((WorkingFile)message).getInputFile() + " into byte array.";
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
-     */
-    public Serializable getErrorNotification(Object message) {
-        return "Failed to read file contents of " + ((WorkingFile)message).getInputFile() + " into byte array.";
-    }
-
-}

Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -1,196 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.io.Serializable;
-import java.util.List;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueSession;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.common.Configuration;
-import org.jboss.soa.esb.helpers.AppServerContext;
-import org.jboss.soa.esb.helpers.KeyValuePair;
-
-/**
- * JSM Routing Action Processor.
- * <p/>
- * Sample Action Configuration:
- * <pre>
- * &lt;Action name="Route-To-Invoicing" processor="JMSRouter"&gt;
- *     &lt;property name="jndiName" value="queue/A" /&gt;
- *     &lt;property name="message-prop:jms-selector" value="incoming-invoice" /&gt;
- * &lt;/Action&gt;
- * </pre>
- * Note how properties to be set on the message are prefixed with "message-prop:".
- * <p/>
- * TODO: Add support for JMS Topic destinations.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class JMSRouter implements ActionProcessor {
-    /**
-     * Logger.
-     */
-    private static Logger logger = Logger.getLogger(JMSRouter.class);
-    /**
-     * Routing properties.
-     */
-    private List<KeyValuePair> properties;
-    /**
-     * JMS Queue setup.
-     */
-    private JMSSendQueueSetup queueSetup;
-
-    /**
-     * Public constructor.
-     * @param actionName Action name.
-     * @param properties Action properties.
-     * @throws ConfigurationException Queue name not configured.
-     * @throws JMSException Unable to configure JMS destination.
-     * @throws NamingException Unable to configure JMS destination.
-     */
-    public JMSRouter(String actionName, List<KeyValuePair> properties) throws ConfigurationException, NamingException, JMSException {
-        this.properties = properties;
-        
-        String queueName = KeyValuePair.getValue("jndiName", properties);
-        if(queueName == null) {
-            throw new ConfigurationException("JMSRouter must specify a 'jndiName' property.");
-        }
-        queueSetup = new JMSSendQueueSetup(queueName);
-        this.properties = properties;
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
-     */
-    public Object process(Object message) throws ActionProcessingException {
-        if(!(message instanceof Serializable)) {
-            throw new ActionProcessingException("Cannot send Object [" + message.getClass().getName() + "] to destination [" + queueSetup.queueName + "]. Object must be serializable.");
-        }
-        
-        try {
-            // Send a Text or Object message to the queue...
-            if (message instanceof String) {
-                TextMessage oMsg = queueSetup.jmsSession.createTextMessage();
-    
-                if(logger.isDebugEnabled()) {
-                    logger.debug("Sending Text message: [" + message + "] to destination [" + queueSetup.queueName + "].");
-                }
-                oMsg.setText((String)message);
-                setStringProperties(oMsg);
-                queueSetup.jmsProducer.send(oMsg);
-            } else {
-                ObjectMessage oMsg = queueSetup.jmsSession.createObjectMessage();
-                
-                if(logger.isDebugEnabled()) {
-                    logger.debug("Sending Object message: [" + message + "] to destination [" + queueSetup.queueName + "].");
-                }
-                oMsg.setObject((Serializable) message);
-                setStringProperties(oMsg);
-                queueSetup.jmsProducer.send(oMsg);
-            }
-        } catch(Exception e) {
-            String errorMessage = "Exception while sending message [" + message + "] to destination [" + queueSetup.queueName + "].";
-            logger.error(errorMessage, e);
-            throw new ActionProcessingException(errorMessage, e);
-        }
-        
-        return message;
-    }
-
-    private void setStringProperties(Message msg) throws JMSException {
-        String messagePropPrefix = "message-prop:";
-
-        for(KeyValuePair property : properties) {
-            String key = property.getKey();
-            
-            if(key.startsWith(messagePropPrefix) && key.length() > messagePropPrefix.length()) {
-                msg.setStringProperty(key.substring(messagePropPrefix.length()), property.getValue());
-            }
-        }
-    }
-    
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
-     */
-    public Serializable getOkNotification(Object message) {
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
-     */
-    public Serializable getErrorNotification(Object message) {
-        return null;
-    }
-
-    @Override
-    protected void finalize() throws Throwable {
-        queueSetup.close();
-        super.finalize();
-    }
-    
-    private static class JMSSendQueueSetup {
-        QueueSession jmsSession;
-        Queue jmsQueue;
-        MessageProducer jmsProducer;
-        String queueName;
-        
-        // TODO: Modify to support topic destinations too
-
-        private JMSSendQueueSetup(String queueName) throws NamingException, JMSException  {
-            Context m_oCtx = AppServerContext.getServerContext(
-                    Configuration.getJndiServerType(), 
-                    Configuration.getJndiServerURL());           
-            QueueConnectionFactory qcf = (QueueConnectionFactory) m_oCtx.lookup("ConnectionFactory");
-            QueueConnection oQconn = qcf.createQueueConnection();
-
-            this.queueName = queueName;
-            
-            jmsSession = oQconn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
-            jmsQueue = (Queue) m_oCtx.lookup(queueName);
-            jmsProducer = jmsSession.createSender(jmsQueue);            
-        }
-        
-        private void close() {
-            try {
-                jmsProducer.close();
-                jmsSession.close();
-            } catch (Exception e) {
-                logger.error("Unable to close JMS Queue Setup.", e);
-            }
-        }
-    }
-}

Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.KeyValuePair;
-
-/**
- * Object to CSV String processor.
- * <p/>
- * Returns a CSV string based on the supplied message object and a comma-separated "bean-properties"
- * action property that specifies a list of bean property names.
- * <p/>
- * Sample Action Configuration:
- * <pre>
- * &lt;Action name="Customer-To-CSV" processor="ObjectToCSVString"&gt;
- *     &lt;property name="bean-properties" value="name,address1,address2,phone" /&gt;
- * &lt;/Action&gt;
- * </pre>
- * <p/>
- * TODO: Add support for arrays ala producing the contents of a CSV file.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class ObjectToCSVString implements ActionProcessor {
-
-    public static final String BEAN_PROPERTIES_PROP = "bean-properties";
-    private static Logger logger = Logger.getLogger(ObjectToCSVString.class);
-    private List<String> propertyMethodNames = new ArrayList<String>();
-    
-    /**
-     * Public constructor.
-     * @param actionName Action name.
-     * @param properties Action Properties.
-     * @throws ConfigurationException Action not properly configured.
-     */
-    public ObjectToCSVString(String actionName, List<KeyValuePair> properties) throws ConfigurationException {
-        String objectProps = KeyValuePair.getValue(BEAN_PROPERTIES_PROP, properties);
-        
-        if(objectProps == null || objectProps.trim().equals("")) {
-            throw new ConfigurationException("Action [" + actionName + "] must specify a comma seperated object bean property list via a '" + BEAN_PROPERTIES_PROP + "' property setting.");
-        }
-        
-        // Construct a bean method name list from the configured property name list...
-        String[] propertyNames = objectProps.split(",");
-        StringBuffer methodNameConstructionBuffer = new StringBuffer();
-        for(String propertyName : propertyNames) {
-            propertyName = propertyName.trim();
-            
-            if(propertyName.equals("")) {
-                continue;
-            }
-            
-            methodNameConstructionBuffer.setLength(0);
-            methodNameConstructionBuffer.append("get");
-            methodNameConstructionBuffer.append(propertyName);
-            
-            // Capitalise the 4th char to make it a proper bean method....
-            methodNameConstructionBuffer.setCharAt(3, Character.toUpperCase(methodNameConstructionBuffer.charAt(3)));
-
-            // Add to the set...
-            propertyMethodNames.add(methodNameConstructionBuffer.toString());
-        }
-    }
-    
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
-     */
-    public Object process(Object message) throws ActionProcessingException {
-        StringBuffer csv = new StringBuffer();
-        boolean hasAppendStarted = false; // Have we appended a value yet?
-        
-        for(String methodName : propertyMethodNames) {
-            Method method;
-
-            if(hasAppendStarted) {
-                csv.append(",");
-            }
-            hasAppendStarted = true;
-
-            // Get the bean method....
-            try {
-                method = message.getClass().getMethod(methodName, new Class[] {});
-            } catch (Exception e) {
-                logger.error("Bean method: " + methodName + " not found/accessible on message object " + message.getClass().getName(), e);
-                continue;
-            }
-
-            // Call the bean method and add the toString of the return to the CSV string....
-            try {
-                Object value = method.invoke(message, new Object[] {});
-                // TODO: Some sort of encoding is required here to make a proper CSV string...
-                csv.append(value != null?value.toString():"");
-            } catch (Exception e) {
-                logger.error("Exception calling bean method: " + methodName, e);
-            }
-        }
-        
-        return csv.toString();
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
-     */
-    public Serializable getOkNotification(Object message) {
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
-     */
-    public Serializable getErrorNotification(Object message) {
-        return null;
-    }
-}

Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToFileWriter.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToFileWriter.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToFileWriter.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -1,170 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.URI;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.KeyValuePair;
-
-/**
- * Object to file writing processor.
- * <p/>
- * Writes an Object to a file based on the "file" property specified by the action configuration.  This "file"
- * property can specify a file or directory.  If the file is a directory, the class generates a file name based
- * on the return from a call to {@link java.util.UUID#randomUUID()} and the file extension value specified in
- * the "ext" property (default of "obj").
- * <p/>
- * If the message is a byte array it's writen to the file as is, otherwise the toString method is called on the
- * message object and the resulting String bytes are writen to the file based on the "encoding" specified in the action
- * configuration (see below).
- * <p/>
- * Sample Action Configuration:
- * <pre>
- * &lt;Action name="Write-To-X-File" processor="ObjectToFileWriter"&gt;
- *     &lt;property name="file" value="file:///..." /&gt; &lt;!-- File/Directory name. Supports URI or non-URI based names. --&gt;
- *     &lt;property name="append" value="true/false" /&gt; &lt;!-- Only relevant if the file is not a directory. Default of "false". --&gt;
- *     &lt;property name="ext" value="dat" /&gt; &lt;!-- Only relevant if the file is a directory. Default of "obj". --&gt;
- *     &lt;property name="encoding" value="UTF-8" /&gt; &lt;!-- Default of "UTF-8". --&gt;
- * &lt;/Action&gt;
- * </pre>
- * 
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class ObjectToFileWriter implements ActionProcessor {
-
-    public static final String FILE_NAME = "file";
-    public static final String FILE_APPEND = "append";
-    public static final String FILE_EXT = "ext";
-    public static final String FILE_ENC = "encoding";
-    private static Logger logger = Logger.getLogger(ObjectToFileWriter.class);
-    
-    private String actionName;
-    private File file;
-    private boolean append;
-    private String ext;
-    private String encoding;
-    
-    /**
-     * Public constructor.
-     * @param actionName Action name.
-     * @param properties Action Properties.
-     * @throws ConfigurationException Action not properly configured.
-     */
-    public ObjectToFileWriter(String actionName, List<KeyValuePair> properties) throws ConfigurationException {
-        String fileName = KeyValuePair.getValue(FILE_NAME, properties);
-        
-        this.actionName = actionName;
-        
-        if(fileName == null || fileName.trim().equals("")) {
-            throw new ConfigurationException("Action [" + actionName + "] must specify a '" + FILE_NAME + "' property specifying the name of the output file.");
-        }
-        try {
-            // try it as a URI first...
-            file = new File(new URI(fileName));
-        } catch (Exception e) {
-            // ok, just interpret it as being relative to the cwd...
-            file = new File(fileName);
-        }
-        append = KeyValuePair.getBooleanValue(FILE_APPEND, properties, false);
-        ext = KeyValuePair.getValue(FILE_EXT, properties, "obj");
-        encoding = KeyValuePair.getValue(FILE_ENC, properties, "UTF-8");
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
-     */
-    public Object process(Object message) throws ActionProcessingException {
-        synchronized(file) {
-            File outputFile = getOutputFile();
-            FileOutputStream fileOutputStream = null;
-
-            try {
-                fileOutputStream = new FileOutputStream(outputFile, append);
-            } catch (IOException e) {
-                throw new ActionProcessingException("Action " + actionName + " failed.  Unable to open output file " + outputFile.getAbsolutePath());
-            }
-            
-            try {
-                if(message instanceof byte[]) {
-                    fileOutputStream.write((byte[])message);
-                } else {
-                    fileOutputStream.write(message.toString().getBytes(encoding));
-                }
-                fileOutputStream.flush();
-            } catch (IOException e) {
-                throw new ActionProcessingException("Action " + actionName + " failed.  Unable to write to output file " + outputFile.getAbsolutePath(), e);
-            } finally {
-                try {
-                	fileOutputStream.close();
-                } catch (IOException e) {
-                    logger.warn("Exception on closing file " + file.getAbsolutePath(), e);
-                }
-            }
-            
-            return message;
-        }        
-    }
-
-    /**
-     * Get the output file.
-     * @return Output file.
-     */
-    private File getOutputFile() {
-        if(file.isDirectory()) {
-            UUID randomUUID = UUID.randomUUID();
-            File randomFile = new File(file, randomUUID.toString() + "." + ext);
-            
-            if(randomFile.exists()) {
-                return getOutputFile();
-            }
-            
-            return randomFile;
-        } else {
-            return file;
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
-     */
-    public Serializable getOkNotification(Object message) {
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
-     */
-    public Serializable getErrorNotification(Object message) {
-        return null;
-    }
-
-}

Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToXStream.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToXStream.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToXStream.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -1,100 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.actions;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.KeyValuePair;
-
-import com.thoughtworks.xstream.XStream;
-
-/**
- * Object to XML processor.
- * <p/>
- * Uses the <a href="http://xstream.codehaus.org/">XStream</a> processor to generate an XML message String from the supplied object.
- * <p/>
- * Sample Action Configuration:
- * <pre>
- * &lt;Action name="Customer-To-XML" processor="ObjectToXStream"&gt;
- *     &lt;property name="class-alias" value="Customer" /&gt; &lt;!-- Class alias used in call to <a href="http://xstream.codehaus.org/javadoc/com/thoughtworks/xstream/XStream.html">XStream.alias(String, Class)</a> prior to serialisation. --&gt;
- *     &lt;property name="exclude-package" value="false" /&gt; &lt;!-- Default "true".  Not applicable if a "class-alias" is specified. --&gt;
- * &lt;/Action&gt;
- * </pre>
- * <p/>
- * The XML root element is either set from the "class-alias" property or the classes full name.  In the later case, the class package is
- * excluded unless "exclude-package" is set to "false"/"no". 
- * 
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @since Version 4.0
- */
-public class ObjectToXStream implements ActionProcessor {
-    
-    private String classAlias;
-    private boolean excludePackage;
-    
-    /**
-     * Public constructor.
-     * @param actionName Action name.
-     * @param properties Action Properties.
-     * @throws ConfigurationException Action not properly configured.
-     */
-    public ObjectToXStream(String actionName, List<KeyValuePair> properties) {
-        classAlias = KeyValuePair.getValue("class-alias", properties);
-        excludePackage = KeyValuePair.getBooleanValue("exclude-package", properties, true);
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
-     */
-    public Object process(Object object) throws ActionProcessingException {
-        XStream xstream = new XStream();
-        
-        if(classAlias == null) {
-            if(excludePackage) {
-                xstream.alias(object.getClass().getSimpleName(), object.getClass());
-            } else {
-                xstream.alias(object.getClass().getName(), object.getClass());
-            }
-        } else {
-            xstream.alias(classAlias, object.getClass());
-        }
-        
-        return xstream.toXML(object);
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
-     */
-    public Serializable getOkNotification(Object message) {
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
-     */
-    public Serializable getErrorNotification(Object message) {
-        return null;
-    }
-}

Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/ByteArrayToString.java (from rev 6523, labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java)
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ByteArrayToString.java	2006-10-02 16:26:11 UTC (rev 6523)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/ByteArrayToString.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.actions.converters;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * Byte Array to String processor.
+ * <p/>
+ * Sample Action Configuration:
+ * <pre>
+ * &lt;Action name="Bytes-To-UTF-8-String" processor="ByteArrayToString"&gt;
+ *     &lt;property name="encoding" value="UTF-8" /&gt; &lt;!-- Default of "UTF-8". --&gt;
+ * &lt;/Action&gt;
+ * </pre>
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ByteArrayToString implements ActionProcessor {
+    
+    private String encoding;
+    
+    /**
+     * Public constructor.
+     * @param actionName Processing action name.
+     * @param properties Action properties.
+     */
+    public ByteArrayToString(String actionName, List<KeyValuePair> properties) {
+        encoding = KeyValuePair.getValue("encoding", properties, "UTF-8");
+    }
+    
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+     */
+    public Object process(Object message) throws ActionProcessingException {
+        byte[] bytes;
+        
+        try {
+            bytes = (byte[])message;
+        } catch(ClassCastException e) {
+            throw new ActionProcessingException("Message must be an array of bytes. Is " + message.getClass().getName());
+        }
+        
+        try {
+            return new String(bytes, encoding);
+        } catch (UnsupportedEncodingException e) {
+            throw new ActionProcessingException("Unable to decode byte[] to String. Unsupported character encoding configuration: " + encoding, e);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+     */
+    public Serializable getOkNotification(Object message) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+     */
+    public Serializable getErrorNotification(Object message) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/FileToByteArray.java (from rev 6523, labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java)
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileToByteArray.java	2006-10-02 16:26:11 UTC (rev 6523)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/FileToByteArray.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.actions.converters;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.AbstractFileAction;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.listeners.DirectoryPoller.WorkingFile;
+
+/**
+ * File data to byte array reader {@link org.jboss.soa.esb.actions.ActionProcessor}.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class FileToByteArray extends AbstractFileAction {
+    
+    /**
+     * Logger.
+     */
+    private static Logger logger = Logger.getLogger(FileToByteArray.class);
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.AbstractFileAction#process(java.io.File)
+     */
+    @Override
+    protected Object process(File file) throws ActionProcessingException {
+        ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream();
+        FileInputStream fileInputStream = null;
+        
+        try {
+            fileInputStream = new FileInputStream(file);
+        } catch (FileNotFoundException e) {
+            throw new ActionProcessingException("IOException reading file contents. File not found.", e);
+        }
+        
+        try {
+            byte[] readBuffer = new byte[512];
+            int readCount = 0;
+            
+            while((readCount = fileInputStream.read(readBuffer)) != -1) {
+                outputBuffer.write(readBuffer, 0, readCount);
+            }            
+        } catch (IOException e) {
+            throw new ActionProcessingException("IOException reading file contents.", e);
+        } finally {
+            try {
+                fileInputStream.close();
+            } catch (IOException e) {
+                logger.warn("Error closing input file.", e);
+            }
+        }
+        
+        return outputBuffer.toByteArray();
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+     */
+    public Serializable getOkNotification(Object message) {
+        return "Successfully read file contents of " + ((WorkingFile)message).getInputFile() + " into byte array.";
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+     */
+    public Serializable getErrorNotification(Object message) {
+        return "Failed to read file contents of " + ((WorkingFile)message).getInputFile() + " into byte array.";
+    }
+
+}

Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/ObjectToCSVString.java (from rev 6523, labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java)
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToCSVString.java	2006-10-02 16:26:11 UTC (rev 6523)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/ObjectToCSVString.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.actions.converters;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * Object to CSV String processor.
+ * <p/>
+ * Returns a CSV string based on the supplied message object and a comma-separated "bean-properties"
+ * action property that specifies a list of bean property names.
+ * <p/>
+ * Sample Action Configuration:
+ * <pre>
+ * &lt;Action name="Customer-To-CSV" processor="ObjectToCSVString"&gt;
+ *     &lt;property name="bean-properties" value="name,address1,address2,phone" /&gt;
+ * &lt;/Action&gt;
+ * </pre>
+ * <p/>
+ * TODO: Add support for arrays ala producing the contents of a CSV file.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ObjectToCSVString implements ActionProcessor {
+
+    public static final String BEAN_PROPERTIES_PROP = "bean-properties";
+    private static Logger logger = Logger.getLogger(ObjectToCSVString.class);
+    private List<String> propertyMethodNames = new ArrayList<String>();
+    
+    /**
+     * Public constructor.
+     * @param actionName Action name.
+     * @param properties Action Properties.
+     * @throws ConfigurationException Action not properly configured.
+     */
+    public ObjectToCSVString(String actionName, List<KeyValuePair> properties) throws ConfigurationException {
+        String objectProps = KeyValuePair.getValue(BEAN_PROPERTIES_PROP, properties);
+        
+        if(objectProps == null || objectProps.trim().equals("")) {
+            throw new ConfigurationException("Action [" + actionName + "] must specify a comma seperated object bean property list via a '" + BEAN_PROPERTIES_PROP + "' property setting.");
+        }
+        
+        // Construct a bean method name list from the configured property name list...
+        String[] propertyNames = objectProps.split(",");
+        StringBuffer methodNameConstructionBuffer = new StringBuffer();
+        for(String propertyName : propertyNames) {
+            propertyName = propertyName.trim();
+            
+            if(propertyName.equals("")) {
+                continue;
+            }
+            
+            methodNameConstructionBuffer.setLength(0);
+            methodNameConstructionBuffer.append("get");
+            methodNameConstructionBuffer.append(propertyName);
+            
+            // Capitalise the 4th char to make it a proper bean method....
+            methodNameConstructionBuffer.setCharAt(3, Character.toUpperCase(methodNameConstructionBuffer.charAt(3)));
+
+            // Add to the set...
+            propertyMethodNames.add(methodNameConstructionBuffer.toString());
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+     */
+    public Object process(Object message) throws ActionProcessingException {
+        StringBuffer csv = new StringBuffer();
+        boolean hasAppendStarted = false; // Have we appended a value yet?
+        
+        for(String methodName : propertyMethodNames) {
+            Method method;
+
+            if(hasAppendStarted) {
+                csv.append(",");
+            }
+            hasAppendStarted = true;
+
+            // Get the bean method....
+            try {
+                method = message.getClass().getMethod(methodName, new Class[] {});
+            } catch (Exception e) {
+                logger.error("Bean method: " + methodName + " not found/accessible on message object " + message.getClass().getName(), e);
+                continue;
+            }
+
+            // Call the bean method and add the toString of the return to the CSV string....
+            try {
+                Object value = method.invoke(message, new Object[] {});
+                // TODO: Some sort of encoding is required here to make a proper CSV string...
+                csv.append(value != null?value.toString():"");
+            } catch (Exception e) {
+                logger.error("Exception calling bean method: " + methodName, e);
+            }
+        }
+        
+        return csv.toString();
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+     */
+    public Serializable getOkNotification(Object message) {
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+     */
+    public Serializable getErrorNotification(Object message) {
+        return null;
+    }
+}

Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/ObjectToXStream.java (from rev 6523, labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToXStream.java)
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/ObjectToXStream.java	2006-10-02 16:26:11 UTC (rev 6523)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/converters/ObjectToXStream.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.actions.converters;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+import com.thoughtworks.xstream.XStream;
+
+/**
+ * Object to XML processor.
+ * <p/>
+ * Uses the <a href="http://xstream.codehaus.org/">XStream</a> processor to generate an XML message String from the supplied object.
+ * <p/>
+ * Sample Action Configuration:
+ * <pre>
+ * &lt;Action name="Customer-To-XML" processor="ObjectToXStream"&gt;
+ *     &lt;property name="class-alias" value="Customer" /&gt; &lt;!-- Class alias used in call to <a href="http://xstream.codehaus.org/javadoc/com/thoughtworks/xstream/XStream.html">XStream.alias(String, Class)</a> prior to serialisation. --&gt;
+ *     &lt;property name="exclude-package" value="false" /&gt; &lt;!-- Default "true".  Not applicable if a "class-alias" is specified. --&gt;
+ * &lt;/Action&gt;
+ * </pre>
+ * <p/>
+ * The XML root element is either set from the "class-alias" property or the classes full name.  In the later case, the class package is
+ * excluded unless "exclude-package" is set to "false"/"no". 
+ * 
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ObjectToXStream implements ActionProcessor {
+    
+    private String classAlias;
+    private boolean excludePackage;
+    
+    /**
+     * Public constructor.
+     * @param actionName Action name.
+     * @param properties Action Properties.
+     * @throws ConfigurationException Action not properly configured.
+     */
+    public ObjectToXStream(String actionName, List<KeyValuePair> properties) {
+        classAlias = KeyValuePair.getValue("class-alias", properties);
+        excludePackage = KeyValuePair.getBooleanValue("exclude-package", properties, true);
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+     */
+    public Object process(Object object) throws ActionProcessingException {
+        XStream xstream = new XStream();
+        
+        if(classAlias == null) {
+            if(excludePackage) {
+                xstream.alias(object.getClass().getSimpleName(), object.getClass());
+            } else {
+                xstream.alias(object.getClass().getName(), object.getClass());
+            }
+        } else {
+            xstream.alias(classAlias, object.getClass());
+        }
+        
+        return xstream.toXML(object);
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+     */
+    public Serializable getOkNotification(Object message) {
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+     */
+    public Serializable getErrorNotification(Object message) {
+        return null;
+    }
+}

Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/routing/FileCopier.java (from rev 6543, labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java)
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/FileCopier.java	2006-10-03 11:04:21 UTC (rev 6543)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/routing/FileCopier.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.actions.routing;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.AbstractFileAction;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.helpers.*;
+import org.jboss.soa.esb.listeners.DirectoryPoller.WorkingFile;
+
+/**
+ * File copy action.
+ * <p/>
+ * Copy the file specified by the "fileParams" arg in {@link #process(File)} to the location specified by the 
+ * action config properties.
+ * <p/>
+ * Sample Action Configuration:
+ * <pre>
+ * &lt;Action name="Copy-To-XXX" processor="FileCopier"&gt;
+ *     &lt;property name="copyToDirURI" value="file:///..." /&gt;
+ *     &lt;property name="copyToSuffix" value=".fileCopierOutput" /&gt;
+ * &lt;/Action&gt;
+ * </pre>
+ * 
+ * @author Esteban
+ */
+public class FileCopier extends AbstractFileAction {
+    
+    private static Logger logger = Logger.getLogger(FileCopier.class);
+    
+    private static final String TMP_SUFFIX = ".notReady";
+
+    private static final String PARMS_OUTDIR = "copyToDirURI";
+
+    private static final String PARMS_OUTSFX = "copyToSuffix";
+
+    private File outputDir;
+    private String copyToSuffix;
+
+    /**
+     * Public constructor.
+     * @param actionName Action name.
+     * @param properties Action Properties.
+     * @throws ConfigurationException Action not properly configured.
+     */
+    public FileCopier(String actionName, List<KeyValuePair> properties) throws URISyntaxException {
+        String outputDirParam = KeyValuePair.getValue(PARMS_OUTDIR, properties);
+        
+        try {
+            outputDir = new File(new URI(outputDirParam));
+        } catch(Exception e) {
+            outputDir = new File(outputDirParam);
+        }
+        copyToSuffix = KeyValuePair.getValue(PARMS_OUTSFX, properties, ".copy");
+    } // __________________________________
+
+    public Object process(File file) throws ActionProcessingException {
+        WorkingFile workingFile;
+        
+        try {
+            workingFile = (WorkingFile)file;
+        } catch(ClassCastException e) {
+            throw new ActionProcessingException("File must be an instance of " + WorkingFile.class.getName());
+        }
+        
+        File outputFile = new File(outputDir, workingFile.getInputFile().getName() + copyToSuffix);
+        
+        try {
+            File tempFile = File.createTempFile(workingFile.getName(), TMP_SUFFIX, outputDir);
+            FileInputStream inputFileStream = new FileInputStream(workingFile);
+            FileOutputStream outputFileStream;
+            
+            outputFileStream = new FileOutputStream(tempFile);
+    
+            // Perform Copy
+            byte[] ba = new byte[1024];
+            while (true) {
+                int iQ = inputFileStream.read(ba);
+                
+                if (iQ < 0) {
+                    break;
+                }
+    
+                outputFileStream.write(ba, 0, iQ);
+            }
+            // Close
+            inputFileStream.close();
+            outputFileStream.close();
+    
+            // Rename
+            outputFile.delete();
+            tempFile.renameTo(outputFile);
+            
+            if(logger.isDebugEnabled()) {
+                logger.debug("Successfully copied file " + workingFile.getAbsolutePath() + " to file " + outputFile.getAbsolutePath());
+            }
+        } catch(IOException e) {
+            throw new ActionProcessingException("IOException copying " + workingFile.getAbsolutePath() + " to " + outputFile.getAbsolutePath(), e);
+        }
+        
+        return workingFile;
+    } // __________________________________
+
+    public Serializable getOkNotification(Object message) {
+        return "File " + ((WorkingFile)message).getInputFile().getAbsolutePath()
+                + " successfully copied to all destination";
+    }
+
+    public Serializable getErrorNotification(Object message) {
+        return "Problems copying " + ((WorkingFile)message).getInputFile().getAbsolutePath()
+                + " to configured destination";
+    }
+
+} // ____________________________________________________________________________

Copied: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/routing/JMSRouter.java (from rev 6543, labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java)
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/JMSRouter.java	2006-10-03 11:04:21 UTC (rev 6543)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/routing/JMSRouter.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -0,0 +1,198 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.actions.routing;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.helpers.AppServerContext;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * JSM Routing Action Processor.
+ * <p/>
+ * Sample Action Configuration:
+ * <pre>
+ * &lt;Action name="Route-To-Invoicing" processor="JMSRouter"&gt;
+ *     &lt;property name="jndiName" value="queue/A" /&gt;
+ *     &lt;property name="message-prop:jms-selector" value="incoming-invoice" /&gt;
+ * &lt;/Action&gt;
+ * </pre>
+ * Note how properties to be set on the message are prefixed with "message-prop:".
+ * <p/>
+ * TODO: Add support for JMS Topic destinations.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class JMSRouter implements ActionProcessor {
+    /**
+     * Logger.
+     */
+    private static Logger logger = Logger.getLogger(JMSRouter.class);
+    /**
+     * Routing properties.
+     */
+    private List<KeyValuePair> properties;
+    /**
+     * JMS Queue setup.
+     */
+    private JMSSendQueueSetup queueSetup;
+
+    /**
+     * Public constructor.
+     * @param actionName Action name.
+     * @param properties Action properties.
+     * @throws ConfigurationException Queue name not configured.
+     * @throws JMSException Unable to configure JMS destination.
+     * @throws NamingException Unable to configure JMS destination.
+     */
+    public JMSRouter(String actionName, List<KeyValuePair> properties) throws ConfigurationException, NamingException, JMSException {
+        this.properties = properties;
+        
+        String queueName = KeyValuePair.getValue("jndiName", properties);
+        if(queueName == null) {
+            throw new ConfigurationException("JMSRouter must specify a 'jndiName' property.");
+        }
+        queueSetup = new JMSSendQueueSetup(queueName);
+        this.properties = properties;
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+     */
+    public Object process(Object message) throws ActionProcessingException {
+        if(!(message instanceof Serializable)) {
+            throw new ActionProcessingException("Cannot send Object [" + message.getClass().getName() + "] to destination [" + queueSetup.queueName + "]. Object must be serializable.");
+        }
+        
+        try {
+            // Send a Text or Object message to the queue...
+            if (message instanceof String) {
+                TextMessage oMsg = queueSetup.jmsSession.createTextMessage();
+    
+                if(logger.isDebugEnabled()) {
+                    logger.debug("Sending Text message: [" + message + "] to destination [" + queueSetup.queueName + "].");
+                }
+                oMsg.setText((String)message);
+                setStringProperties(oMsg);
+                queueSetup.jmsProducer.send(oMsg);
+            } else {
+                ObjectMessage oMsg = queueSetup.jmsSession.createObjectMessage();
+                
+                if(logger.isDebugEnabled()) {
+                    logger.debug("Sending Object message: [" + message + "] to destination [" + queueSetup.queueName + "].");
+                }
+                oMsg.setObject((Serializable) message);
+                setStringProperties(oMsg);
+                queueSetup.jmsProducer.send(oMsg);
+            }
+        } catch(Exception e) {
+            String errorMessage = "Exception while sending message [" + message + "] to destination [" + queueSetup.queueName + "].";
+            logger.error(errorMessage, e);
+            throw new ActionProcessingException(errorMessage, e);
+        }
+        
+        return message;
+    }
+
+    private void setStringProperties(Message msg) throws JMSException {
+        String messagePropPrefix = "message-prop:";
+
+        for(KeyValuePair property : properties) {
+            String key = property.getKey();
+            
+            if(key.startsWith(messagePropPrefix) && key.length() > messagePropPrefix.length()) {
+                msg.setStringProperty(key.substring(messagePropPrefix.length()), property.getValue());
+            }
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+     */
+    public Serializable getOkNotification(Object message) {
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+     */
+    public Serializable getErrorNotification(Object message) {
+        return null;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        queueSetup.close();
+        super.finalize();
+    }
+    
+    private static class JMSSendQueueSetup {
+        QueueSession jmsSession;
+        Queue jmsQueue;
+        MessageProducer jmsProducer;
+        String queueName;
+        
+        // TODO: Modify to support topic destinations too
+
+        private JMSSendQueueSetup(String queueName) throws NamingException, JMSException  {
+            Context m_oCtx = AppServerContext.getServerContext(
+                    Configuration.getJndiServerType(), 
+                    Configuration.getJndiServerURL());           
+            QueueConnectionFactory qcf = (QueueConnectionFactory) m_oCtx.lookup("ConnectionFactory");
+            QueueConnection oQconn = qcf.createQueueConnection();
+
+            this.queueName = queueName;
+            
+            jmsSession = oQconn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+            jmsQueue = (Queue) m_oCtx.lookup(queueName);
+            jmsProducer = jmsSession.createSender(jmsQueue);            
+        }
+        
+        private void close() {
+            try {
+                jmsProducer.close();
+                jmsSession.close();
+            } catch (Exception e) {
+                logger.error("Unable to close JMS Queue Setup.", e);
+            }
+        }
+    }
+}

Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/routing/ObjectToFileWriter.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/routing/ObjectToFileWriter.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/routing/ObjectToFileWriter.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.actions.routing;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * Object to file writing processor.
+ * <p/>
+ * Writes an Object to a file based on the "file" property specified by the action configuration.  This "file"
+ * property can specify a file or directory.  If the file is a directory, the class generates a file name based
+ * on the return from a call to {@link java.util.UUID#randomUUID()} and the file extension value specified in
+ * the "ext" property (default of "obj").
+ * <p/>
+ * If the message is a byte array it's writen to the file as is, otherwise the toString method is called on the
+ * message object and the resulting String bytes are writen to the file based on the "encoding" specified in the action
+ * configuration (see below).
+ * <p/>
+ * Sample Action Configuration:
+ * <pre>
+ * &lt;Action name="Write-To-X-File" processor="ObjectToFileWriter"&gt;
+ *     &lt;property name="file" value="file:///..." /&gt; &lt;!-- File/Directory name. Supports URI or non-URI based names. --&gt;
+ *     &lt;property name="append" value="true/false" /&gt; &lt;!-- Only relevant if the file is not a directory. Default of "false". --&gt;
+ *     &lt;property name="ext" value="dat" /&gt; &lt;!-- Only relevant if the file is a directory. Default of "obj". --&gt;
+ *     &lt;property name="encoding" value="UTF-8" /&gt; &lt;!-- Default of "UTF-8". --&gt;
+ * &lt;/Action&gt;
+ * </pre>
+ * 
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ObjectToFileWriter implements ActionProcessor {
+
+    public static final String FILE_NAME = "file";
+    public static final String FILE_APPEND = "append";
+    public static final String FILE_EXT = "ext";
+    public static final String FILE_ENC = "encoding";
+    private static Logger logger = Logger.getLogger(ObjectToFileWriter.class);
+    
+    private String actionName;
+    private File file;
+    private boolean append;
+    private String ext;
+    private String encoding;
+    
+    /**
+     * Public constructor.
+     * @param actionName Action name.
+     * @param properties Action Properties.
+     * @throws ConfigurationException Action not properly configured.
+     */
+    public ObjectToFileWriter(String actionName, List<KeyValuePair> properties) throws ConfigurationException {
+        String fileName = KeyValuePair.getValue(FILE_NAME, properties);
+        
+        this.actionName = actionName;
+        
+        if(fileName == null || fileName.trim().equals("")) {
+            throw new ConfigurationException("Action [" + actionName + "] must specify a '" + FILE_NAME + "' property specifying the name of the output file.");
+        }
+        try {
+            // try it as a URI first...
+            file = new File(new URI(fileName));
+        } catch (Exception e) {
+            // ok, just interpret it as being relative to the cwd...
+            file = new File(fileName);
+        }
+        append = KeyValuePair.getBooleanValue(FILE_APPEND, properties, false);
+        ext = KeyValuePair.getValue(FILE_EXT, properties, "obj");
+        encoding = KeyValuePair.getValue(FILE_ENC, properties, "UTF-8");
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
+     */
+    public Object process(Object message) throws ActionProcessingException {
+        synchronized(file) {
+            File outputFile = getOutputFile();
+            FileOutputStream fileOutputStream = null;
+            FileWriter fileWriter = null;
+
+            try {
+                fileWriter = new FileWriter(outputFile, append);
+                fileOutputStream = new FileOutputStream(outputFile, append);
+            } catch (IOException e) {
+                throw new ActionProcessingException("Action " + actionName + " failed.  Unable to open output file " + outputFile.getAbsolutePath());
+            }
+            
+            try {
+                if(message instanceof byte[]) {
+                    fileOutputStream.write((byte[])message);
+                } else {
+                    fileOutputStream.write(message.toString().getBytes(encoding));
+                }
+                fileOutputStream.flush();
+            } catch (IOException e) {
+                throw new ActionProcessingException("Action " + actionName + " failed.  Unable to write to output file " + outputFile.getAbsolutePath(), e);
+            } finally {
+                try {
+                    fileWriter.close();
+                } catch (IOException e) {
+                    logger.warn("Exception on closing file " + file.getAbsolutePath(), e);
+                }
+            }
+            
+            return message;
+        }        
+    }
+
+    /**
+     * Get the output file.
+     * @return Output file.
+     */
+    private File getOutputFile() {
+        if(file.isDirectory()) {
+            UUID randomUUID = UUID.randomUUID();
+            File randomFile = new File(file, randomUUID.toString() + "." + ext);
+            
+            if(randomFile.exists()) {
+                return getOutputFile();
+            }
+            
+            return randomFile;
+        } else {
+            return file;
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
+     */
+    public Serializable getOkNotification(Object message) {
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionProcessor#getErrorNotification(java.lang.Object)
+     */
+    public Serializable getErrorNotification(Object message) {
+        return null;
+    }
+
+}

Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockAction.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockAction.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -0,0 +1,46 @@
+package org.jboss.soa.esb.actions.templates;
+
+import java.io.Serializable;
+import java.text.*;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.ActionProcessor;
+
+
+/**
+ * Use this class to tune your XML configurations <p/>Once your config works
+ * with this dummy class, you can switch to your own action class <p/>You will
+ * have to implement these three methods in your own action class
+ * 
+ * @author Esteban
+ * 
+ */
+public class MockAction implements ActionProcessor {
+    /**
+     * Class Logger.
+     */
+    private static Logger logger = Logger.getLogger(MockAction.class);
+
+    public Object process(Object message) {
+        logger.info("process was called with <<" + message.toString() + ">>");
+        return message;
+    } // ________________________________
+
+    private SimpleDateFormat s_oTS = new SimpleDateFormat(
+            "yyyy/MM/dd hh:mm:ss.SSS");
+
+    private String getStamp() {
+        return s_oTS.format(new java.util.Date(System.currentTimeMillis()));
+    }
+
+    public Serializable getOkNotification(Object message) {
+        return getStamp() + " Notif OK - <"
+                + ((null == message) ? "null" : message.toString()) + ">";
+    } // ________________________________
+
+    public Serializable getErrorNotification(Object message) {
+        return getStamp() + " Notif ERROR - <"
+                + ((null == message) ? "null" : message.toString()) + ">";
+    } // ________________________________
+
+} // ____________________________________________________________________________

Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockFileAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockFileAction.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockFileAction.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -0,0 +1,50 @@
+package org.jboss.soa.esb.actions.templates;
+
+import java.io.File;
+import java.io.Serializable;
+import java.text.*;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.AbstractFileAction;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+
+/**
+ * Use this class to tune your XML configurations
+ * <p/>Once your config works with this dummy class, you can
+ * switch to your own action class
+ * <p/>You will have to implement these three methods 
+ * in your own action class
+ * 
+ * @author Esteban
+ *
+ */
+public class MockFileAction extends AbstractFileAction 
+{
+    private static Logger logger = Logger.getLogger(MockFileAction.class);
+	
+	@Override
+	public Object process(File file) throws ActionProcessingException 
+	{
+        logger.info("processObject was called with <<" + file.getAbsolutePath() + ">>");
+        return file;
+	} //________________________________
+	
+	private SimpleDateFormat s_oTS = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS");
+	private String getStamp() 
+		{ return s_oTS.format(new java.util.Date(System.currentTimeMillis())); }
+
+	public Serializable getOkNotification(Object message)
+	{
+		return getStamp()+" Notif OK - <"
+		+((null==message)?"null":message.toString())
+		+">";
+	} //________________________________
+
+	public Serializable getErrorNotification(Object message)
+	{
+		return getStamp()+" Notif ERROR - <"
+		+((null==message)?"null":message.toString())
+		+">";
+	} //________________________________
+	
+} //____________________________________________________________________________

Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockSqlRowAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockSqlRowAction.java	2006-10-03 13:43:00 UTC (rev 6547)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockSqlRowAction.java	2006-10-03 13:46:32 UTC (rev 6548)
@@ -0,0 +1,60 @@
+package org.jboss.soa.esb.actions.templates;
+
+import java.io.Serializable;
+import java.text.*;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.jboss.soa.esb.actions.AbstractSqlRowAction;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+/**
+ * Use this class to tune your XML configurations
+ * <p/>Once your config works with this dummy class, you can
+ * switch to your own action class
+ * <p/>You will have to implement these three methods 
+ * in your own action class
+ * 
+ * @author Esteban
+ *
+ */
+public class MockSqlRowAction extends AbstractSqlRowAction 
+{
+    
+    public static List<Map> params = new Vector<Map>();
+
+    public MockSqlRowAction(String actionName, List<KeyValuePair> properties) throws Exception {
+        super(actionName, properties);
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.AbstractSqlRowAction#processSQL()
+     */
+    @Override
+    protected Object process(Map resultSet) {
+        logger.info("processResultset was called with <<"
+                + resultSet.toString()+">>");
+        params.add(resultSet);
+        
+        return resultSet;
+    }
+	
+	private SimpleDateFormat s_oTS = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS");
+	private String getStamp() 
+		{ return s_oTS.format(new java.util.Date(System.currentTimeMillis())); }
+
+	public Serializable getOkNotification(Object message)
+	{
+		return getStamp()+" Notif OK - <"
+		+((null==message)?"null":message.toString())
+		+">";
+	} //________________________________
+
+	public Serializable getErrorNotification(Object message)
+	{
+		return getStamp()+" Notif ERROR - <"
+		+((null==message)?"null":message.toString())
+		+">";
+	} //________________________________
+} //____________________________________________________________________________




More information about the jboss-svn-commits mailing list