View Javadoc

1   /*
2    * $Id: MessageRequester.java 19191 2010-08-25 21:05:23Z tcarlson $
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.api.transport;
12  
13  import org.mule.api.MuleException;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.endpoint.InboundEndpoint;
16  import org.mule.api.endpoint.OutboundEndpoint;
17  import org.mule.api.lifecycle.LifecycleStateEnabled;
18  
19  
20  /**
21   * Combine {@link org.mule.api.transport.MessageRequesting} with
22   * various lifecycle methods for the actual instances doing message sending.
23   */
24  public interface MessageRequester extends Connectable, MessageRequesting, LifecycleStateEnabled
25  {
26      /**
27       * This method can perform necessary state updates before any of the
28       * {@link org.mule.api.transport.MessageDispatching} methods are invoked.
29       *
30       * @see MessageDispatcherFactory#activate(OutboundEndpoint, MessageDispatcher)
31       */
32      void activate();
33  
34      /**
35       * After receiving a message, the dispatcher can use this method e.g. to
36       * clean up its internal state (if it has any) or return pooled resources to
37       * whereever it got them during {@link #activate()}.
38       *
39       * @see MessageDispatcherFactory#passivate(OutboundEndpoint, MessageDispatcher)
40       */
41      void passivate();
42  
43      /**
44       * Determines whether this dispatcher can be reused after message receiving.
45       *
46       * @return <code>true</code> if this dispatcher can be reused,
47       *         <code>false</code> otherwise (for example when
48       *         {@link org.mule.api.lifecycle.Disposable#dispose()} has been called because an Exception was
49       *         raised)
50       */
51      boolean validate();
52  
53      /**
54       * Gets the connector for this dispatcher
55       *
56       * @return the connector for this dispatcher
57       */
58      Connector getConnector();
59  
60      /**
61       * @return the endpoint used for requesting events 
62       */
63      InboundEndpoint getEndpoint();
64      
65      MuleMessage createMuleMessage(Object transportMessage, String encoding) throws MuleException;
66  
67      MuleMessage createMuleMessage(Object transportMessage) throws MuleException;
68  }