01: /*****************************************************************************
02: * Copyright (C) NanoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: *****************************************************************************/package org.nanocontainer.webcontainer;
09:
10: import org.mortbay.jetty.webapp.WebAppContext;
11: import org.mortbay.jetty.webapp.WebXmlConfiguration;
12: import org.mortbay.jetty.webapp.Configuration;
13: import org.picocontainer.PicoContainer;
14: import org.nanocontainer.webcontainer.PicoServletHandler;
15:
16: public class PicoWebAppContext extends WebAppContext {
17: private final PicoContainer parentContainer;
18:
19: public PicoWebAppContext(PicoContainer parentContainer) {
20: super (null, null, new PicoServletHandler(parentContainer), null);
21: this .parentContainer = parentContainer;
22: }
23:
24: protected void loadConfigurations() throws Exception {
25: super .loadConfigurations();
26: Configuration[] configurations = getConfigurations();
27: for (int i = 0; i < configurations.length; i++) {
28: if (configurations[i] instanceof WebXmlConfiguration) {
29: configurations[i] = new PicoWebXmlConfiguration(
30: parentContainer);
31: }
32: }
33: setConfigurations(configurations);
34: }
35:
36: }
|