View Javadoc

1   /*
2    * $Id: MessageHeaderExpressionEnricher.java 20273 2010-11-19 12:52:55Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.expression;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.expression.ExpressionEnricher;
15  import org.mule.api.transport.PropertyScope;
16  
17  public class MessageHeaderExpressionEnricher implements ExpressionEnricher
18  {
19  
20      public static final String NAME = "header";
21  
22      public void enrich(String expression, MuleMessage message, Object object)
23      {
24          String propertyName = expression;
25          PropertyScope scope = ExpressionUtils.getScope(expression);
26          if (scope != null)
27          {
28              // cut-off leading scope and separator
29              propertyName = expression.substring(scope.getScopeName().length() + 1);
30          }
31          else
32          {
33              // default
34              scope = PropertyScope.OUTBOUND;
35          }
36  
37          message.setProperty(propertyName, object, scope);
38      }
39  
40      public String getName()
41      {
42          return NAME;
43      }
44  
45      public void setName(String name)
46      {
47          throw new UnsupportedOperationException();
48      }
49  
50  }