1 package org.sourceforge.jemm.sample.demo1.model;
2
3 import org.sourceforge.jemm.lifecycle.ConstructorLifecycle;
4 import org.sourceforge.jemm.lifecycle.ShadowUserObject;
5 import org.sourceforge.jemm.util.JEMMObject;
6
7 public class Account implements JEMMObject {
8
9
10 protected ShadowUserObject jemmOIF;
11
12 double balance;
13
14
15
16
17
18
19 public Account() {
20 ConstructorLifecycle.preConstructor(Account.class.getName());
21 ConstructorLifecycle.beginConstructor(this);
22 try {
23 this.balance = 0;
24 ConstructorLifecycle.endConstructor(this);
25 } catch(Throwable t) {
26 ConstructorLifecycle.failedConstructor(this);
27
28 throw new RuntimeException(t);
29 }
30 }
31
32
33
34
35
36
37 public Account(ShadowUserObject jemmOIF) {
38 this.jemmOIF = jemmOIF;
39 }
40
41
42
43
44
45
46 public Account(double initialBalance) {
47 ConstructorLifecycle.beginConstructor(this);
48 try {
49 this.balance = initialBalance;
50 ConstructorLifecycle.endConstructor(this);
51 } catch(Throwable t) {
52 ConstructorLifecycle.failedConstructor(this);
53
54 throw new RuntimeException(t);
55 }
56 }
57
58
59
60
61
62
63
64
65 public double getBalance() {
66 jemmOIF.entityEntered("org.sourceforge.jemm.sample.demo1.model.Account#getBalance ()D");
67 jemmOIF.beginLock();
68 try {
69 return balance;
70 } finally {
71 jemmOIF.endLock();
72 jemmOIF.entityExited("org.sourceforge.jemm.sample.demo1.model.Account#getBalance ()D");
73 }
74 }
75
76
77
78
79
80
81 public void deposit(double amount) {
82 jemmOIF.entityEntered("org.sourceforge.jemm.sample.demo1.model.Account#deposit (D)V");
83 jemmOIF.beginLock();
84 try {
85 balance += amount;
86 } finally {
87 jemmOIF.endLock();
88 jemmOIF.entityExited("org.sourceforge.jemm.sample.demo1.model.Account#deposit (D)V");
89 }
90 }
91 }