1 10 11 package org.nanocontainer.reflection; 12 13 import java.io.Serializable ; 14 import org.nanocontainer.NanoPicoContainer; 15 import org.picocontainer.ComponentMonitor; 16 import org.picocontainer.MutablePicoContainer; 17 import org.picocontainer.PicoContainer; 18 import org.picocontainer.defaults.ComponentAdapterFactory; 19 import org.picocontainer.defaults.ComponentMonitorStrategy; 20 import org.picocontainer.defaults.DefaultComponentAdapterFactory; 21 import org.picocontainer.defaults.DefaultPicoContainer; 22 import org.picocontainer.defaults.LifecycleStrategy; 23 24 35 public class DefaultNanoPicoContainer extends AbstractNanoPicoContainer implements NanoPicoContainer, Serializable , 36 ComponentMonitorStrategy { 37 38 public DefaultNanoPicoContainer(ClassLoader classLoader, ComponentAdapterFactory caf, PicoContainer parent) { 39 super(new DefaultPicoContainer(caf, parent), classLoader); 40 } 41 42 public DefaultNanoPicoContainer(ClassLoader classLoader, PicoContainer parent) { 43 super(new DefaultPicoContainer(new DefaultComponentAdapterFactory(), parent), classLoader); 44 } 45 46 public DefaultNanoPicoContainer(ClassLoader classLoader, PicoContainer parent, ComponentMonitor componentMonitor) { 47 super(new DefaultPicoContainer(new DefaultComponentAdapterFactory(componentMonitor), parent), classLoader); 48 } 49 50 public DefaultNanoPicoContainer(ComponentAdapterFactory caf) { 51 super(new DefaultPicoContainer(caf, null), DefaultNanoPicoContainer.class.getClassLoader()); 52 } 53 54 public DefaultNanoPicoContainer(PicoContainer pc) { 55 super(new DefaultPicoContainer(pc), DefaultNanoPicoContainer.class.getClassLoader()); 56 } 57 58 public DefaultNanoPicoContainer(ClassLoader classLoader) { 59 super(new DefaultPicoContainer(), classLoader); 60 } 61 62 public DefaultNanoPicoContainer() { 63 super(new DefaultPicoContainer(), DefaultNanoPicoContainer.class.getClassLoader()); 64 } 65 66 67 76 public DefaultNanoPicoContainer(ComponentAdapterFactory componentAdapterFactory, 77 LifecycleStrategy lifecycleStrategyForInstanceRegistrations, PicoContainer parent, ClassLoader cl) { 78 79 super(new DefaultPicoContainer(componentAdapterFactory, 80 lifecycleStrategyForInstanceRegistrations, parent), 81 (cl != null) ? cl : DefaultNanoPicoContainer.class.getClassLoader()); 83 } 84 85 94 protected DefaultNanoPicoContainer(final DefaultNanoPicoContainer parent) { 95 super(parent.getDelegate().makeChildContainer(), parent.getComponentClassLoader()); 96 MutablePicoContainer parentDelegate = parent.getDelegate(); 97 parentDelegate.removeChildContainer(getDelegate()); 98 parentDelegate.addChildContainer(this); 99 } 100 101 102 protected AbstractNanoPicoContainer createChildContainer() { 103 return new DefaultNanoPicoContainer(this); 104 } 105 106 public void changeMonitor(ComponentMonitor monitor) { 107 ((ComponentMonitorStrategy)getDelegate()).changeMonitor(monitor); 108 } 109 110 public ComponentMonitor currentMonitor() { 111 return ((ComponentMonitorStrategy)getDelegate()).currentMonitor(); 112 } 113 114 } 115 | Popular Tags |