コード例 #1
0
ファイル: ApplesProcessor.java プロジェクト: tpso-src/cocoon
  private void processApple(
      List params, Redirector redirector, AppleController app, WebContinuation wk)
      throws Exception {

    Request cocoonRequest = ContextHelper.getRequest(this.avalonContext);
    AppleRequest req = new DefaultAppleRequest(params, cocoonRequest);
    Response cocoonResponse = ContextHelper.getResponse(this.avalonContext);
    DefaultAppleResponse res = new DefaultAppleResponse(cocoonResponse);

    try {
      app.process(req, res);
    } finally {
      if (wk == null) {
        // dispose stateless apple immediatelly
        if (app instanceof Disposable) {
          try {
            ((Disposable) app).dispose();
          } catch (Exception e) {
            getLogger().error("Error disposing Apple instance.", e);
          }
        }
      }
    }

    if (res.isRedirect()) {
      redirector.redirect(false, res.getURI());
    } else {
      String uri = res.getURI();
      if (getLogger().isDebugEnabled()) {
        getLogger()
            .debug(
                "Apple forwards to "
                    + uri
                    + " with bizdata= "
                    + res.getData()
                    + (wk != null
                        ? " and continuationid= " + wk.getId()
                        : " without continuationid"));
      }

      // Note: it is ok for wk to be null
      this.forwardTo(uri, res.getData(), wk, redirector);
    }

    // TODO allow for AppleResponse to set some boolean saying the use case
    // is completed and the continuation can be invalidated ?
  }
コード例 #2
0
ファイル: ApplesProcessor.java プロジェクト: tpso-src/cocoon
 public void disposeContinuation(WebContinuation webContinuation) {
   AppleController app = (AppleController) webContinuation.getContinuation();
   if (app instanceof Disposable) {
     ((Disposable) app).dispose();
   }
 }