Search in sources :

Example 6 with PropertyNotFoundException

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

the class AstProperty method invoke.

public Object invoke(Bindings bindings, ELContext context, Class<?> returnType, Class<?>[] paramTypes, Object[] paramValues) {
    Object base = prefix.eval(bindings, context);
    if (base == null) {
        throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", prefix));
    }
    Object property = getProperty(bindings, context);
    if (property == null && strict) {
        throw new PropertyNotFoundException(LocalMessages.get("error.property.method.notfound", "null", base));
    }
    String name = bindings.convert(property, String.class);
    Method method = findMethod(name, base.getClass(), returnType, paramTypes);
    try {
        return method.invoke(base, paramValues);
    } catch (IllegalAccessException e) {
        throw new ELException(LocalMessages.get("error.property.method.access", name, base.getClass()));
    } catch (IllegalArgumentException e) {
        throw new ELException(LocalMessages.get("error.property.method.invocation", name, base.getClass()), e);
    } catch (InvocationTargetException e) {
        throw new ELException(LocalMessages.get("error.property.method.invocation", name, base.getClass()), e.getCause());
    }
}
Also used : PropertyNotFoundException(org.activiti.engine.impl.javax.el.PropertyNotFoundException) Method(java.lang.reflect.Method) ELException(org.activiti.engine.impl.javax.el.ELException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 7 with PropertyNotFoundException

use of org.activiti.engine.impl.javax.el.PropertyNotFoundException 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)

Example 8 with PropertyNotFoundException

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

the class ExpressionBeanAccessTest method testConfigurationBeanAccess.

@Deployment
public void testConfigurationBeanAccess() {
    // Exposed bean returns 'I'm exposed' when to-string is called in first service-task
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("expressionBeanAccess");
    assertEquals("I'm exposed", runtimeService.getVariable(pi.getId(), "exposedBeanResult"));
    // is not added to the beans-list
    try {
        runtimeService.signal(pi.getId());
        fail("Exception expected");
    } catch (ActivitiException ae) {
        assertNotNull(ae.getCause());
        assertTrue(ae.getCause() instanceof PropertyNotFoundException);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) PropertyNotFoundException(org.activiti.engine.impl.javax.el.PropertyNotFoundException) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

PropertyNotFoundException (org.activiti.engine.impl.javax.el.PropertyNotFoundException)8 ValueExpression (org.activiti.engine.impl.javax.el.ValueExpression)4 Method (java.lang.reflect.Method)2 ActivitiException (org.activiti.engine.ActivitiException)2 ELException (org.activiti.engine.impl.javax.el.ELException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ExpressionGetInvocation (org.activiti.engine.impl.delegate.ExpressionGetInvocation)1 ELContext (org.activiti.engine.impl.javax.el.ELContext)1 MethodInfo (org.activiti.engine.impl.javax.el.MethodInfo)1 MethodNotFoundException (org.activiti.engine.impl.javax.el.MethodNotFoundException)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 Deployment (org.activiti.engine.test.Deployment)1