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