001: package org.picocontainer.containers;
002:
003: import java.io.Serializable;
004: import java.util.Collection;
005: import java.util.List;
006: import java.lang.annotation.Annotation;
007:
008: import org.picocontainer.ComponentAdapter;
009: import org.picocontainer.NameBinding;
010: import org.picocontainer.PicoContainer;
011: import org.picocontainer.PicoException;
012: import org.picocontainer.PicoVisitor;
013:
014: /**
015: * abstract base class for immutable delegation to pico
016: *
017: * @author k.pribluda
018: *
019: */
020: public abstract class AbstractDelegatingPicoContainer implements
021: PicoContainer, Serializable {
022:
023: private PicoContainer delegate;
024:
025: public AbstractDelegatingPicoContainer(PicoContainer delegate) {
026: if (delegate == null) {
027: throw new NullPointerException(
028: "PicoContainer delegate must not be null");
029: }
030: this .delegate = delegate;
031: }
032:
033: public void accept(PicoVisitor visitor) {
034: delegate.accept(visitor);
035: }
036:
037: public boolean equals(Object obj) {
038: // required to make it pass on both jdk 1.3 and jdk 1.4. Btw, what about
039: // overriding hashCode()? (AH)
040: return delegate.equals(obj) || this == obj;
041: }
042:
043: public <T> T getComponent(Class<T> componentType) {
044: return componentType.cast(getComponent((Object) componentType));
045: }
046:
047: public <T> T getComponent(Class<T> componentType,
048: Class<? extends Annotation> binding) {
049: return delegate.getComponent(componentType, binding);
050: }
051:
052: public Object getComponent(Object componentKeyOrType) {
053: return delegate.getComponent(componentKeyOrType);
054: }
055:
056: public <T> ComponentAdapter<T> getComponentAdapter(
057: Class<T> componentType, NameBinding componentNameBinding) {
058: return delegate.getComponentAdapter(componentType,
059: componentNameBinding);
060: }
061:
062: public <T> ComponentAdapter<T> getComponentAdapter(
063: Class<T> componentType, Class<? extends Annotation> binding) {
064: return delegate.getComponentAdapter(componentType, binding);
065: }
066:
067: public ComponentAdapter<?> getComponentAdapter(Object componentKey) {
068: return delegate.getComponentAdapter(componentKey);
069: }
070:
071: public Collection<ComponentAdapter<?>> getComponentAdapters() {
072: return delegate.getComponentAdapters();
073: }
074:
075: public <T> List<ComponentAdapter<T>> getComponentAdapters(
076: Class<T> componentType) {
077: return delegate.getComponentAdapters(componentType);
078: }
079:
080: public <T> List<ComponentAdapter<T>> getComponentAdapters(
081: Class<T> componentType, Class<? extends Annotation> binding) {
082: return delegate.getComponentAdapters(componentType, binding);
083: }
084:
085: public List<Object> getComponents() {
086: return delegate.getComponents();
087: }
088:
089: public <T> List<T> getComponents(Class<T> type)
090: throws PicoException {
091: return delegate.getComponents(type);
092: }
093:
094: public PicoContainer getDelegate() {
095: return delegate;
096: }
097:
098: public PicoContainer getParent() {
099: return delegate.getParent();
100: }
101:
102: }
|