View Javadoc

1   /*
2    * $Id: EntryPointResolverSet.java 20321 2010-11-24 15:21:24Z dfeist $
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.model;
12  
13  import org.mule.api.MuleEventContext;
14  
15  /**
16   * <code>EntryPointResolver</code> resolves a method to call on the given
17   * service object when an event is received.
18   * This object maintains a set of Resolvers that will be used in order to resolve
19   * an entrypoint on a service object until one is found or until the set is
20   * exhausted.
21   *
22   * Note that there is a one-to-one mapping from component to EntryPointResolverSet.  Each component must get a separate set
23   * with {@link org.mule.api.model.EntryPointResolver} instances that are not shared. An EntryPointResolver is allowed to cache state
24   * and can assume the component will always be of the the same type.
25   */
26  public interface EntryPointResolverSet
27  {
28  
29      /**
30       * Will attempt to invoke the component by looping through all {@link org.mule.api.model.EntryPointResolver} instances registered on this set until
31       * a match is found
32       * @param component the component to invoke
33       * @param context the current event context, this is used to figure out which method to call on the component
34       * @return the result of the invocation
35       * @throws Exception if the invocation itself or an {@link EntryPointResolver} fails
36       */
37      Object invoke(Object component, MuleEventContext context) throws Exception;
38  
39      /**
40       * Will add a resolver to the list of resolvers to invoke on a compoent.
41       * Implementations must maintain an ordered list of resolvers
42       *
43       * @param resolver the resolver to add
44       */
45      void addEntryPointResolver(EntryPointResolver resolver);
46  
47      /**
48       * Removes a resolver from the list
49       *
50       * @param resolver the resolver to remove
51       * @return true if the resolver was found and removed from the list
52       */
53      boolean removeEntryPointResolver(EntryPointResolver resolver);
54  
55  }