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.config;
8   
9   import org.mule.api.EndpointAnnotationParser;
10  import org.mule.api.MessageProcessorAnnotationParser;
11  import org.mule.api.expression.ExpressionAnnotationParser;
12  
13  import java.lang.annotation.Annotation;
14  import java.lang.reflect.Member;
15  
16  /**
17   * Defines a common interface to find all Endpoint annotation parsers for a context.  Endpoint parsers may be
18   * customized depending on the underlying platform.
19   * This is not an interface that users should ever need to use or customize, but Mule on different platforms
20   * can customize how the endpoints are created from the annotations.
21   * <p/>
22   * There are 3 types of annotation parser -
23   * 1. Endpoint : translates into an endpoint configured on a service object.
24   * 2. Router : translates into a router that will be configured on a service object, i.e. WireTap, Splitter, or Filter
25   * 3. Expression : translates into an expression, usually these are configured on method parameters so that an expression
26   * will get evaluated on the parameter before being passed into the method.
27   *
28   * @since 3.0
29   *
30   */
31  public interface AnnotationsParserFactory
32  {
33      /**
34       * Retrieves a parser for the given annotation, the parameters passed in can be used to validate the use of
35       * the annotation, i.e. you may want to restrict annotations to only be configured on concrete classes
36       *
37       * @param annotation the annotation being processed
38       * @param aClass     the class on which  the annotation is defined
39       * @param member     the class member on which the annotation was defined, such as Field, Method, Constructor, or
40       *                   null if a Type-level annotation.
41       * @return the endpoint annotation parser that can parse the supplied annotation or null if a matching parser
42       *         not found
43       */
44      EndpointAnnotationParser getEndpointParser(Annotation annotation, Class<?> aClass, Member member);
45  
46      /**
47       * Retrieves a parser for the given annotation, where the annotation is an Expression annotation; one annotated with
48       * the {@link org.mule.api.annotations.meta.Evaluator} annotation.
49       * <p/>
50       *
51       * @param annotation the annotation being processed
52       * @return the expression annotation parser that can parse the supplied annotation or null if a matching parser
53       *         not found
54       */
55      ExpressionAnnotationParser getExpressionParser(Annotation annotation);
56  
57      /**
58       * Retrieves a parser for the given annotation, where the annotation is a Router annotation; one annotated with
59       * the {@link org.mule.api.annotations.meta.Router} annotation. the parameters passed in can be used to validate the use of
60       * the annotation, i.e. you may want to restrict annotations to only be configured on concrete classes.
61       * <p/>
62       *
63       * @param annotation the annotation being processed
64       * @param aClass     the class on which  the annotation is defined
65       * @param member     the class member on which the annotation was defined, such as Field, Method, Constructor, or
66       *                   null if a Type-level annotation.
67       * @return the router annotation parser that can parse the supplied annotation or null if a matching parser
68       *         not found
69       */
70      MessageProcessorAnnotationParser getRouterParser(Annotation annotation, Class<?> aClass, Member member);
71  
72  }