1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
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 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| public class ImmutablePicoContainer implements PicoContainer, Serializable { |
31 |
| |
32 |
| private PicoContainer delegate; |
33 |
| |
34 |
210
| public ImmutablePicoContainer(PicoContainer delegate) {
|
35 |
2
| if(delegate == null) throw new NullPointerException("You must pass in a picoContainer instance");
|
36 |
208
| this.delegate = delegate;
|
37 |
| } |
38 |
| |
39 |
114
| public Object getComponentInstance(Object componentKey) {
|
40 |
114
| return delegate.getComponentInstance(componentKey);
|
41 |
| } |
42 |
| |
43 |
2
| public Object getComponentInstanceOfType(Class componentType) {
|
44 |
2
| return delegate.getComponentInstanceOfType(componentType);
|
45 |
| } |
46 |
| |
47 |
6
| public List getComponentInstances() {
|
48 |
6
| return delegate.getComponentInstances();
|
49 |
| } |
50 |
| |
51 |
34
| public synchronized PicoContainer getParent() {
|
52 |
34
| return delegate.getParent();
|
53 |
| } |
54 |
| |
55 |
322
| public ComponentAdapter getComponentAdapter(Object componentKey) {
|
56 |
322
| return delegate.getComponentAdapter(componentKey);
|
57 |
| } |
58 |
| |
59 |
70
| public ComponentAdapter getComponentAdapterOfType(Class componentType) {
|
60 |
70
| return delegate.getComponentAdapterOfType(componentType);
|
61 |
| } |
62 |
| |
63 |
28
| public Collection getComponentAdapters() {
|
64 |
28
| return delegate.getComponentAdapters();
|
65 |
| } |
66 |
| |
67 |
28
| public List getComponentAdaptersOfType(Class componentType) {
|
68 |
28
| return delegate.getComponentAdaptersOfType(componentType);
|
69 |
| } |
70 |
| |
71 |
| |
72 |
| |
73 |
| |
74 |
0
| public void verify() throws PicoVerificationException {
|
75 |
0
| delegate.verify();
|
76 |
| } |
77 |
| |
78 |
2
| public List getComponentInstancesOfType(Class type) throws PicoException {
|
79 |
2
| return delegate.getComponentInstancesOfType(type);
|
80 |
| } |
81 |
| |
82 |
4
| public void accept(PicoVisitor visitor) {
|
83 |
4
| delegate.accept(visitor);
|
84 |
| } |
85 |
| |
86 |
2
| public void start() {
|
87 |
| |
88 |
2
| throw new UnsupportedOperationException("This container is immutable, start() is not allowed");
|
89 |
| } |
90 |
| |
91 |
2
| public void stop() {
|
92 |
| |
93 |
2
| throw new UnsupportedOperationException("This container is immutable, stop() is not allowed");
|
94 |
| } |
95 |
| |
96 |
4
| public void dispose() {
|
97 |
| |
98 |
4
| throw new UnsupportedOperationException("This container is immutable, dispose() is not allowed");
|
99 |
| } |
100 |
| } |