public Object interpret(HelperAdapter helper) throws ExecuteException { Object recipientValue = null; try { if (recipient != null) { recipientValue = recipient.interpret(helper); if (recipientValue == null) { throw new ExecuteException( "MethodExpression.interpret : null recipient for method " + token.getText() + getPos()); } } int argCount = arguments.size(); Object[] argValues = new Object[argCount]; for (int i = 0; i < argCount; i++) { argValues[i] = arguments.get(i).interpret(helper); } // execute setTriggering directly rather than via reflection // that way rule code switch off triggering for a rule injected // into code used by Method.invoke() if (method.equals(setTriggeringMethod)) { boolean setting = (Boolean) argValues[0]; if (setting) { Rule.enableTriggers(); } else { Rule.disableTriggers(); } return true; } // we have to enable triggers whenever we call out to a method in case it contians a trigger // point // TODO - do we do this if the method is a built-in? i.e. if the target is an instance of the // helper class // TODO - this breaks the user disable option so fix it! Rule.enableTriggersInternal(); return method.invoke(recipientValue, argValues); } catch (InvocationTargetException e) { Throwable th = e.getCause(); if (th instanceof ExecuteException) { throw (ExecuteException) th; } else { throw new ExecuteException( "MethodExpression.interpret : exception invoking method " + token.getText() + getPos(), th); } } catch (ExecuteException e) { throw e; } catch (Exception e) { throw new ExecuteException( "MethodExpression.interpret : exception invoking method " + token.getText() + getPos(), e); } finally { // disable triggers again Rule.disableTriggersInternal(); } }