/** * The execution function. Executes a server side command. * * @param command * The command to be executed. This command is a wrapper around the actual request object. * @param callback * A <code>CommandCallback</code> function to be executed when the command successfully returns. The * callbacks may implement CommunicationExceptionCallback or CommandExceptionCallback to allow error * handling. * @return deferred object which can be used to add extra callbacks */ public Deferred execute(final GwtCommand command, final CommandCallback... callback) { final Deferred deferred = new Deferred(); for (CommandCallback successCallback : callback) { try { deferred.addCallback(successCallback); } catch (Throwable t) { Log.logError("Command failed on success callback", t); } } return execute(command, deferred); }
/** * Log a message in the server log. * * @param logLevel log level * @param message message to log * @param throwable exception to include in message */ public static void logServer(int logLevel, String message, Throwable throwable) { String logMessage = message; if (null == logMessage) { logMessage = ""; } if (null != throwable) { logMessage += "\n" + getMessage(throwable); } LogRequest logRequest = new LogRequest(); logRequest.setLevel(logLevel); logRequest.setStatement(logMessage); GwtCommand command = new GwtCommand(LogRequest.COMMAND); command.setCommandRequest(logRequest); Deferred deferred = new Deferred(); deferred.setLogCommunicationExceptions(false); GwtCommandDispatcher.getInstance().execute(command, deferred); }