01: package com.icesoft.faces.webapp.http.servlet;
02:
03: import com.icesoft.faces.webapp.http.common.Configuration;
04: import com.icesoft.faces.webapp.http.common.Server;
05:
06: import javax.servlet.http.HttpServletRequest;
07: import javax.servlet.http.HttpServletResponse;
08:
09: public class EnvironmentAdaptingServlet implements PseudoServlet {
10: private PseudoServlet servlet;
11:
12: public EnvironmentAdaptingServlet(Server server,
13: Configuration configuration) {
14: boolean useJettyContinuationsByDefault;
15: try {
16: this .getClass().getClassLoader().loadClass(
17: "org.mortbay.util.ajax.Continuation");
18: useJettyContinuationsByDefault = true;
19: } catch (ClassNotFoundException e) {
20: useJettyContinuationsByDefault = false;
21: }
22:
23: if (configuration
24: .getAttributeAsBoolean("useJettyContinuations",
25: useJettyContinuationsByDefault)) {
26: servlet = new ContinuationAdaptingServlet(server);
27: } else {
28: servlet = new ThreadBlockingAdaptingServlet(server);
29: }
30: }
31:
32: public void service(HttpServletRequest request,
33: HttpServletResponse response) throws Exception {
34: servlet.service(request, response);
35: }
36:
37: public void shutdown() {
38: servlet.shutdown();
39: }
40: }
|