01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.vfny.geoserver.global;
06:
07: import org.springframework.beans.BeansException;
08: import org.springframework.context.ApplicationContext;
09: import org.springframework.context.ApplicationContextAware;
10: import org.springframework.web.context.WebApplicationContext;
11:
12: /**
13: * Places a GeoServer module into the servlet context.
14: * <p>
15: * This class is only around to maintain backwards compatability for hte
16: * struts ui stuff which requires application modules to be placed into the
17: * servlet context.
18: * </p>
19: * @author Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
20: *
21: */
22: public class GeoServerServletContextInitializer implements
23: ApplicationContextAware {
24: /**
25: * The key to register the object under.
26: */
27: String key;
28:
29: /**
30: * The object to register.
31: */
32: Object object;
33:
34: public GeoServerServletContextInitializer(String key, Object object) {
35: this .key = key;
36: this .object = object;
37: }
38:
39: public void setApplicationContext(ApplicationContext context)
40: throws BeansException {
41: if (context instanceof WebApplicationContext) {
42: WebApplicationContext webContext = (WebApplicationContext) context;
43: webContext.getServletContext().setAttribute(key, object);
44: }
45: }
46: }
|