javax.servlet.SingleThreadModel Java Examples

The following examples show how to use javax.servlet.SingleThreadModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ManagedServlet.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public ManagedServlet(final ServletInfo servletInfo, final ServletContextImpl servletContext) {
    this.servletInfo = servletInfo;
    this.servletContext = servletContext;
    if (SingleThreadModel.class.isAssignableFrom(servletInfo.getServletClass())) {
        instanceStrategy = new SingleThreadModelPoolStrategy(servletInfo.getInstanceFactory(), servletInfo, servletContext);
    } else {
        instanceStrategy = new DefaultInstanceStrategy(servletInfo.getInstanceFactory(), servletInfo, servletContext);
    }
    setupMultipart(servletContext);
}
 
Example #2
Source File: ManagedServlet.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public ManagedServlet(final ServletInfo servletInfo, final ServletContextImpl servletContext) {
    this.servletInfo = servletInfo;
    this.servletContext = servletContext;
    if (SingleThreadModel.class.isAssignableFrom(servletInfo.getServletClass())) {
        instanceStrategy = new SingleThreadModelPoolStrategy(servletInfo.getInstanceFactory(), servletInfo, servletContext);
    } else {
        instanceStrategy = new DefaultInstanceStrategy(servletInfo.getInstanceFactory(), servletInfo, servletContext);
    }
    setupMultipart(servletContext);
}
 
Example #3
Source File: RequestDispatcherImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void service(Request request, Response response)
    throws IOException, ServletException
{
  if (httpContext.handleSecurity(request, response)) {

    final Thread t = Thread.currentThread();
    Stack<String> usedURIStack = threadStacks.get(t);
    if (usedURIStack == null) {
      usedURIStack = new Stack<String>();
      threadStacks.put(t, usedURIStack);
    }
    String uri =
      (String) request.getAttribute("javax.servlet.include.request_uri");
    if (uri == null) {
      uri = request.getRequestURI();
    }
    if (usedURIStack.contains(uri)) {
      throw new ServletException("Recursive include of \"" + uri + "\"");
    }

    usedURIStack.push(uri);
    try {
      if (servlet instanceof SingleThreadModel) {
        synchronized (servlet) {
          if (config == null) {
            // Activator.log.info("Serving: " + uri);
            servlet.service(request, response);
            // Activator.log.info("Served: " + uri);
          } else {
            serviceResource(request, response, config);
          }
        }
      } else {
        if (config == null) {
          // Activator.log.info(Thread.currentThread().getName() + " Serving: " + uri);
          servlet.service(request, response);
          // Activator.log.info(Thread.currentThread().getName() + " Served: " + uri);
        } else {
          serviceResource(request, response, config);
        }
      }
    } finally {
      usedURIStack.pop();
      if (usedURIStack.empty()) {
        threadStacks.remove(t);
      }
    }

  }
}