01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.pageflow.handler;
20:
21: import javax.servlet.ServletContext;
22: import java.io.Serializable;
23:
24: /**
25: * Default implementation of the base Handler interface. Simply stores a reference to the ServletContext and offers
26: * access to the previously-registered Handler of the same type (the one that comes before the current one in the
27: * list under <code><pageflow-handlers></code> in beehive-netui-config.xml).
28: */
29: public abstract class BaseHandler implements Handler, Serializable {
30: private transient ServletContext _servletContext;
31: private HandlerConfig _config;
32: private Handler _previousHandler;
33:
34: protected BaseHandler() {
35: }
36:
37: /**
38: * Initialize.
39: *
40: * @param handlerConfig the configuration object for this Handler.
41: * @param previousHandler the previously-registered Handler, which this one can adapt.
42: * @param servletContext the ServletContext for the webapp that is creating this object.
43: */
44: public void init(HandlerConfig handlerConfig,
45: Handler previousHandler, ServletContext servletContext) {
46: _servletContext = servletContext;
47: _previousHandler = previousHandler;
48: _config = handlerConfig;
49: }
50:
51: protected final ServletContext getServletContext() {
52: assert _servletContext != null;
53: return _servletContext;
54: }
55:
56: protected Handler getPreviousHandler() {
57: return _previousHandler;
58: }
59:
60: protected HandlerConfig getConfig() {
61: return _config;
62: }
63:
64: public void reinit(ServletContext servletContext) {
65: _servletContext = servletContext;
66: }
67: }
|