01: /*
02: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
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 de.odysseus.calyxo.control.impl;
17:
18: import javax.servlet.http.HttpServletRequest;
19: import javax.servlet.http.HttpServletResponse;
20:
21: import de.odysseus.calyxo.base.ModuleContext;
22: import de.odysseus.calyxo.base.conf.ConfigException;
23: import de.odysseus.calyxo.control.Action;
24: import de.odysseus.calyxo.control.conf.ActionConfig;
25: import de.odysseus.calyxo.control.conf.DispatchConfig;
26:
27: /**
28: * Default action used by the module for actions without action class.
29: * This action answers the action's "default dispatch" configuration,
30: * which is the one with name <code>null</code>.
31: *
32: * @author Christoph Beck
33: */
34: public class DefaultAction implements Action {
35: private DispatchConfig target;
36:
37: /* (non-Javadoc)
38: * @see de.odysseus.calyxo.control.Action#init(de.odysseus.calyxo.control.conf.ActionConfig, de.odysseus.calyxo.base.ModuleContext)
39: */
40: public void init(ActionConfig config, ModuleContext context)
41: throws ConfigException {
42: target = config.findDispatchConfig(null);
43: if (target == null) {
44: throw new ConfigException("Missing default dispatch in "
45: + config.toInlineString());
46: }
47: }
48:
49: /* (non-Javadoc)
50: * @see de.odysseus.calyxo.control.Command#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
51: */
52: public DispatchConfig execute(HttpServletRequest request,
53: HttpServletResponse response) {
54: return target;
55: }
56: }
|