KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > impl > ElementsProxyMap


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 JavaDoc;
18 import java.util.Map JavaDoc;
19 import java.util.Set JavaDoc;
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 JavaDoc implements RegistryShutdownListener
34 {
35     private Map JavaDoc _inner;
36
37     private boolean _shutdown;
38
39     public void registryDidShutdown()
40     {
41         _shutdown = true;
42         _inner = null;
43     }
44
45     private void checkShutdown()
46     {
47         if (_shutdown)
48             throw HiveMind.createRegistryShutdownException();
49     }
50
51     public Set JavaDoc entrySet()
52     {
53         checkShutdown();
54
55         return _inner.entrySet();
56     }
57
58     public String JavaDoc toString()
59     {
60         return _inner.toString();
61     }
62
63     public boolean equals(Object JavaDoc o)
64     {
65         return _inner.equals(o);
66     }
67
68     public int hashCode()
69     {
70         return _inner.hashCode();
71     }
72
73     public void setInner(Map JavaDoc map)
74     {
75         _inner = map;
76     }
77
78 }
Popular Tags