43 * Thread this context is in use by.
44 * As this only works in one thread, we do not need to worry about thread-safety.
45 */
46 private Thread thread;
47
48 public SerialCallbackContext(Object obj, ObjectStreamClass desc) {
49 this.obj = obj;
50 this.desc = desc;
51 this.thread = Thread.currentThread();
52 }
53
54 public Object getObj() throws NotActiveException {
55 checkAndSetUsed();
56 return obj;
57 }
58
59 public ObjectStreamClass getDesc() {
60 return desc;
61 }
62
63 private void checkAndSetUsed() throws NotActiveException {
64 if (thread != Thread.currentThread()) {
65 throw new NotActiveException(
66 "not in readObject invocation or fields already read");
67 }
68 thread = null;
69 }
70
71 public void setUsed() {
72 thread = null;
73 }
74 }
|
43 * Thread this context is in use by.
44 * As this only works in one thread, we do not need to worry about thread-safety.
45 */
46 private Thread thread;
47
48 public SerialCallbackContext(Object obj, ObjectStreamClass desc) {
49 this.obj = obj;
50 this.desc = desc;
51 this.thread = Thread.currentThread();
52 }
53
54 public Object getObj() throws NotActiveException {
55 checkAndSetUsed();
56 return obj;
57 }
58
59 public ObjectStreamClass getDesc() {
60 return desc;
61 }
62
63 public void checkAndSetUsed() throws NotActiveException {
64 if (thread != Thread.currentThread()) {
65 throw new NotActiveException(
66 "not in readObject invocation or fields already read");
67 }
68 thread = null;
69 }
70
71 public void setUsed() {
72 thread = null;
73 }
74 }
|