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.WebXmlConfiguration;
11: import org.mortbay.jetty.servlet.ServletHolder;
12: import org.mortbay.jetty.servlet.FilterHolder;
13: import org.picocontainer.PicoContainer;
14: import org.picocontainer.defaults.DefaultPicoContainer;
15:
16: public class PicoWebXmlConfiguration extends WebXmlConfiguration {
17:
18: private PicoContainer parentContainer;
19:
20: public PicoWebXmlConfiguration(PicoContainer parentContainer) {
21: this .parentContainer = parentContainer;
22: }
23:
24: protected ServletHolder newServletHolder() {
25: return new PicoServletHolder(parentContainer);
26: }
27:
28: protected FilterHolder newFilterHolder() {
29: return new PicoFilterHolder(parentContainer);
30: }
31:
32: protected Object newListenerInstance(Class clazz)
33: throws InstantiationException, IllegalAccessException {
34: DefaultPicoContainer child = new DefaultPicoContainer(
35: parentContainer);
36: child.registerComponentImplementation("listener", clazz);
37: return child.getComponentInstance("listener");
38: }
39:
40: }
|