View Javadoc

1   /*
2    * $Id: SftpNotifier.java 21125 2011-01-26 21:21:10Z dzapata $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.sftp.notification;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.endpoint.ImmutableEndpoint;
15  import org.mule.transport.sftp.SftpConnector;
16  
17  public class SftpNotifier
18  {
19  
20      private SftpConnector connector;
21      private MuleMessage message;
22      private ImmutableEndpoint endpoint;
23      private String serviceName;
24  
25      public SftpNotifier(SftpConnector connector,
26                          MuleMessage message,
27                          ImmutableEndpoint endpoint,
28                          String serviceName)
29      {
30  
31          this.connector = connector;
32          this.message = message;
33          this.endpoint = endpoint;
34          this.serviceName = serviceName;
35      }
36  
37      public void setMessage(MuleMessage message)
38      {
39          this.message = message;
40      }
41  
42      public void notify(int action, String info)
43      {
44          notify(action, info, -1);
45      }
46  
47      public void notify(int action, String info, long size)
48      {
49          if (connector.isEnableMessageEvents())
50          {
51              connector.fireNotification(new SftpTransportNotification(message, endpoint, serviceName, action,
52                  info, size));
53          }
54      }
55  }