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

org.milyn.javabean.expression.BeanMapExpressionEvaluator Maven / Gradle / Ivy

There is a newer version: 1.7.1
Show newest version
/*
	Milyn - Copyright (C) 2006

	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public
	License (version 2.1) as published by the Free Software
	Foundation.

	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

	See the GNU Lesser General Public License for more details:
	http://www.gnu.org/licenses/lgpl.txt
*/
package org.milyn.javabean.expression;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.milyn.cdr.SmooksConfigurationException;
import org.milyn.container.ExecutionContext;
import org.milyn.expression.ExecutionContextExpressionEvaluator;
import org.milyn.expression.ExpressionEvaluationException;
import org.milyn.expression.MVELExpressionEvaluator;
import org.milyn.javabean.repository.BeanRepositoryManager;

/**
 * Javabean Cartridge bean Map expression evaluator.
 * 

* Evaluates MVEL expressions on java objects * bound to the supplied {@link ExecutionContext} via the {@link org.milyn.javabean.repository.BeanRepository}. *

* Cab be used to selectively target resources based on the * contents of the java objects bound to the supplied {@link ExecutionContext} * via the {@link org.milyn.javabean.repository.BeanRepository}. *

* The special EC variable gives access to the EditingContext. * * @author [email protected] */ public class BeanMapExpressionEvaluator extends MVELExpressionEvaluator implements ExecutionContextExpressionEvaluator { /** * */ public static final String MVEL_EXECUTION_CONTEXT_KEY = "EC"; private static Log logger = LogFactory.getLog(BeanMapExpressionEvaluator.class); public BeanMapExpressionEvaluator() { } public BeanMapExpressionEvaluator(String expression) throws SmooksConfigurationException { setExpression(expression); } public boolean eval(ExecutionContext context) throws ExpressionEvaluationException { return (Boolean) getValue(context); } public Object getValue(ExecutionContext context) throws ExpressionEvaluationException { Map beans = BeanRepositoryManager.getBeanRepository(context).getBeanMap(); Object value = getValue(beans); if(logger.isDebugEnabled()) { logger.debug("Expression value evaluation:==============================================================="); logger.debug("\tExpression='" + getExpression() + "'"); logger.debug("\tBean Map='" + beans + "'"); logger.debug("\tValue='" + value + "'"); logger.debug("==========================================================================================="); } return value; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy