use of javax.servlet.Servlet in project jetty.project by eclipse.
the class ServletHolder method destroyInstance.
/* ------------------------------------------------------------ */
@Override
public void destroyInstance(Object o) throws Exception {
if (o == null)
return;
Servlet servlet = ((Servlet) o);
getServletHandler().destroyServlet(servlet);
servlet.destroy();
}
use of javax.servlet.Servlet in project jetty.project by eclipse.
the class ServletHolder method handle.
/* ------------------------------------------------------------ */
/**
* Service a request with this servlet.
*
* @param baseRequest the base request
* @param request the request
* @param response the response
* @throws ServletException if unable to process the servlet
* @throws UnavailableException if servlet is unavailable
* @throws IOException if unable to process the request or response
*/
public void handle(Request baseRequest, ServletRequest request, ServletResponse response) throws ServletException, UnavailableException, IOException {
if (_class == null)
throw new UnavailableException("Servlet Not Initialized");
Servlet servlet = ensureInstance();
// Service the request
Object old_run_as = null;
boolean suspendable = baseRequest.isAsyncSupported();
try {
// Handle aliased path
if (_forcedPath != null)
adaptForcedPathToJspContainer(request);
// Handle run as
if (_identityService != null)
old_run_as = _identityService.setRunAs(baseRequest.getResolvedUserIdentity(), _runAsToken);
if (baseRequest.isAsyncSupported() && !isAsyncSupported()) {
try {
baseRequest.setAsyncSupported(false, this.toString());
servlet.service(request, response);
} finally {
baseRequest.setAsyncSupported(true, null);
}
} else
servlet.service(request, response);
} catch (UnavailableException e) {
makeUnavailable(e);
throw _unavailableEx;
} finally {
// Pop run-as role.
if (_identityService != null)
_identityService.unsetRunAs(old_run_as);
}
}
use of javax.servlet.Servlet in project qi4j-sdk by Qi4j.
the class JettyConfigurationHelper method addServlets.
static void addServlets(ServletContextHandler root, Iterable<ServiceReference<Servlet>> servlets) {
// Iterate the available servlets and add it to the server
for (ServiceReference<Servlet> servlet : servlets) {
ServletInfo servletInfo = servlet.metaInfo(ServletInfo.class);
String servletPath = servletInfo.getPath();
Servlet servletInstance = servlet.get();
ServletHolder holder = new ServletHolder(servletInstance);
holder.setInitParameters(servletInfo.initParams());
root.addServlet(holder, servletPath);
}
}
use of javax.servlet.Servlet in project spring-boot by spring-projects.
the class XmlServletWebServerApplicationContextTests method verifyContext.
private void verifyContext() {
MockServletWebServerFactory factory = this.context.getBean(MockServletWebServerFactory.class);
Servlet servlet = this.context.getBean(Servlet.class);
verify(factory.getServletContext()).addServlet("servlet", servlet);
}
use of javax.servlet.Servlet in project spring-boot by spring-projects.
the class AnnotationConfigServletWebServerApplicationContextTests method sessionScopeAvailableToServlet.
@Test
public void sessionScopeAvailableToServlet() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext(ExampleServletWebServerApplicationConfiguration.class, ExampleServletWithAutowired.class, SessionScopedComponent.class);
Servlet servlet = this.context.getBean(ExampleServletWithAutowired.class);
assertThat(servlet).isNotNull();
}
Aggregations