01: /*
02: * Copyright (C) 2006 Otego AG, Switzerland
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 nl.hippo.util.spring;
17:
18: import javax.servlet.ServletContextEvent;
19: import javax.servlet.ServletContextListener;
20: import javax.servlet.ServletContext;
21:
22: /**
23: * This class
24: */
25: public class MultipleXmlContextLoaderListener implements
26: ServletContextListener {
27: //~ Instance fields ---------------------------------------------------------------------------------
28:
29: /** A field */
30: private MultipleXmlContextLoader m_contextLoader;
31:
32: //~ Methods -----------------------------------------------------------------------------------------
33:
34: /**
35: * Return the ContextLoader used by this servlet.
36: *
37: * @return Value
38: */
39: public MultipleXmlContextLoader getContextLoader() {
40: return m_contextLoader;
41: }
42:
43: /**
44: * Close the root web application context.
45: *
46: * @param event The <code>event</code>
47: */
48: public void contextDestroyed(ServletContextEvent event) {
49: if (this .m_contextLoader != null) {
50: this .m_contextLoader.closeWebApplicationContext(event
51: .getServletContext());
52: }
53: }
54:
55: /**
56: * Initialize the root web application context.
57: *
58: * @param event The <code>event</code>
59: */
60: public void contextInitialized(final ServletContextEvent event) {
61: this .m_contextLoader = createContextLoader(event
62: .getServletContext());
63: this .m_contextLoader.initWebApplicationContext(event
64: .getServletContext());
65: }
66:
67: /**
68: * Create the ContextLoader to use. Can be overridden in subclasses.
69: *
70: * @return the new ContextLoader
71: */
72: protected MultipleXmlContextLoader createContextLoader(
73: ServletContext servletContext) {
74: return new MultipleXmlContextLoader(servletContext);
75: }
76: }
|