001 /*****************************************************************************
002 * Copyright (C) PicoContainer Organization. All rights reserved. *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file. *
007 * *
008 * Original code by the committers *
009 *****************************************************************************/
010 package org.picocontainer.alternatives;
011
012 import java.io.Serializable;
013 import java.util.Collection;
014 import java.util.List;
015
016 import org.picocontainer.ComponentAdapter;
017 import org.picocontainer.MutablePicoContainer;
018 import org.picocontainer.Parameter;
019 import org.picocontainer.PicoContainer;
020 import org.picocontainer.PicoException;
021 import org.picocontainer.PicoRegistrationException;
022 import org.picocontainer.PicoVerificationException;
023 import org.picocontainer.PicoVisitor;
024
025 /**
026 * @author Paul Hammant
027 * @version $Revision: 2230 $
028 */
029 public abstract class AbstractDelegatingMutablePicoContainer implements MutablePicoContainer, Serializable {
030
031 private MutablePicoContainer delegate;
032
033 public AbstractDelegatingMutablePicoContainer(MutablePicoContainer delegate) {
034 this.delegate = delegate;
035 }
036
037 protected MutablePicoContainer getDelegate() {
038 return delegate;
039 }
040
041 public ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation) throws PicoRegistrationException {
042 return delegate.registerComponentImplementation(componentKey, componentImplementation);
043 }
044
045 public ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation, Parameter[] parameters) throws PicoRegistrationException {
046 return delegate.registerComponentImplementation(componentKey, componentImplementation, parameters);
047 }
048
049
050 public ComponentAdapter registerComponentImplementation(Class componentImplementation) throws PicoRegistrationException {
051 return delegate.registerComponentImplementation(componentImplementation);
052 }
053
054 public ComponentAdapter registerComponentInstance(Object componentInstance) throws PicoRegistrationException {
055 return delegate.registerComponentInstance(componentInstance);
056 }
057
058 public ComponentAdapter registerComponentInstance(Object componentKey, Object componentInstance) throws PicoRegistrationException {
059 return delegate.registerComponentInstance(componentKey, componentInstance);
060 }
061
062 public ComponentAdapter registerComponent(ComponentAdapter componentAdapter) throws PicoRegistrationException {
063 return delegate.registerComponent(componentAdapter);
064 }
065
066 public ComponentAdapter unregisterComponent(Object componentKey) {
067 return delegate.unregisterComponent(componentKey);
068 }
069
070 public ComponentAdapter unregisterComponentByInstance(Object componentInstance) {
071 return delegate.unregisterComponentByInstance(componentInstance);
072 }
073
074 public Object getComponentInstance(Object componentKey) {
075 return delegate.getComponentInstance(componentKey);
076 }
077
078 public Object getComponentInstanceOfType(Class componentType) {
079 return delegate.getComponentInstanceOfType(componentType);
080 }
081
082 public List getComponentInstances() {
083 return delegate.getComponentInstances();
084 }
085
086 public PicoContainer getParent() {
087 return delegate.getParent();
088 }
089
090 public ComponentAdapter getComponentAdapter(Object componentKey) {
091 return delegate.getComponentAdapter(componentKey);
092 }
093
094 public ComponentAdapter getComponentAdapterOfType(Class componentType) {
095 return delegate.getComponentAdapterOfType(componentType);
096 }
097
098 public Collection getComponentAdapters() {
099 return delegate.getComponentAdapters();
100 }
101
102 public List getComponentAdaptersOfType(Class componentType) {
103 return delegate.getComponentAdaptersOfType(componentType);
104 }
105
106 /**
107 * @deprecated since 1.1 - Use new VerifyingVisitor().traverse(this)
108 */
109 public void verify() throws PicoVerificationException {
110 delegate.verify();
111 }
112
113 public void start() {
114 delegate.start();
115 }
116
117 public void stop() {
118 delegate.stop();
119 }
120
121 public void dispose() {
122 delegate.dispose();
123 }
124
125 public boolean addChildContainer(PicoContainer child) {
126 return delegate.addChildContainer(child);
127 }
128
129 public boolean removeChildContainer(PicoContainer child) {
130 return delegate.removeChildContainer(child);
131 }
132
133 public void accept(PicoVisitor visitor) {
134 delegate.accept(visitor);
135 }
136
137 public List getComponentInstancesOfType(Class type) throws PicoException {
138 return delegate.getComponentInstancesOfType(type);
139 }
140
141 public boolean equals(Object obj) {
142 // required to make it pass on both jdk 1.3 and jdk 1.4. Btw, what about overriding hashCode()? (AH)
143 final boolean result = delegate.equals(obj) || this == obj;
144 return result;
145 }
146
147 }