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.impl;
17:
18: import org.apache.commons.logging.Log;
19: import org.apache.commons.logging.LogFactory;
20: import org.directwebremoting.extend.Creator;
21: import org.directwebremoting.extend.EnginePrivate;
22: import org.directwebremoting.impl.DefaultRemoter;
23:
24: /**
25: * This is a customization of {@link DefaultRemoter} which is needed because
26: * DWR+Jaxer has a different definition of scriptName than plain vanilla DWR
27: * @author Joe Walker [joe at getahead dot ltd dot uk]
28: */
29: public class JaxerRemoter extends DefaultRemoter {
30: /* (non-Javadoc)
31: * @see org.directwebremoting.Remoter#generateInterfaceScript(java.lang.String, java.lang.String)
32: */
33: @Override
34: public String generateInterfaceScript(String fullCreatorName,
35: String contextServletPath) throws SecurityException {
36: Creator creator = creatorManager.getCreator(fullCreatorName);
37: if (creator == null) {
38: log
39: .warn("Failed to find creator using: "
40: + fullCreatorName);
41: throw new SecurityException("Failed to find creator");
42: }
43:
44: String scriptName = creator.getJavascript();
45:
46: StringBuilder buffer = new StringBuilder();
47:
48: buffer.append(createParameterDefinitions(scriptName));
49: buffer.append(EnginePrivate.getEngineInitScript());
50: buffer.append(createClassDefinition(scriptName));
51: buffer.append(createPathDefinition(scriptName,
52: contextServletPath));
53: buffer.append(createMethodDefinitions(fullCreatorName));
54:
55: return buffer.toString();
56: }
57:
58: /**
59: * The log stream
60: */
61: private static final Log log = LogFactory
62: .getLog(JaxerRemoter.class);
63: }
|