01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tctest;
06:
07: import EDU.oswego.cs.dl.util.concurrent.CyclicBarrier;
08:
09: import com.tc.object.config.ConfigVisitor;
10: import com.tc.object.config.DSOClientConfigHelper;
11: import com.tc.object.config.TransparencyClassSpec;
12: import com.tc.simulator.app.ApplicationConfig;
13: import com.tc.simulator.listener.ListenerProvider;
14: import com.tctest.runner.AbstractTransparentApp;
15:
16: import java.util.ArrayList;
17: import java.util.Collection;
18: import java.util.HashSet;
19: import java.util.Iterator;
20: import java.util.List;
21: import java.util.Set;
22:
23: public class HashSetSubclassTestApp extends AbstractTransparentApp {
24:
25: private final CyclicBarrier barrier;
26:
27: public HashSetSubclassTestApp(String appId, ApplicationConfig cfg,
28: ListenerProvider listenerProvider) {
29: super (appId, cfg, listenerProvider);
30: barrier = new CyclicBarrier(getParticipantCount());
31: }
32:
33: public void run() {
34: try {
35: int index = barrier.barrier();
36:
37: List hellos = new ArrayList();
38:
39: synchronized (hellos) {
40: Set abc = new HashSet();
41: abc.add("A");
42: abc.add("B");
43: abc.add("C");
44: hellos.add(abc);
45: Set myset = new MySet("xxx", abc);
46: }
47:
48: } catch (Throwable t) {
49: notifyError(t);
50: }
51: }
52:
53: public static void visitL1DSOConfig(ConfigVisitor visitor,
54: DSOClientConfigHelper config) {
55: TransparencyClassSpec spec = config
56: .getOrCreateSpec(CyclicBarrier.class.getName());
57: config.addWriteAutolock("* " + CyclicBarrier.class.getName()
58: + "*.*(..)");
59:
60: String testClass = HashSetSubclassTestApp.class.getName();
61: spec = config.getOrCreateSpec(testClass);
62: config.addIncludePattern(testClass + "$*");
63:
64: spec.addRoot("barrier", "barrier");
65: }
66:
67: class MySet extends HashSet {
68:
69: protected String something;
70:
71: public MySet(String something, Collection c) {
72: super (c.size());
73: Iterator iter = c.iterator();
74: while (iter.hasNext()) {
75: super.add(iter.next());
76: }
77: this.something = something;
78: }
79: }
80:
81: }
|