View Javadoc

1   /*
2    * $Id: InboundAttachments.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.annotations.param;
12  
13  import org.mule.api.annotations.meta.Evaluator;
14  
15  import java.lang.annotation.Documented;
16  import java.lang.annotation.ElementType;
17  import java.lang.annotation.Retention;
18  import java.lang.annotation.RetentionPolicy;
19  import java.lang.annotation.Target;
20  
21  /**
22   * Used on component and transformer methods that have a {@link org.mule.api.annotations.Transformer} annotation.
23   * This annotation marks the method parameter that will be used to pass in one or more of the received attachments.
24   * This annotation can define a single attachment, a comma-separated list of attachment names, or '*' to denote all headers. By default,
25   * if a named header is not present, an exception will be thrown. However, if the header name is defined with the '?' post fix, it
26   * will be marked as optional.
27   * <p/>
28   * When defining multiple attachment names i.e. InboundAttachments("shipping-slip.pdf, customer-record.xml") or using the '*' wildcard to denote all attachments,
29   * or wildcard expressions can be used, such as '*.pdf' or multiple patterns such as '*.pdf, *.xml'.
30   * the parameter can be a {@link java.util.Map} or {@link java.util.List}. If a {@link java.util.Map} is used, the header name and value is passed in.
31   * If {@link java.util.List} is used, just the header value is used. If a single header name is defined, the header type can be used as the parameter or
32   * {@link java.util.List} or {@link java.util.Map} can be used too.  Entry type for collections is {@link javax.activation.DataHandler}.
33   *
34   * The Inbound attachments collection is immutable, so the attachments Map or List passed in will be immutable too. Attempting to write to the Map or List will result in an {@link UnsupportedOperationException}.
35   */
36  @Target(ElementType.PARAMETER)
37  @Retention(RetentionPolicy.RUNTIME)
38  @Documented
39  @Evaluator("attachments")
40  //
41  public @interface InboundAttachments
42  {
43      /**
44       * Defines the headers that should be injected into the parameter. This can be a single header, a comma-separated
45       * list of header names, or '*' to denote all headers or a comma separated list of wildcard expressions such as '*.pdf, *.xml'.
46       * By default, if a named header is not present, an exception will
47       * be thrown. However, if the header name is defined with the '?' post fix, it will be marked as optional. When using wildcard expressions
48       * the optional '?' postfix cannot be used.
49       *
50       * @return the attachment expression used to query the message
51       */
52      String value();
53  }