KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > team > PlayerBean


1 package team;
2
3 import java.util.Collection JavaDoc;
4 import javax.ejb.*;
5
6 /**
7  * This is the bean class for the PlayerBean enterprise bean.
8  * Created Mar 23, 2005 1:48:50 PM
9  * @author honza
10  */

11 public abstract class PlayerBean implements EntityBean, PlayerLocalBusiness {
12     private EntityContext context;
13     
14     // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click on the + sign on the left to edit the code.">
15
// TODO Consider creating Transfer Object to encapsulate data
16
// TODO Review finder methods
17
/**
18      * @see EntityBean#setEntityContext(EntityContext)
19      */

20     public void setEntityContext(EntityContext aContext) {
21         context = aContext;
22     }
23     
24     /**
25      * @see EntityBean#ejbActivate()
26      */

27     public void ejbActivate() {
28         
29     }
30     
31     /**
32      * @see EntityBean#ejbPassivate()
33      */

34     public void ejbPassivate() {
35         
36     }
37     
38     /**
39      * @see EntityBean#ejbRemove()
40      */

41     public void ejbRemove() {
42         
43     }
44     
45     /**
46      * @see EntityBean#unsetEntityContext()
47      */

48     public void unsetEntityContext() {
49         context = null;
50     }
51     
52     /**
53      * @see EntityBean#ejbLoad()
54      */

55     public void ejbLoad() {
56         
57     }
58     
59     /**
60      * @see EntityBean#ejbStore()
61      */

62     public void ejbStore() {
63         
64     }
65     // </editor-fold>
66

67     // <editor-fold desc="CMP fields and relationships.">
68

69     public abstract String JavaDoc getPlayerId();
70     public abstract void setPlayerId(String JavaDoc id);
71     
72     public abstract String JavaDoc getName();
73     public abstract void setName(String JavaDoc name);
74     
75     public abstract String JavaDoc getPosition();
76     public abstract void setPosition(String JavaDoc position);
77     
78     public abstract Double JavaDoc getSalary();
79     public abstract void setSalary(Double JavaDoc salary);
80     
81     // </editor-fold>
82

83     public String JavaDoc ejbCreate(String JavaDoc playerId, String JavaDoc name, String JavaDoc position, Double JavaDoc salary) throws CreateException {
84         if (playerId == null) {
85             throw new CreateException("The field \"id\" must not be null");
86         }
87         
88         // TODO add additional validation code, throw CreateException if data is not valid
89
setPlayerId(playerId);
90         setName(name);
91         setPosition(position);
92         setSalary(salary);
93         
94         return null;
95     }
96     
97     public void ejbPostCreate(String JavaDoc playerId, String JavaDoc name, String JavaDoc position, Double JavaDoc salary) {
98         // TODO populate relationships here if appropriate
99

100     }
101  // Business methods
102
public Collection JavaDoc getLeagues() throws FinderException {
103         PlayerLocal player = (PlayerLocal) context.getEJBLocalObject();
104
105         return ejbSelectLeagues(player);
106     }
107
108     public Collection JavaDoc getSports() throws FinderException {
109         PlayerLocal player = (PlayerLocal) context.getEJBLocalObject();
110
111         return ejbSelectSports(player);
112     }
113     public abstract Collection JavaDoc getTeams();
114
115     public abstract void setTeams(Collection JavaDoc teams);
116     
117     public abstract Collection JavaDoc ejbSelectLeagues(PlayerLocal p0) throws FinderException;
118
119     public abstract Collection JavaDoc ejbSelectSports(PlayerLocal p0) throws FinderException;
120 }
121
Popular Tags