[jboss-cvs] jboss-seam/src/main/org/jboss/seam/bpm ...
Peter Muir
peter at bleepbleep.org.uk
Wed Nov 28 13:03:56 EST 2007
User: pmuir
Date: 07/11/28 13:03:56
Modified: src/main/org/jboss/seam/bpm SeamExpressionEvaluator.java
Log:
JBSEAM-2152 - ugh
Revision Changes Path
1.6 +62 -23 jboss-seam/src/main/org/jboss/seam/bpm/SeamExpressionEvaluator.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SeamExpressionEvaluator.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/bpm/SeamExpressionEvaluator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- SeamExpressionEvaluator.java 28 Nov 2007 15:52:23 -0000 1.5
+++ SeamExpressionEvaluator.java 28 Nov 2007 18:03:56 -0000 1.6
@@ -2,14 +2,20 @@
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
import javax.el.CompositeELResolver;
import javax.el.ELContext;
import javax.el.MethodExpression;
+import javax.el.MethodNotFoundException;
+import javax.el.PropertyNotFoundException;
import javax.el.ValueExpression;
import org.jboss.seam.el.EL;
import org.jboss.seam.el.SeamFunctionMapper;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
import org.jbpm.jpdl.el.ELException;
import org.jbpm.jpdl.el.Expression;
import org.jbpm.jpdl.el.ExpressionEvaluator;
@@ -23,12 +29,15 @@
* defined only by the JSF ELResolvers.
*
* @author Gavin King
+ * @author Pete Muir
*
*/
public class SeamExpressionEvaluator
extends ExpressionEvaluator
{
+ private static LogProvider log = Logging.getLogProvider(SeamExpressionEvaluator.class);
+
@Override
public Object evaluate(String expression, Class returnType, final VariableResolver resolver, FunctionMapper mapper)
throws ELException
@@ -52,47 +61,77 @@
private void initMethodExpression()
{
+ if (me == null || ve == null)
+ {
me = EL.EXPRESSION_FACTORY.createMethodExpression(EL.EL_CONTEXT, expression, returnType, new Class[0]);
}
+ }
private void initValueExpression()
{
+ if (me == null || ve == null)
+ {
ve = EL.EXPRESSION_FACTORY.createValueExpression(EL.EL_CONTEXT, expression, returnType);
}
+ }
@Override
public Object evaluate(VariableResolver resolver) throws ELException
{
+ List<javax.el.ELException> exceptions = new ArrayList<javax.el.ELException>();
try
{
- try
- {
- if (me==null && ve==null)
- {
initMethodExpression();
}
- if (me!=null && ve==null)
+ catch (javax.el.ELException e)
{
- return me.invoke(createELContext(resolver, mapper), new Object[0]);
+ exceptions.add(e);
}
+ if (me != null)
+ {
+ try
+ {
+ return me.invoke(createELContext(resolver, mapper), new Object[0]);
}
- catch (javax.el.ELException e)
+ catch (MethodNotFoundException e)
{
- if (ve==null)
+ exceptions.add(e);
+ }
+ }
+
+ try
{
initValueExpression();
- }
- if (ve!=null)
+ if (ve != null)
+ {
+ try
{
return ve.getValue(createELContext(resolver, mapper));
}
+ catch (PropertyNotFoundException e)
+ {
+ exceptions.add(e);
+ }
}
- throw new ELException();
}
catch (javax.el.ELException e)
{
- throw new ELException(e);
+ exceptions.add(e);
+ }
+
+ if (exceptions.size() > 0)
+ {
+ log.debug("Exceptions occurred when parsing " + expression);
+ for (javax.el.ELException e : exceptions)
+ {
+ log.debug("Possible cause", e);
+ }
+ }
+ else if (me == null && ve == null)
+ {
+ log.debug("Error parsing " + expression);
}
+ throw new ELException("Error evaluating " + expression + "; possible causes are logged at debug level");
}
};
}
More information about the jboss-cvs-commits
mailing list