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.expression;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.api.expression.ExpressionEvaluator;
11  
12  import org.apache.commons.logging.Log;
13  import org.apache.commons.logging.LogFactory;
14  
15  /**
16   * Creates a Map facade around a {@link org.mule.api.MuleMessage} instance to allow access to outbound
17   * attachments from within components and transformers without the these objects needing access to the Mule Message
18   */
19  public class OutboundAttachmentsExpressionEvaluator implements ExpressionEvaluator
20  {
21      public static final String NAME = "outboundAttachments";
22  
23      /**
24       * logger used by this class
25       */
26      protected transient final Log logger = LogFactory.getLog(OutboundAttachmentsExpressionEvaluator.class);
27  
28  
29      public Object evaluate(String expression, MuleMessage message)
30      {
31          if (message == null)
32          {
33              return null;
34          }
35          return new OutboundAttachmentsMap(message);
36      }
37  
38      /**
39       * {@inheritDoc}
40       */
41      public String getName()
42      {
43          return NAME;
44      }
45  
46      /**
47       * {@inheritDoc}
48       */
49      public void setName(String name)
50      {
51          throw new UnsupportedOperationException("name");
52      }
53  }