KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > RootInRootClassTestApp


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

4 package com.tctest;
5
6 import com.tc.object.config.ConfigVisitor;
7 import com.tc.object.config.DSOClientConfigHelper;
8 import com.tc.simulator.app.ApplicationConfig;
9 import com.tc.simulator.listener.ListenerProvider;
10 import com.tctest.runner.AbstractTransparentApp;
11 import com.tctest.runner.TransparentAppConfig;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Iterator JavaDoc;
15 import java.util.Map JavaDoc;
16
17 /**
18  * TODO May 26, 2005: I, steve, am too lazy to write a single sentence describing what this class is for.
19  */

20 public class RootInRootClassTestApp extends AbstractTransparentApp {
21
22   private Map JavaDoc myInnerInMap;
23
24   public RootInRootClassTestApp() {
25     super("", new TransparentAppConfig(null, null, 0, 0, null), null);
26     Map JavaDoc m = new HashMap JavaDoc();
27     m.put(new Long JavaDoc(System.currentTimeMillis()), new TestObject());
28     myInnerInMap = m;
29
30     System.out.println("CALLED NO ARG CONST:");
31     new Error JavaDoc().printStackTrace();
32   }
33
34   public RootInRootClassTestApp(String JavaDoc appId, ApplicationConfig cfg, ListenerProvider listenerProvider) {
35     super(appId, cfg, listenerProvider);
36     Map JavaDoc m = new HashMap JavaDoc();
37     m.put(new Long JavaDoc(System.currentTimeMillis()), new TestObject());
38     myInnerInMap = m;
39   }
40
41   public int getMapSize() {
42     synchronized (myInnerInMap) {
43       return myInnerInMap.size();
44     }
45   }
46
47   public void run() {
48
49     try {
50       synchronized (myInnerInMap) {
51         myInnerInMap.put("test" + myInnerInMap.size(), new TestObject());
52         System.out.println("myInnerMap size:" + myInnerInMap.size());
53         for (Iterator JavaDoc i = myInnerInMap.values().iterator(); i.hasNext();) {
54           TestObject to = (TestObject) i.next();
55           to.doStuff();
56         }
57       }
58       Thread.sleep(1000);
59     } catch (Exception JavaDoc e) {
60       e.printStackTrace();
61     }
62   }
63
64   public class TestObject {
65
66     public void doStuff() {
67       System.out.println("myInner:" + getMapSize());
68     }
69     //blah
70
}
71
72   public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) {
73     String JavaDoc testClass = RootInRootClassTestApp.class.getName();
74     config.addIncludePattern(testClass, false);
75
76     String JavaDoc methodExpression = "* " + testClass + "*.*(..)";
77     config.addWriteAutolock(methodExpression);
78     config.getOrCreateSpec(testClass).addRoot("myInnerInMap", "myInnerInMap");
79
80     config.addIncludePattern(TestObject.class.getName());
81   }
82
83 }
84
Popular Tags