    001    package org.nanocontainer.webcontainer;
    002
    003    import javax.servlet.Filter;
    004
    005    import org.mortbay.jetty.servlet.FilterHolder;
    006    import org.picocontainer.PicoContainer;
    007    import org.picocontainer.defaults.DefaultPicoContainer;
    008
    009    public class PicoFilterHolder extends FilterHolder {
    010
    011        private final PicoContainer parentContainer;
    012
    013        public PicoFilterHolder(PicoContainer parentContainer) {
    014            this.parentContainer = parentContainer;
    015        }
    016
    017        public PicoFilterHolder(Class filterClass, PicoContainer parentContainer) {
    018            super(filterClass);
    019            this.parentContainer = parentContainer;
    020        }
    021
    022        public synchronized Object newInstance() throws InstantiationException, IllegalAccessException {
    023            DefaultPicoContainer child = new DefaultPicoContainer(parentContainer);
    024            child.registerComponentImplementation(Filter.class, _class);
    025            return child.getComponentInstance(Filter.class);
    026        }
    027
    028
    029    }