View Javadoc

1   /**
2    * 
3    */
4   package org.sourceforge.jemm.sample.demo1.model;
5   
6   import org.sourceforge.jemm.Entity;
7   import org.sourceforge.jemm.lifecycle.AttributeUse;
8   import org.sourceforge.jemm.lifecycle.ConstructorLifecycle;
9   import org.sourceforge.jemm.lifecycle.ShadowUserObject;
10  import org.sourceforge.jemm.lifecycle.Uses;
11  import org.sourceforge.jemm.util.JEMMObject;
12  
13  /**
14   * 
15   * @author Paul Keeble
16   * 
17   */
18  @Entity
19  public class Person implements JEMMObject{
20  	
21  	protected ShadowUserObject jemmOIF;
22  	
23  	protected String name;
24  	protected Account account;
25  
26  	/**
27  	 * Create a Person instance.
28  	 * 
29  	 * @param name The name of the person.
30  	 */
31  	public Person(String name) {
32  		ConstructorLifecycle.preConstructor(Person.class.getName());
33  		ConstructorLifecycle.beginConstructor(this);
34  		try {
35  			this.name = name;
36  			ConstructorLifecycle.endConstructor(this);
37  		}catch(Throwable t) {
38  			ConstructorLifecycle.failedConstructor(this);
39  			//would in the real program throw t not a RuntimeException
40  			throw new RuntimeException(t);
41  		}
42  	}
43  
44  	/**
45       * Generated by the compiler and used internally for creating an object.
46       * @param jemmOIF The shadow object this object uses to talk to the store.
47       */
48      public Person(ShadowUserObject jemmOIF) {
49          this.jemmOIF = jemmOIF;
50      }
51  
52  	
53  	/**
54  	 * Return the name of the account holder.
55  	 * 
56  	 * @return The account holders name.
57  	 */
58  	public String getName() {
59  		jemmOIF.entityEntered("org.sourceforge.jemm.sample.demo1.model.Person#"
60  				+ "getName ()Ljava/lang/String;");
61  		try {
62  			return name;
63  		} finally {
64  			jemmOIF.entityExited("org.sourceforge.jemm.sample.demo1.model.Person#"
65  					+ "getName ()Ljava/lang/String;");
66  		}
67  	}
68  
69  	@Uses(@AttributeUse(clazz = "org.sourceforge.jemm.sample.demo1.model.Person", name = "account"))
70  	public void setAccount(Account account) {
71  		jemmOIF.entityEntered("org.sourceforge.jemm.sample.demo1.model.Person#"
72  				+ "setAccount (Lorg/sourceforge/jemm/sample/demo1/model/Account;)V");
73  		try {
74  			this.account = account;
75  		} finally {
76  			jemmOIF.entityExited("org.sourceforge.jemm.sample.demo1.model.Person#"
77  					+ "setAccount (Lorg/sourceforge/jemm/sample/demo1/model/Account;)V");
78  		}
79  	}
80  
81  	/**
82  	 * Return the account referred to by the given index.
83  	 * 
84  	 * @param index The index of the target account.
85  	 * @return The account at the given index.
86  	 */
87  	@Uses(@AttributeUse(clazz = "org.sourceforge.jemm.sample.demo1.model.Person", name = "account"))
88  	public Account getAccount() {
89  		jemmOIF.entityEntered("org.sourceforge.jemm.sample.demo1.model.Person#"
90  				+ "getAccount ()Lorg/sourceforge/jemm/sample/demo1/model/Account;");
91  		try {
92  			return account;
93  		} finally {
94  			jemmOIF.entityExited("org.sourceforge.jemm.sample.demo1.model.Person#"
95  					+ "getAccount ()Lorg/sourceforge/jemm/sample/demo1/model/Account;");
96  		}
97  	}
98  }