01: /*
02: * Created on Nov 19, 2005
03: */
04: package uk.org.ponder.rsac.servlet;
05:
06: import javax.servlet.ServletContext;
07:
08: import org.springframework.beans.BeansException;
09: import org.springframework.context.ApplicationContext;
10: import org.springframework.context.ApplicationContextAware;
11: import org.springframework.util.StringUtils;
12: import org.springframework.web.context.ConfigurableWebApplicationContext;
13: import org.springframework.web.context.WebApplicationContext;
14:
15: import uk.org.ponder.rsac.RSACResourceLocator;
16:
17: /** Decodes the locations of request-scope bean containers from the
18: * parent ServletContext of the current application context.
19: * @author Antranig Basman (antranig@caret.cam.ac.uk)
20: *
21: */
22: public class ServletRSACResourceLocator implements RSACResourceLocator,
23: ApplicationContextAware {
24: public static final String REQUEST_CONTEXT_CONFIG_LOCATION = "requestContextConfigLocation";
25:
26: private String[] configlocations;
27: private ApplicationContext applicationcontext;
28:
29: public void setApplicationContext(
30: ApplicationContext applicationContext)
31: throws BeansException {
32: this .applicationcontext = applicationContext;
33: WebApplicationContext wac = (WebApplicationContext) applicationContext;
34: ServletContext context = wac.getServletContext();
35: String configlocation = context
36: .getInitParameter(REQUEST_CONTEXT_CONFIG_LOCATION);
37: configlocations = StringUtils
38: .tokenizeToStringArray(
39: configlocation,
40: ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS);
41: }
42:
43: public String[] getConfigLocations() {
44: return configlocations;
45: }
46:
47: public ApplicationContext getApplicationContext() {
48: return applicationcontext;
49: }
50:
51: }
|