コード例 #1
0
  @Override
  public void handleResult(ProcessObject procObj) {
    try {
      logger.log(Level.INFO, "DSR Status Code: " + procObj.getProfile().getDsrStatusCode());
      if (procObj.getProfile().getDsrStatusCode() == ResourceConst.SERVER_ERROR) {
        // DSR Recognition Failure
        logger.log(Level.WARNING, "No reponse bytes return. Failed to recognize speech.");
        String responseMsg = "Failed to recognize speech.[-1]";
        handleError(ResourceConst.SERVER_ERROR, responseMsg);
      } else {
        // pipeline flow
        for (IResultsHandler handler : processConfig.getHandlers())
          procObj = handler.process(procObj);

        procObj.statusCode = ResourceConst.SERVER_SUCCESS;
      }
    } catch (Exception e) {
      logger.log(Level.WARNING, "Unable to process request due to ", e);
      String responseMsg = "DSR C-server Error";
      handleError(ResourceConst.SERVER_ERROR, responseMsg);
    }

    DSRExecutorResponse er = new DSRExecutorResponse();
    er.setStatus(procObj.statusCode);
    er.setErrorMessage(procObj.errorMessage);
    er.setProcessObject(procObj);
    er.setExecutorType(executorType);
    procObj.profile.totalProcessEnd();
    // call back to the framework with the result
    try {
      callback.doCallback(null, er);
    } catch (Exception e) {
      logger.log(Level.WARNING, "Exception calling back to server", e);
    }

    // callback.doEnd();
  }
コード例 #2
0
  private void processMetaInfo(RecContext context) {
    profile.netIOBegin();
    profile.totalProcessBegin();

    CliTransaction cli = new CliTransaction(CliConstants.TYPE_MODULE);
    cli.setFunctionName("handleMeta");

    // handle meta information
    if (context == null) {
      String responseMsg = "Unable to parse request meta data.";
      handleError(ResourceConst.SERVER_ERROR, responseMsg);
      cli.setStatus("responseMsg");
      cli.complete();
    }

    logger.log(Level.INFO, "Meta handled successfully");
    // Set context obtained form meta
    procObj.setContext(context);

    // Set profiling data
    setProfileInfo();

    // Obtain processConfig for corresponding recType
    int configId = procObj.getContext().recType;
    processConfig = ProcessConfigurationFactory.getConfiguration("" + configId);
    logger.log(Level.INFO, "Obtained process config instance for config id : " + configId);

    // Obtain proxy object
    proxy = processConfig.getProxy();
    proxy.addResultListener(this);

    logger.log(Level.INFO, "Obtained proxy instance from process config");

    // proxy.init(procObj);
    cli.complete();
  }