View Javadoc

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