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.api.lifecycle;
8   
9   import org.mule.api.MuleEventContext;
10  
11  /**
12   * <code>Callable</code> is used to provide a Service with an interface that supports
13   * event calls. Components do not have to implement this interface, though the
14   * <code>onCall</code> method provides an example lifecycle method that is executed
15   * when an event is received for the implementing service.
16   */
17  public interface Callable extends EventListener
18  {
19  
20      /**
21       * Passes the event to the listener
22       * 
23       * @param eventContext the context of the current event being process
24       * @return Object this object can be anything. When the
25       *         <code>LifecycleAdapter</code> for the service receives this
26       *         object it will first see if the Object is an <code>MuleMessage</code>
27       *         if not and the Object is not null a new message will be created using
28       *         the returned object as the payload. This new event will then get
29       *         published via the configured outbound router if-
30       *         <ol>
31       *         <li>One has been configured for the component.</li>
32       *         <li>the <code>setStopFurtherProcessing(true)</code> wasn't called
33       *         on the event context event.</li>
34       *         </ol>
35       * @throws Exception if the event fails to process properly. If exceptions aren't
36       *             handled by the implementation they will be handled by the
37       *             exceptionListener associated with the service
38       */
39      Object onCall(MuleEventContext eventContext) throws Exception;
40  
41  }