[jboss-svn-commits] JBL Code SVN: r8259 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Dec 12 11:15:10 EST 2006
Author: b_georges
Date: 2006-12-12 11:15:08 -0500 (Tue, 12 Dec 2006)
New Revision: 8259
Removed:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AnewFileGatewayListener.java
Log:
Removed as not needed. Replaced the previous FileGatewayListener
Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AnewFileGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AnewFileGatewayListener.java 2006-12-12 15:59:38 UTC (rev 8258)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AnewFileGatewayListener.java 2006-12-12 16:15:08 UTC (rev 8259)
@@ -1,162 +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.listeners.gateway;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.jboss.soa.esb.util.Util;
-
-public class AnewFileGatewayListener extends AbstractFileGateway
-{
- protected AnewFileGatewayListener() {}
- public AnewFileGatewayListener(GatewayListenerController commandListener, ConfigTree config)
- throws Exception
- {
- super(commandListener,config);
- _fileFilter = new FileEndsWith(_inputSuffix);
- }
-
- protected void checkMyParms() throws Exception
- {
- super.checkMyParms();
- }
-
- @Override
- protected void seeIfOkToWorkOnDir (File p_oDir) throws GatewayException
- {
- if (! p_oDir.exists())
- throw new GatewayException ("Directory "+p_oDir.toString()+" not found");
- if (!p_oDir.isDirectory())
- throw new GatewayException(p_oDir.toString()+" is not a directory");
- if (!p_oDir.canRead())
- throw new GatewayException("Can't read directory "+p_oDir.toString());
- if (! p_oDir.canWrite())
- throw new GatewayException ("Can't write/rename in directory "+p_oDir.toString());
- } //________________________________
-
- @Override
- boolean deleteFile(File file) throws GatewayException
- {
- return file.delete();
- }
-
-
- @Override
- byte[] getFileContents(File file) throws GatewayException
- {
- try
- {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] ba = new byte[1000];
- int iQread;
- FileInputStream inp = new FileInputStream(file);
- while (-1!= (iQread=inp.read(ba)))
- if (iQread > 0)
- out.write(ba,0,iQread);
- inp.close();
- out.close();
- return out.toByteArray();
- }
- catch (IOException e) { throw new GatewayException(e); }
- }
-
-
- @Override
- File[] getFileList(String suffix) throws GatewayException
- {
- return _inputDirectory.listFiles(_fileFilter);
- }
-
-
- @Override
- boolean renameFile(File from, File to) throws GatewayException
- {
- return from.renameTo(to);
- }
-
- @Override
- void getDefaultComposer() throws GatewayException
- {
- _composerName = PackageFileContents.class.getName();
- _composerClass= PackageFileContents.class;
- _composer = new PackageFileContents();
- _logger.warn("No <"+ListenerTagNames.ACTION_ELEMENT_TAG+"> element found in cofiguration"
- +" - Using default composer class : "+_composerName);
- }
-//______________________________________________________________________________
- /**
- * Default gateway action for files
- * <p/>It will just drop the file contents into a Message
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- * @since Version 4.0
- *
- */
- public class PackageFileContents
- {
- public Message process (Object obj) throws Exception
- {
- if (! (obj instanceof File))
- throw new Exception ("Object must be instance of File");
-
- Message message = MessageFactory.getInstance().getMessage();
- message.getBody().setContents(getFileContent((File)obj));
- return message;
- }
-
- private byte[] getFileContent(File file) throws Exception
- { return getFileContents(file); }
- } //____________________________________________________
-
- /**
- * Simple file filter for local filesystem
- * Will accept only files that end with the String supplied at constructor time
- *
- */
- private class FileEndsWith implements FileFilter
- {
- String m_sSuffix;
- FileEndsWith(String p_sEnd) throws Exception
- {
- m_sSuffix = p_sEnd;
- if (Util.isNullString(m_sSuffix))
- throw new Exception("Must specify file extension");
- } //______________________________
-
- public boolean accept(File p_f)
- { return (p_f.isFile())
- ? p_f.toString().endsWith(m_sSuffix)
- : false;
- } //______________________________
- } //____________________________________________________
-
- private FileFilter _fileFilter;
-
-}
More information about the jboss-svn-commits
mailing list