KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > team > LeagueBean


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

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

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

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

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

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

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

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

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

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

70     public abstract String JavaDoc getLeagueId();
71     public abstract void setLeagueId(String JavaDoc id);
72     
73     public abstract String JavaDoc getName();
74     public abstract void setName(String JavaDoc name);
75     
76     public abstract String JavaDoc getSport();
77     public abstract void setSport(String JavaDoc sport);
78     
79     // </editor-fold>
80

81     public String JavaDoc ejbCreate(String JavaDoc leagueId, String JavaDoc name, String JavaDoc sport) throws CreateException {
82         if (leagueId == null) {
83             throw new CreateException("The field \"id\" must not be null");
84         }
85         
86         // TODO add additional validation code, throw CreateException if data is not valid
87
setLeagueId(leagueId);
88         setName(name);
89         setSport(sport);
90         
91         return null;
92     }
93     
94     public void ejbPostCreate(String JavaDoc leagueId, String JavaDoc name, String JavaDoc sport) {
95         // TODO populate relationships here if appropriate
96

97     }
98
99     public abstract Collection JavaDoc getTeams();
100
101     public abstract void setTeams(Collection JavaDoc teams);
102     
103         // Business methods
104
public void addTeam(TeamLocal team) {
105         Debug.print("TeamBean addTeam");
106
107         try {
108             Collection JavaDoc teams = getTeams();
109
110             teams.add(team);
111         } catch (Exception JavaDoc ex) {
112             throw new EJBException(ex.getMessage());
113         }
114     }
115
116     public void dropTeam(TeamLocal team) {
117         Debug.print("TeamBean dropTeam");
118
119         try {
120             Collection JavaDoc teams = getTeams();
121
122             teams.remove(team);
123         } catch (Exception JavaDoc ex) {
124             throw new EJBException(ex.getMessage());
125         }
126     }
127     
128 }
129
Popular Tags