01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tctest;
05:
06: import EDU.oswego.cs.dl.util.concurrent.CyclicBarrier;
07:
08: import com.tc.object.config.ConfigVisitor;
09: import com.tc.object.config.DSOClientConfigHelper;
10: import com.tc.object.config.TransparencyClassSpec;
11: import com.tc.object.config.spec.CyclicBarrierSpec;
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.HashSet;
17: import java.util.Set;
18:
19: public class LiteralAutoLockTestApp extends AbstractTransparentApp {
20: private Set nodes = new HashSet();
21: private CyclicBarrier barrier = new CyclicBarrier(2);
22:
23: public LiteralAutoLockTestApp(String appId, ApplicationConfig cfg,
24: ListenerProvider listenerProvider) {
25: super (appId, cfg, listenerProvider);
26: }
27:
28: public void run() {
29: int size = 0;
30: synchronized ("Steve") {
31: nodes.add(new Object());
32: size = nodes.size();
33: }
34: try {
35: System.out.println("barrier:" + size);
36: barrier.barrier();
37: System.out.println("barrier out:" + size);
38: } catch (InterruptedException ie) {
39: notifyError(ie);
40: }
41: }
42:
43: public static void visitL1DSOConfig(ConfigVisitor visitor,
44: DSOClientConfigHelper config) {
45: String testClass = LiteralAutoLockTestApp.class.getName();
46: TransparencyClassSpec spec = config.getOrCreateSpec(testClass);
47:
48: String methodExpression = "* " + testClass + "*.*(..)";
49: config.addWriteAutolock(methodExpression);
50: spec.addRoot("nodes", "nodes");
51: spec.addRoot("barrier", "barrier");
52: new CyclicBarrierSpec().visit(visitor, config);
53: }
54: }
|