private final IDClientCommand getEvaluationResultCommand( final Channel channel, final GDServer server) { final Integer evaluationID = _evaluationID.get(); final Integer modelID = _modelID.get(); final GDModel model = server.getModelByID(modelID); if (model == null) { final RuntimeException e = new RuntimeException("Invalid modelID (" + modelID + ")"); return new GDExceptionThrowerCommand(e, evaluationID, server); } Method method = null; Object[] materializedArgs = null; try { method = GDUtils.getMethod(model.getClass(), _methodID.get()); materializedArgs = (Object[]) GDSerialization.materializeInServer(_args.get(), channel, server); final Object result = method.invoke(model, materializedArgs); server.evaluated(channel, model, method, materializedArgs, result, null); return new GDEvaluationResultCommand(result, evaluationID, server); } catch (final Exception e) { server.evaluated(channel, model, method, materializedArgs, null, e); final RuntimeException evaluationException = new RuntimeException(toString(), e); return new GDExceptionThrowerCommand(evaluationException, evaluationID, server); } }
@Override public void evaluateInServer(final Channel channel, final GDServer server) { final IDClientCommand command = getEvaluationResultCommand(channel, server); // send the result immediately server.sendCommand(channel, command); }