Added better checking for el-api version

This commit is contained in:
Jeremy Grelle
2008-03-07 15:04:39 +00:00
parent 448a00b6f6
commit 2a81c7b8db

View File

@@ -4,15 +4,18 @@ import java.util.ArrayList;
import java.util.List;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELResolver;
import javax.el.ExpressionFactory;
import javax.el.FunctionMapper;
import javax.el.VariableMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.binding.expression.el.DefaultELResolver;
import org.springframework.binding.expression.el.ELContextFactory;
import org.springframework.binding.expression.el.ELExpressionParser;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.webflow.core.collection.MutableAttributeMap;
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.expression.el.ActionMethodELResolver;
@@ -30,6 +33,10 @@ import org.springframework.webflow.expression.el.SpringSecurityELResolver;
*/
public class LegacyJSFELExpressionParser extends ELExpressionParser {
private static final String EXPRESSION_FACTORY_PROPERTY = "javax.el.ExpressionFactory";
private static final String DEFAULT_EXPRESSION_FACTORY = "org.jboss.el.ExpressionFactoryImpl";
public LegacyJSFELExpressionParser(ExpressionFactory expressionFactory) {
super(expressionFactory);
putContextFactory(RequestContext.class, new RequestContextELContextFactory());
@@ -41,10 +48,18 @@ public class LegacyJSFELExpressionParser extends ELExpressionParser {
}
private static ExpressionFactory getDefaultExpressionFactory() {
if (!System.getProperties().containsKey("javax.el.ExpressionFactory")) {
System.setProperty("javax.el.ExpressionFactory", "org.jboss.el.ExpressionFactoryImpl");
if (!System.getProperties().containsKey(EXPRESSION_FACTORY_PROPERTY)) {
System.setProperty(EXPRESSION_FACTORY_PROPERTY, DEFAULT_EXPRESSION_FACTORY);
}
if (ReflectionUtils.findMethod(ExpressionFactory.class, "newInstance") != null) {
return ExpressionFactory.newInstance();
} else { // Fallback in case using an older version of el-api
try {
return (ExpressionFactory) BeanUtils.instantiateClass(Class.forName(DEFAULT_EXPRESSION_FACTORY));
} catch (Exception e) {
throw new ELException("Could not create the default ExpressionFactory", e);
}
}
return ExpressionFactory.newInstance();
}
private static class RequestContextELContextFactory implements ELContextFactory {