01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.directwebremoting.impl;
17:
18: import javax.servlet.ServletConfig;
19: import javax.servlet.http.HttpServletRequest;
20:
21: import org.directwebremoting.extend.ContainerAbstraction;
22: import org.directwebremoting.extend.ServerLoadMonitor;
23: import org.directwebremoting.extend.Sleeper;
24:
25: /**
26: * An abstraction of the servlet container that is specific to Jetty
27: * @author Joe Walker [joe at getahead dot ltd dot uk]
28: */
29: public class JettyContainerAbstraction implements ContainerAbstraction {
30: /* (non-Javadoc)
31: * @see org.directwebremoting.dwrp.ContainerAbstraction#isNativeEnvironment(javax.servlet.ServletConfig)
32: */
33: public boolean isNativeEnvironment(ServletConfig servletConfig) {
34: String serverInfo = servletConfig.getServletContext()
35: .getServerInfo();
36: if (serverInfo.startsWith("jetty-")) {
37: try {
38: int version = Integer.parseInt(serverInfo.substring(6,
39: 7));
40: if (version >= 6) {
41: return true;
42: }
43: } catch (NumberFormatException ex) {
44: // ignore
45: }
46: }
47:
48: return false;
49: }
50:
51: /* (non-Javadoc)
52: * @see org.directwebremoting.dwrp.ContainerAbstraction#createSleeper(javax.servlet.http.HttpServletRequest)
53: */
54: public Sleeper createSleeper(HttpServletRequest request) {
55: return new JettyContinuationSleeper(request);
56: }
57:
58: /* (non-Javadoc)
59: * @see org.directwebremoting.dwrp.ContainerAbstraction#getServerLoadMonitorImplementation()
60: */
61: public Class<? extends ServerLoadMonitor> getServerLoadMonitorImplementation() {
62: return ThreadDroppingServerLoadMonitor.class;
63: }
64: }
|