KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > UnInstrumentedObject


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.TCObject;
7 import com.tc.object.bytecode.TransparentAccess;
8
9 import java.util.Map JavaDoc;
10
11 public class UnInstrumentedObject implements TransparentAccess {
12   private long longValue;
13   private boolean booleanValue;
14   private UnInstrumentedObject objectValue;
15   private UnInstrumentedObject objectValue1;
16   private UnInstrumentedObject objectValue2;
17   private Object JavaDoc object = new Object JavaDoc();
18   public Object JavaDoc lock = new Object JavaDoc();
19   private boolean protect = false;
20   private final Object JavaDoc protectLock = new Object JavaDoc();
21
22   public UnInstrumentedObject(boolean sub) {
23     this.longValue = System.currentTimeMillis();
24     this.booleanValue = System.currentTimeMillis() % 2 == 0;
25     if (sub) {
26       this.objectValue = new UnInstrumentedObject(false);
27       this.objectValue1 = new UnInstrumentedObject(false);
28       this.objectValue2 = new UnInstrumentedObject(false);
29     }
30   }
31
32   public void setValues() {
33     this.longValue = System.currentTimeMillis();
34     this.booleanValue = System.currentTimeMillis() % 2 == 0;
35
36     this.objectValue = new UnInstrumentedObject(false);
37     this.objectValue1 = new UnInstrumentedObject(false);
38     this.objectValue2 = new UnInstrumentedObject(false);
39   }
40
41   public void accessValues() {
42     if (object == null) {
43       System.out.println("blah");
44     }
45
46     myMethod(longValue, booleanValue, objectValue, objectValue1, objectValue2);
47     if (objectValue != null) {
48       synchronized (getLock()) {
49         objectValue.accessValues();
50       }
51       synchronized (getLock()) {
52         objectValue1.accessValues();
53       }
54       synchronized (getLock()) {
55         objectValue2.accessValues();
56       }
57     }
58   }
59
60   // public void accessValues() {
61
// if (object == null) {
62
// System.out.println("blah");
63
// }
64
//
65
// myMethod(longValue, booleanValue, objectValue, objectValue1, objectValue2);
66
// if (objectValue != null) {
67
// makeProtected();
68
// objectValue.accessValues();
69
// makeUnProtected();
70
//
71
// makeProtected();
72
// objectValue1.accessValues();
73
// makeUnProtected();
74
//
75
// makeProtected();
76
// objectValue2.accessValues();
77
// makeUnProtected();
78
// }
79
// }
80

81   public void makeUnProtected() {
82     protect = false;
83
84   }
85
86   public void makeProtected() {
87     protect = true;
88     synchronized (protectLock) {
89       protectLock.notify();
90     }
91   }
92
93   public boolean isProtected() {
94     return this.protect;
95   }
96
97   public Object JavaDoc getLock() {
98     return lock;
99   }
100
101   private void myMethod(long longValue2, boolean booleanValue2, UnInstrumentedObject o, UnInstrumentedObject o1,
102                         UnInstrumentedObject o2) {
103     // doNothing
104
}
105
106   public void __tc_getallfields(Map JavaDoc map) {
107     //
108
}
109
110   public void __tc_setfield(String JavaDoc name, Object JavaDoc value) {
111     //
112
}
113
114   public void __tc_managed(TCObject t) {
115     //
116
}
117
118   public TCObject __tc_managed() {
119     return null;
120   }
121
122   public Object JavaDoc __tc_getmanagedfield(String JavaDoc name) {
123     return null;
124     
125   }
126
127   public void __tc_setmanagedfield(String JavaDoc name, Object JavaDoc value) {
128     //
129

130   }
131 }
132
Popular Tags