1 10 package org.picocontainer.alternatives; 11 12 import org.picocontainer.ComponentAdapter; 13 import org.picocontainer.PicoContainer; 14 import org.picocontainer.PicoException; 15 import org.picocontainer.PicoVerificationException; 16 import org.picocontainer.PicoVisitor; 17 18 import java.io.Serializable ; 19 import java.util.Collection ; 20 import java.util.List ; 21 22 25 30 public class ImmutablePicoContainer implements PicoContainer, Serializable { 31 32 private PicoContainer delegate; 33 34 public ImmutablePicoContainer(PicoContainer delegate) { 35 if(delegate == null) throw new NullPointerException ("You must pass in a picoContainer instance"); 36 this.delegate = delegate; 37 } 38 39 public Object getComponentInstance(Object componentKey) { 40 return delegate.getComponentInstance(componentKey); 41 } 42 43 public Object getComponentInstanceOfType(Class componentType) { 44 return delegate.getComponentInstanceOfType(componentType); 45 } 46 47 public List getComponentInstances() { 48 return delegate.getComponentInstances(); 49 } 50 51 public synchronized PicoContainer getParent() { 52 return delegate.getParent(); 53 } 54 55 public ComponentAdapter getComponentAdapter(Object componentKey) { 56 return delegate.getComponentAdapter(componentKey); 57 } 58 59 public ComponentAdapter getComponentAdapterOfType(Class componentType) { 60 return delegate.getComponentAdapterOfType(componentType); 61 } 62 63 public Collection getComponentAdapters() { 64 return delegate.getComponentAdapters(); 65 } 66 67 public List getComponentAdaptersOfType(Class componentType) { 68 return delegate.getComponentAdaptersOfType(componentType); 69 } 70 71 74 public void verify() throws PicoVerificationException { 75 delegate.verify(); 76 } 77 78 public List getComponentInstancesOfType(Class type) throws PicoException { 79 return delegate.getComponentInstancesOfType(type); 80 } 81 82 public void accept(PicoVisitor visitor) { 83 delegate.accept(visitor); 84 } 85 86 public void start() { 87 throw new UnsupportedOperationException ("This container is immutable, start() is not allowed"); 89 } 90 91 public void stop() { 92 throw new UnsupportedOperationException ("This container is immutable, stop() is not allowed"); 94 } 95 96 public void dispose() { 97 throw new UnsupportedOperationException ("This container is immutable, dispose() is not allowed"); 99 } 100 } 101 | Popular Tags |