|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ElementsProxyMap.java | 50% | 60% | 57.1% | 57.9% |
|
1 | // Copyright 2004, 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.hivemind.impl; | |
16 | ||
17 | import java.util.AbstractMap; | |
18 | import java.util.Map; | |
19 | import java.util.Set; | |
20 | ||
21 | import org.apache.hivemind.HiveMind; | |
22 | import org.apache.hivemind.events.RegistryShutdownListener; | |
23 | ||
24 | /** | |
25 | * The Map implementation visible to the client code. It defers to another inner implementation of | |
26 | * Map; initially this is a {@link org.apache.hivemind.impl.ElementsInnerProxyMap}, but the inner | |
27 | * proxy replaces itself with a real Map implementation containing the actual configuration | |
28 | * elements. | |
29 | * | |
30 | * @author Knut Wannheden | |
31 | * @since 1.1 | |
32 | */ | |
33 | public final class ElementsProxyMap extends AbstractMap implements RegistryShutdownListener | |
34 | { | |
35 | private Map _inner; | |
36 | ||
37 | private boolean _shutdown; | |
38 | ||
39 | 28 | public void registryDidShutdown() |
40 | { | |
41 | 28 | _shutdown = true; |
42 | 28 | _inner = null; |
43 | } | |
44 | ||
45 | 128 | private void checkShutdown() |
46 | { | |
47 | 128 | if (_shutdown) |
48 | 0 | throw HiveMind.createRegistryShutdownException(); |
49 | } | |
50 | ||
51 | 128 | public Set entrySet() |
52 | { | |
53 | 128 | checkShutdown(); |
54 | ||
55 | 128 | return _inner.entrySet(); |
56 | } | |
57 | ||
58 | 0 | public String toString() |
59 | { | |
60 | 0 | return _inner.toString(); |
61 | } | |
62 | ||
63 | 0 | public boolean equals(Object o) |
64 | { | |
65 | 0 | return _inner.equals(o); |
66 | } | |
67 | ||
68 | 0 | public int hashCode() |
69 | { | |
70 | 0 | return _inner.hashCode(); |
71 | } | |
72 | ||
73 | 247 | public void setInner(Map map) |
74 | { | |
75 | 247 | _inner = map; |
76 | } | |
77 | ||
78 | } |
|