View Javadoc

1   /*
2    * $Id: EndpointAnnotationParser.java 20813 2010-12-21 11:37:48Z dirk.olmes $
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.endpoint.InboundEndpoint;
13  import org.mule.api.endpoint.OutboundEndpoint;
14  
15  import java.lang.annotation.Annotation;
16  import java.lang.reflect.Member;
17  import java.util.Map;
18  
19  /**
20   * An SPI interface that will process an Endpoint annotation. Note that the
21   * Annotation must be annotated with the <code>@Endpoint</code> annotation.
22   */
23  public interface EndpointAnnotationParser
24  {
25      /**
26       * Creates an outbound endpoint from the annotation.
27       *
28       * @param annotation the annotation to process
29       * @param metaInfo   any additional info that can be used to construct the endpoint.  Typically a connector name might be
30       *                   in this map so that all endpoints for the current object can share the same connector
31       * @return a new {@link org.mule.api.endpoint.OutboundEndpoint} object configured according to the annotation
32       * @throws MuleException if the outbound endpoint cannot be created. A Mule-specific error will be thrown.
33       */
34      public OutboundEndpoint parseOutboundEndpoint(Annotation annotation, Map metaInfo) throws MuleException;
35  
36      /**
37       * Creates an inbound endpoint from the annotation.
38       *
39       * @param annotation the annotation to process
40       * @param metaInfo any additional info that can be used to construct the endpoint.  Typically a connector name might be
41       *                   in this map so that all endpoints for the current object can share the same connector
42       * @return a new {@link org.mule.api.endpoint.InboundEndpoint} object configured according to the annotation
43       * @throws MuleException if the inbound endpoint cannot be created. A Mule-specific error will be thrown.
44       */
45      public InboundEndpoint parseInboundEndpoint(Annotation annotation, Map metaInfo) throws MuleException;
46  
47      /**
48       * Determines whether this parser can process the current annotation.  The clazz and member params are passed in
49       * so that further validation be done on the location, type or name of these elements.
50       *
51       * @param annotation the annotation being processed
52       * @param clazz      the class on which the annotation was found
53       * @param member     the member on which the annotation was found inside the class. This is only set when the annotation
54       *                   was either set on a {@link java.lang.reflect.Method}, {@link java.lang.reflect.Field} or {@link java.lang.reflect.Constructor}
55       *                   class member, otherwise this value is null.
56       * @return true if this parser supports the current annotation, false otherwise
57       */
58      public boolean supports(Annotation annotation, Class clazz, Member member);
59  }