private void fire(Enum<?> e, Enum<?> serverCallId, Object... params) {
   if (params == null) {
     JavaScriptExpressionEvaluator.getInstance().eval(e, serverCallId.name());
   } else {
     String[] xmlParams = new String[params.length + 1];
     xmlParams[0] = serverCallId.name();
     for (int i = 0; i < params.length; i++) {
       xmlParams[i + 1] = Utils.escape(Utils.toString(params[i]));
       LOG.log(Level.FINE, "Param {0}", i);
       if (LOG.isLoggable(Level.FINE)) {
         LOG.log(Level.FINE, Utils.toString(params[i]));
       }
     }
     JavaScriptExpressionEvaluator.getInstance().eval(e, xmlParams);
   }
 }
 /**
  * Fire the serverCall.
  *
  * @param serverCall the serverCall to fire
  */
 public void fire(ServerCall serverCall) {
   LOG.log(
       Level.FINE, "asynchronous caller fires({0})", serverCall.getAsynchronousServerCallName());
   fire(
       serverCall.getAsynchronousServerCallName(),
       serverCall.getServerCallId(),
       (serverCall.getParams() == null || serverCall.getParams().length == 0
           ? new Object[] {new Object()}
           : serverCall.getParams()));
 }
/**
 * Fire asynchronous request to server, serializing object passed as parameters to XML. It relies on
 * {@link JavaScriptExpressionEvaluator}.
 *
 * <p>DISCLAIMER: Project owner DG-JUSTICE.
 *
 * @author <a href="mailto:[email protected]">ARHS Developments</a>
 */
public final class JavaScriptAsynchronousCaller implements AsynchronousCaller {

  private static final DssLogger LOG =
      DssLogger.getLogger(JavaScriptAsynchronousCaller.class.getSimpleName());

  /**
   * Fire the serverCall.
   *
   * @param serverCall the serverCall to fire
   */
  public void fire(ServerCall serverCall) {
    LOG.log(
        Level.FINE, "asynchronous caller fires({0})", serverCall.getAsynchronousServerCallName());
    fire(
        serverCall.getAsynchronousServerCallName(),
        serverCall.getServerCallId(),
        (serverCall.getParams() == null || serverCall.getParams().length == 0
            ? new Object[] {new Object()}
            : serverCall.getParams()));
  }

  private void fire(Enum<?> e, Enum<?> serverCallId, Object... params) {
    if (params == null) {
      JavaScriptExpressionEvaluator.getInstance().eval(e, serverCallId.name());
    } else {
      String[] xmlParams = new String[params.length + 1];
      xmlParams[0] = serverCallId.name();
      for (int i = 0; i < params.length; i++) {
        xmlParams[i + 1] = Utils.escape(Utils.toString(params[i]));
        LOG.log(Level.FINE, "Param {0}", i);
        if (LOG.isLoggable(Level.FINE)) {
          LOG.log(Level.FINE, Utils.toString(params[i]));
        }
      }
      JavaScriptExpressionEvaluator.getInstance().eval(e, xmlParams);
    }
  }
}