1 10 package org.picocontainer.alternatives; 11 12 import org.picocontainer.MutablePicoContainer; 13 import org.picocontainer.PicoContainer; 14 import org.picocontainer.LifecycleManager; 15 import org.picocontainer.defaults.CachingComponentAdapterFactory; 16 import org.picocontainer.defaults.ComponentAdapterFactory; 17 import org.picocontainer.defaults.DefaultComponentAdapterFactory; 18 import org.picocontainer.defaults.DefaultPicoContainer; 19 import org.picocontainer.defaults.DefaultLifecycleManager; 20 21 import java.io.Serializable ; 22 23 31 public class CachingPicoContainer extends AbstractDelegatingMutablePicoContainer implements Serializable { 32 private LifecycleManager lifecycleManager; 33 private CachingComponentAdapterFactory caf; 34 35 38 public CachingPicoContainer(CachingComponentAdapterFactory caf, PicoContainer parent, LifecycleManager lifecycleManager) { 39 super(new DefaultPicoContainer(caf, parent, lifecycleManager)); 40 this.lifecycleManager = lifecycleManager; 41 this.caf = caf; 42 } 43 44 47 public CachingPicoContainer(CachingComponentAdapterFactory caf, PicoContainer parent) { 48 this(caf, parent, new DefaultLifecycleManager()); 49 } 50 51 public CachingPicoContainer(ComponentAdapterFactory caf, PicoContainer parent) { 52 this(new CachingComponentAdapterFactory(caf), parent); 53 } 54 55 58 public CachingPicoContainer(PicoContainer parent) { 59 this(new DefaultComponentAdapterFactory(), parent); 60 } 61 62 65 public CachingPicoContainer(PicoContainer parent, LifecycleManager lifecycleManager) { 66 this(new CachingComponentAdapterFactory(new DefaultComponentAdapterFactory()), parent, lifecycleManager); 67 } 68 69 72 public CachingPicoContainer(ComponentAdapterFactory caf) { 73 this(caf, null); 74 } 75 76 77 80 public CachingPicoContainer() { 81 this((PicoContainer) null); 82 } 83 84 85 public MutablePicoContainer makeChildContainer() { 86 ImplementationHidingCachingPicoContainer pc = new ImplementationHidingCachingPicoContainer(caf, this, lifecycleManager); 87 getDelegate().addChildContainer(pc); 88 return pc; 89 } 90 91 } 92 | Popular Tags |