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.jaxer.servlet;
17:
18: import java.io.IOException;
19:
20: import javax.servlet.http.HttpServletRequest;
21: import javax.servlet.http.HttpServletResponse;
22:
23: import org.directwebremoting.servlet.InterfaceHandler;
24: import org.directwebremoting.servlet.PathConstants;
25:
26: /**
27: * A handler for interface generation requests
28: * @author Joe Walker [joe at getahead dot ltd dot uk]
29: */
30: public class JaxerInterfaceHandler extends InterfaceHandler {
31: /* (non-Javadoc)
32: * @see org.directwebremoting.servlet.TemplateHandler#generateTemplate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
33: */
34: @Override
35: protected String generateTemplate(HttpServletRequest request,
36: HttpServletResponse response) throws IOException {
37: String scriptName = request.getPathInfo();
38: scriptName = scriptName.replaceFirst("/", "");
39: scriptName = scriptName.replace(PathConstants.EXTENSION_JS, "");
40:
41: String path = request.getContextPath()
42: + request.getServletPath();
43:
44: return remoter.generateInterfaceScript(scriptName, path);
45: }
46:
47: /* (non-Javadoc)
48: * @see java.lang.Object#toString()
49: */
50: @Override
51: public String toString() {
52: return "JaxerInterfaceHandler(" + interfaceHandlerUrl + ")";
53: }
54: }
|