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;
8   
9   import org.mule.api.processor.MessageProcessor;
10  
11  import java.lang.annotation.Annotation;
12  import java.lang.reflect.Member;
13  
14  /**
15   * An SPI interface used for creating Routers from Annotations. Note that any Router annotations must be themselves
16   * annotated with the {@link org.mule.api.routing.OutboundRouter} annotation.
17   */
18  public interface MessageProcessorAnnotationParser
19  {
20      /**
21       * Will create a Mule Router according to the annotation. Note that the annotation must
22       * itself be annotated with the {@link org.mule.api.routing.OutboundRouter} annotation.
23       *
24       * @param annotation the current annotation being processed
25       * @return a new Router configuration based on the current annotation
26       * @throws MuleException if the inbound endpoint cannot be created. A Mule-specific error will be thrown.
27       */
28      public MessageProcessor parseMessageProcessor(Annotation annotation) throws MuleException;
29  
30      /**
31       * Determines whether this parser can process the current annotation. The clazz and member params are passed in
32       * so that further validation be done on the location, type or name of these elements.
33       *
34       * @param annotation the annotation being processed
35       * @param clazz      the class on which the annotation was found
36       * @param member     the member on which the annotation was found inside the class.  This is only set when the annotation
37       *                   was either set on a {@link java.lang.reflect.Method}, {@link java.lang.reflect.Field} or {@link java.lang.reflect.Constructor}
38       *                   class member, otherwise this value is null.
39       * @return true if this parser supports the current annotation, false otherwise
40       */
41      public boolean supports(Annotation annotation, Class clazz, Member member);
42  }