001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tctest;
005:
006: import com.tc.object.TCObject;
007: import com.tc.object.bytecode.TransparentAccess;
008:
009: import java.util.Map;
010:
011: public class UnInstrumentedObject implements TransparentAccess {
012: private long longValue;
013: private boolean booleanValue;
014: private UnInstrumentedObject objectValue;
015: private UnInstrumentedObject objectValue1;
016: private UnInstrumentedObject objectValue2;
017: private Object object = new Object();
018: public Object lock = new Object();
019: private boolean protect = false;
020: private final Object protectLock = new Object();
021:
022: public UnInstrumentedObject(boolean sub) {
023: this .longValue = System.currentTimeMillis();
024: this .booleanValue = System.currentTimeMillis() % 2 == 0;
025: if (sub) {
026: this .objectValue = new UnInstrumentedObject(false);
027: this .objectValue1 = new UnInstrumentedObject(false);
028: this .objectValue2 = new UnInstrumentedObject(false);
029: }
030: }
031:
032: public void setValues() {
033: this .longValue = System.currentTimeMillis();
034: this .booleanValue = System.currentTimeMillis() % 2 == 0;
035:
036: this .objectValue = new UnInstrumentedObject(false);
037: this .objectValue1 = new UnInstrumentedObject(false);
038: this .objectValue2 = new UnInstrumentedObject(false);
039: }
040:
041: public void accessValues() {
042: if (object == null) {
043: System.out.println("blah");
044: }
045:
046: myMethod(longValue, booleanValue, objectValue, objectValue1,
047: objectValue2);
048: if (objectValue != null) {
049: synchronized (getLock()) {
050: objectValue.accessValues();
051: }
052: synchronized (getLock()) {
053: objectValue1.accessValues();
054: }
055: synchronized (getLock()) {
056: objectValue2.accessValues();
057: }
058: }
059: }
060:
061: // public void accessValues() {
062: // if (object == null) {
063: // System.out.println("blah");
064: // }
065: //
066: // myMethod(longValue, booleanValue, objectValue, objectValue1, objectValue2);
067: // if (objectValue != null) {
068: // makeProtected();
069: // objectValue.accessValues();
070: // makeUnProtected();
071: //
072: // makeProtected();
073: // objectValue1.accessValues();
074: // makeUnProtected();
075: //
076: // makeProtected();
077: // objectValue2.accessValues();
078: // makeUnProtected();
079: // }
080: // }
081:
082: public void makeUnProtected() {
083: protect = false;
084:
085: }
086:
087: public void makeProtected() {
088: protect = true;
089: synchronized (protectLock) {
090: protectLock.notify();
091: }
092: }
093:
094: public boolean isProtected() {
095: return this .protect;
096: }
097:
098: public Object getLock() {
099: return lock;
100: }
101:
102: private void myMethod(long longValue2, boolean booleanValue2,
103: UnInstrumentedObject o, UnInstrumentedObject o1,
104: UnInstrumentedObject o2) {
105: // doNothing
106: }
107:
108: public void __tc_getallfields(Map map) {
109: //
110: }
111:
112: public void __tc_setfield(String name, Object value) {
113: //
114: }
115:
116: public void __tc_managed(TCObject t) {
117: //
118: }
119:
120: public TCObject __tc_managed() {
121: return null;
122: }
123:
124: public Object __tc_getmanagedfield(String name) {
125: return null;
126:
127: }
128:
129: public void __tc_setmanagedfield(String name, Object value) {
130: //
131:
132: }
133: }
|