1 4 package com.tctest; 5 6 import com.tc.object.config.ConfigVisitor; 7 import com.tc.object.config.DSOClientConfigHelper; 8 import com.tc.object.config.TransparencyClassSpec; 9 import com.tc.simulator.app.ApplicationConfig; 10 import com.tc.simulator.listener.ListenerProvider; 11 import com.tc.util.Assert; 12 import com.tctest.runner.AbstractTransparentApp; 13 14 import java.util.HashMap ; 15 import java.util.Map ; 16 17 20 public class ShareableJavaLangObjectTestApp extends AbstractTransparentApp { 21 22 private final Map root = new HashMap (); 23 private final Object objectRoot = new Object (); 24 25 public ShareableJavaLangObjectTestApp(String appId, ApplicationConfig cfg, ListenerProvider listenerProvider) { 26 super(appId, cfg, listenerProvider); 27 28 if (getParticipantCount() < 2) { throw new RuntimeException ("must have at least two participants"); } 29 } 30 31 public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) { 32 String testClass = ShareableJavaLangObjectTestApp.class.getName(); 33 TransparencyClassSpec spec = config.getOrCreateSpec(testClass); 34 35 String methodExpression = "* " + testClass + "*.*(..)"; 36 config.addWriteAutolock(methodExpression); 37 spec.addRoot("root", "root"); 38 spec.addRoot("objectRoot", "objectRoot"); 39 40 config.addIncludePattern(ObjectHolder.class.getName()); 41 } 42 43 public void run() { 44 Object o = objectRoot; 45 Assert.assertNotNull(o); 46 47 final Object object; 48 49 synchronized (root) { 50 if (root.size() == 0) { 51 root.put("object", new Object ()); 52 } 53 object = root.get("object"); 54 } 55 56 synchronized (object) { 58 root.put(getApplicationId(), null); 59 } 60 61 synchronized (root) { 63 root.put("objectholder", new ObjectHolder()); 64 } 65 } 66 67 private static class ObjectHolder { 68 final Object heldObject = new Object (); 69 } 70 } 71
| Popular Tags
|