boolean oldVal = req.getCallbacks().get(method); boolean newVal = (Boolean) r; if (oldVal == false && newVal == true) {
Boolean oldVal = req.getCallbacks().get(method); Boolean newVal = (Boolean) r; if ((oldVal == null || oldVal == false) && newVal == true) {
    protected void evaluateCallbacks(final Request req) {        final Object bean = req.getBean();        ReflectionUtils.doWithMethods(bean.getClass(), new ReflectionUtils.MethodCallback() {            @SuppressWarnings("unchecked")            public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {                if (method.getAnnotation(Callback.class) != null) {                    try {                        Expression e = ExpressionFactory.createExpression(method.getAnnotation(Callback.class).condition());                        JexlContext jc = JexlHelper.createContext();                        jc.getVars().put("this", bean);                        Object r = e.evaluate(jc);                        if (r instanceof Boolean == false) {                            throw new RuntimeException("Expression did not returned a boolean value but: " + r);                        }                        boolean oldVal = req.getCallbacks().get(method);                        boolean newVal = (Boolean) r;                        if (oldVal == false && newVal == true) {                            req.getCallbacks().put(method, newVal);                            Object o = method.invoke(bean, new Object[0]);                            // TODO: handle return value and sent it as the answer                        }                    } catch (Exception e) {                        throw new RuntimeException("Unable to invoke callback", e);                    }                }            }        });    }