All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mule.expression.MessageHeaderExpressionEnricher Maven / Gradle / Ivy

There is a newer version: 3.9.0
Show newest version
/*
 * $Id: MessageHeaderExpressionEnricher.java 20273 2010-11-19 12:52:55Z dirk.olmes $
 * --------------------------------------------------------------------------------------
 * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

package org.mule.expression;

import org.mule.api.MuleMessage;
import org.mule.api.expression.ExpressionEnricher;
import org.mule.api.transport.PropertyScope;

public class MessageHeaderExpressionEnricher implements ExpressionEnricher
{

    public static final String NAME = "header";

    public void enrich(String expression, MuleMessage message, Object object)
    {
        String propertyName = expression;
        PropertyScope scope = ExpressionUtils.getScope(expression);
        if (scope != null)
        {
            // cut-off leading scope and separator
            propertyName = expression.substring(scope.getScopeName().length() + 1);
        }
        else
        {
            // default
            scope = PropertyScope.OUTBOUND;
        }

        message.setProperty(propertyName, object, scope);
    }

    public String getName()
    {
        return NAME;
    }

    public void setName(String name)
    {
        throw new UnsupportedOperationException();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy