Package net.sourceforge.javautil.web.server.impl

Source Code of net.sourceforge.javautil.web.server.impl.WebServerHostValveContextAbstract

package net.sourceforge.javautil.web.server.impl;

import java.security.Principal;

import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import net.sourceforge.javautil.web.server.WebServerHostValve;
import net.sourceforge.javautil.web.server.WebServerHostValveContext;
import net.sourceforge.javautil.web.server.application.WebApplicationDeploymentContext;
import net.sourceforge.javautil.web.server.application.IWebApplicationRequest;
import net.sourceforge.javautil.web.server.application.IWebApplicationResponse;
import net.sourceforge.javautil.web.server.application.impl.WebApplicationRequestBase;
import net.sourceforge.javautil.web.server.application.impl.WebApplicationResponseBase;

/**
* A base for most valve context implementations.
*
* @author elponderador
* @author $Author: ponderator $
* @version $Id: WebServerHostValveContextAbstract.java 2287 2010-06-14 04:25:09Z ponderator $
*/
public abstract class WebServerHostValveContextAbstract implements WebServerHostValveContext {
 
  protected final WebServerHostValve[] valves;
  protected final WebServerHostValveTarget target;
  protected final WebApplicationDeploymentContext context;
  protected final IWebApplicationRequest request;
  protected final IWebApplicationResponse response;
  protected int valvePointer = 0;

  public WebServerHostValveContextAbstract(WebApplicationDeploymentContext context, ServletRequest request, ServletResponse response,
      WebServerHostValveTarget target, WebServerHostValve... valves) {
    this.valves = valves;
    this.target = target;
    this.context = context;
    this.request = new WebApplicationRequestBase(request);
    this.response = new WebApplicationResponseBase(response);
  }

  public void invokeNext(WebServerHostValveContext ctx) {
    if (this.valvePointer < this.valves.length)
      this.valves[this.valvePointer++].invoke(ctx);
    else
      this.target.invoke(ctx);
  }

  public void next() { this.invokeNext(this); }
 
  public WebApplicationDeploymentContext getDeploymentContext() { return this.context; }

  public IWebApplicationRequest getRequest() { return this.request; }

  public IWebApplicationResponse getResponse() { return this.response; }

  public ServletContext getServletContext() { return this.context.getServletContext(); }

}
TOP

Related Classes of net.sourceforge.javautil.web.server.impl.WebServerHostValveContextAbstract

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.