/** Release the continuation */
  public void release() {
    if (continuation != null) {
      try {
        continuation.release();
        ctx.releaseManaged();
      } catch (InterruptedException e) {
        return;
      }
      ctx = null;

      continuation = null;
      script = null;
      scriptClosure = null;

      try {
        getContext().getWriter().flush();
      } catch (Exception e) {
        Util.printStackTrace(e);
      }
      try {
        getContext().getErrorWriter().flush();
      } catch (Exception e) {
        Util.printStackTrace(e);
      }
    }
  }
  /** Create a new context ID and a environment map which we send to the client. */
  protected void setNewContextFactory() {
    env = (Map) getProcessEnvironment().clone();

    addNewContextFactory();

    // short path S1: no PUT request
    ContextServer contextServer = getContextServer();
    AbstractChannelName channelName = contextServer.getChannelName(ctx);
    if (channelName != null) {
      env.put("X_JAVABRIDGE_REDIRECT", channelName.getName());
      ctx.getBridge();
      contextServer.start(channelName, Util.getLogger());
    }

    setStandardEnvironmentValues(env);
  }
 /**
  * Set the context id (X_JAVABRIDGE_CONTEXT) and the override flag (X_JAVABRIDGE_OVERRIDE_HOSTS)
  * into env
  *
  * @param env the environment which will be passed to PHP
  */
 protected void setStandardEnvironmentValues(Map env) {
   /* send the session context now, otherwise the client has to
    * call handleRedirectConnection */
   env.put(Util.X_JAVABRIDGE_CONTEXT, ctx.getId());
 }