Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * $Id: SftpMessageRequester.java 21125 2011-01-26 21:21:10Z dzapata $
  * --------------------------------------------------------------------------------------
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
  *
  * The software in this package is published under the terms of the CPAL v1.0
  * license, a copy of which has been included with this distribution in the
  * LICENSE.txt file.
  */
package org.mule.transport.sftp;
SftpMessageRequester polls files on request (e.g. from a quartz-inbound-endpoint) from an sftp service on request using jsch. This requester produces an InputStream payload, which can be materialized in a MessageDispatcher or Component.
    private SftpReceiverRequesterUtil sftpRRUtil = null;
    public SftpMessageRequester(InboundEndpoint endpoint)
    {
        super(endpoint);
         = new SftpReceiverRequesterUtil(endpoint);
    }
    @Override
    protected MuleMessage doRequest(long timeoutthrows Exception
    {
        String[] files = .getAvailableFiles(true);
        if (files.length == 0) return null;
        String path = files[0];
        // TODO. ML FIX. Can't we figure out the current service (for logging/audit
        // purpose)???
        SftpNotifier notifier = new SftpNotifier((SftpConnectorcreateNullMuleMessage(),
            .getName());
        InputStream inputStream = .retrieveFile(pathnotifier);
        .debug("Routing file: " + path);
        MuleMessage message = createMuleMessage(inputStream);
        // Now we can update the notifier with the message
        notifier.setMessage(message);
        return message;
    }
New to GrepCode? Check out our FAQ X