KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > bytecode > NonDistributableObjectRegistry


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

5 package com.tc.object.bytecode;
6
7 import com.tc.object.TraversedReference;
8 import com.tc.object.appevent.NonPortableEventContext;
9
10 import java.util.Collections JavaDoc;
11 import java.util.Set JavaDoc;
12
13 /**
14  * Registry for non-distributable objects Loaded from boot jar by native classloader, singleton across the VM.
15  */

16 public class NonDistributableObjectRegistry /* implements TraverseTest */{
17
18   {
19     // XXX: Most of the support for this class has been cleaned up. To wire this class back up,
20
// we need add back a way to let the DSO client use this a TraverseTest when walking the graph of
21
// newly shared objects. Additionally, you want the Set used internally to based on an IdentityWeakHashSet, not just
22
// a regular HashSet
23
if (true) throw new UnsupportedOperationException JavaDoc();
24   }
25
26   private static final NonDistributableObjectRegistry instance = new NonDistributableObjectRegistry();
27
28   private Set JavaDoc nonDistributables = null;
29   private boolean added = false;
30
31   public boolean isAdded() {
32     return added;
33   }
34
35   public void setAdded() {
36     added = true;
37   }
38
39   private NonDistributableObjectRegistry() {
40     nonDistributables = Collections.unmodifiableSet(Collections.EMPTY_SET);
41
42     // potential perfomance bottleneck
43
// nonDistributables = Collections.synchronizedSet(new IdentityWeakHashSet());
44
}
45
46   public static NonDistributableObjectRegistry getInstance() {
47     return instance;
48   }
49
50   public boolean shouldTraverse(Object JavaDoc obj) {
51     return obj != null && nonDistributables.contains(obj) == false;
52   }
53
54   public Set JavaDoc getNondistributables() {
55     return nonDistributables;
56   }
57
58   public void checkPortability(TraversedReference obj, Class JavaDoc referringClass, NonPortableEventContext context) {
59     // never fails
60
}
61
62 }
63
Popular Tags