Search in sources :

Example 6 with ELException

use of org.activiti.engine.impl.javax.el.ELException in project Activiti by Activiti.

the class Builder method main.

/**
	 * Dump out abstract syntax tree for a given expression
	 * 
	 * @param args array with one element, containing the expression string
	 */
public static void main(String[] args) {
    if (args.length != 1) {
        System.err.println("usage: java " + Builder.class.getName() + " <expression string>");
        System.exit(1);
    }
    PrintWriter out = new PrintWriter(System.out);
    Tree tree = null;
    try {
        tree = new Builder(Feature.METHOD_INVOCATIONS).build(args[0]);
    } catch (TreeBuilderException e) {
        System.out.println(e.getMessage());
        System.exit(0);
    }
    NodePrinter.dump(out, tree.getRoot());
    if (!tree.getFunctionNodes().iterator().hasNext() && !tree.getIdentifierNodes().iterator().hasNext()) {
        ELContext context = new ELContext() {

            @Override
            public VariableMapper getVariableMapper() {
                return null;
            }

            @Override
            public FunctionMapper getFunctionMapper() {
                return null;
            }

            @Override
            public ELResolver getELResolver() {
                return null;
            }
        };
        out.print(">> ");
        try {
            out.println(tree.getRoot().getValue(new Bindings(null, null), context, null));
        } catch (ELException e) {
            out.println(e.getMessage());
        }
    }
    out.flush();
}
Also used : ELContext(org.activiti.engine.impl.javax.el.ELContext) ELException(org.activiti.engine.impl.javax.el.ELException) PrintWriter(java.io.PrintWriter)

Example 7 with ELException

use of org.activiti.engine.impl.javax.el.ELException in project Activiti by Activiti.

the class ExpressionFactoryImpl method loadProperties.

private Properties loadProperties(String path) {
    Properties properties = new Properties(loadDefaultProperties());
    // try to find and load properties
    InputStream input = null;
    try {
        input = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
    } catch (SecurityException e) {
        input = ClassLoader.getSystemResourceAsStream(path);
    }
    if (input != null) {
        try {
            properties.load(input);
        } catch (IOException e) {
            throw new ELException("Cannot read EL properties", e);
        } finally {
            try {
                input.close();
            } catch (IOException e) {
            // ignore...
            }
        }
    }
    return properties;
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) ELException(org.activiti.engine.impl.javax.el.ELException) Properties(java.util.Properties)

Example 8 with ELException

use of org.activiti.engine.impl.javax.el.ELException in project Activiti by Activiti.

the class JuelExpression method getValue.

public Object getValue(VariableScope variableScope) {
    ELContext elContext = Context.getProcessEngineConfiguration().getExpressionManager().getElContext(variableScope);
    try {
        ExpressionGetInvocation invocation = new ExpressionGetInvocation(valueExpression, elContext);
        Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(invocation);
        return invocation.getInvocationResult();
    } catch (PropertyNotFoundException pnfe) {
        throw new ActivitiException("Unknown property used in expression: " + expressionText, pnfe);
    } catch (MethodNotFoundException mnfe) {
        throw new ActivitiException("Unknown method used in expression: " + expressionText, mnfe);
    } catch (ELException ele) {
        throw new ActivitiException("Error while evaluating expression: " + expressionText, ele);
    } catch (Exception e) {
        throw new ActivitiException("Error while evaluating expression: " + expressionText, e);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ELContext(org.activiti.engine.impl.javax.el.ELContext) PropertyNotFoundException(org.activiti.engine.impl.javax.el.PropertyNotFoundException) ELException(org.activiti.engine.impl.javax.el.ELException) MethodNotFoundException(org.activiti.engine.impl.javax.el.MethodNotFoundException) ExpressionGetInvocation(org.activiti.engine.impl.delegate.ExpressionGetInvocation) ActivitiException(org.activiti.engine.ActivitiException) PropertyNotFoundException(org.activiti.engine.impl.javax.el.PropertyNotFoundException) MethodNotFoundException(org.activiti.engine.impl.javax.el.MethodNotFoundException) ELException(org.activiti.engine.impl.javax.el.ELException)

Aggregations

ELException (org.activiti.engine.impl.javax.el.ELException)8 Method (java.lang.reflect.Method)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Properties (java.util.Properties)2 ActivitiException (org.activiti.engine.ActivitiException)2 ELContext (org.activiti.engine.impl.javax.el.ELContext)2 PropertyNotFoundException (org.activiti.engine.impl.javax.el.PropertyNotFoundException)2 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ExpressionGetInvocation (org.activiti.engine.impl.delegate.ExpressionGetInvocation)1 MethodNotFoundException (org.activiti.engine.impl.javax.el.MethodNotFoundException)1 ValueExpression (org.activiti.engine.impl.javax.el.ValueExpression)1 Feature (org.activiti.engine.impl.juel.Builder.Feature)1