messageheaderexpressionevaluator.java

来自「提供ESB 应用mule源代码 提供ESB 应用mule源代码」· Java 代码 · 共 61 行

JAVA
61
字号
/* * $Id: MessageHeaderExpressionEvaluator.java 13054 2008-10-10 21:45:36Z dfeist $ * -------------------------------------------------------------------------------------- * 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.util.expression;import org.mule.RequestContext;import org.mule.api.transport.MessageAdapter;/** * Looks up the property on the message using the property name given.  If the call on the messgae returns null, * parameters on the inbound endpoint will also be checked. * * @see MessageHeadersListExpressionEvaluator * @see MessageHeadersExpressionEvaluator * @see ExpressionEvaluator * @see ExpressionEvaluatorManager */public class MessageHeaderExpressionEvaluator implements ExpressionEvaluator{    public static final String NAME = "header";    public Object evaluate(String expression, Object message)    {        Object result = null;        if (message instanceof MessageAdapter)        {            result = ((MessageAdapter) message).getProperty(expression);            //Should this fallback be in its own expression evaluator i.e. #[endpoint-param:foo] ??            //I'm not sure becaus ethis way there is a fallback where the message doesn't have a value the            //endpoint can define a default            if (result == null && RequestContext.getEventContext() != null)            {                result = RequestContext.getEventContext().getEndpointURI().getParams().get(expression);            }        }        return result;    }    /**     * {@inheritDoc}     */    public String getName()    {        return NAME;    }    /**     * {@inheritDoc}     */    public void setName(String name)    {        throw new UnsupportedOperationException("setName");    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?