001: package team;
002:
003: import java.util.Collection;
004: import javax.ejb.*;
005: import util.Debug;
006:
007: /**
008: * This is the bean class for the LeagueBean enterprise bean.
009: * Created Mar 23, 2005 1:48:50 PM
010: * @author honza
011: */
012: public abstract class LeagueBean implements EntityBean,
013: LeagueLocalBusiness {
014: private EntityContext context;
015:
016: // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click on the + sign on the left to edit the code.">
017: // TODO Consider creating Transfer Object to encapsulate data
018: // TODO Review finder methods
019: /**
020: * @see EntityBean#setEntityContext(EntityContext)
021: */
022: public void setEntityContext(EntityContext aContext) {
023: context = aContext;
024: }
025:
026: /**
027: * @see EntityBean#ejbActivate()
028: */
029: public void ejbActivate() {
030:
031: }
032:
033: /**
034: * @see EntityBean#ejbPassivate()
035: */
036: public void ejbPassivate() {
037:
038: }
039:
040: /**
041: * @see EntityBean#ejbRemove()
042: */
043: public void ejbRemove() {
044:
045: }
046:
047: /**
048: * @see EntityBean#unsetEntityContext()
049: */
050: public void unsetEntityContext() {
051: context = null;
052: }
053:
054: /**
055: * @see EntityBean#ejbLoad()
056: */
057: public void ejbLoad() {
058:
059: }
060:
061: /**
062: * @see EntityBean#ejbStore()
063: */
064: public void ejbStore() {
065:
066: }
067:
068: // </editor-fold>
069:
070: // <editor-fold desc="CMP fields and relationships.">
071:
072: public abstract String getLeagueId();
073:
074: public abstract void setLeagueId(String id);
075:
076: public abstract String getName();
077:
078: public abstract void setName(String name);
079:
080: public abstract String getSport();
081:
082: public abstract void setSport(String sport);
083:
084: // </editor-fold>
085:
086: public String ejbCreate(String leagueId, String name, String sport)
087: throws CreateException {
088: if (leagueId == null) {
089: throw new CreateException(
090: "The field \"id\" must not be null");
091: }
092:
093: // TODO add additional validation code, throw CreateException if data is not valid
094: setLeagueId(leagueId);
095: setName(name);
096: setSport(sport);
097:
098: return null;
099: }
100:
101: public void ejbPostCreate(String leagueId, String name, String sport) {
102: // TODO populate relationships here if appropriate
103:
104: }
105:
106: public abstract Collection getTeams();
107:
108: public abstract void setTeams(Collection teams);
109:
110: // Business methods
111: public void addTeam(TeamLocal team) {
112: Debug.print("TeamBean addTeam");
113:
114: try {
115: Collection teams = getTeams();
116:
117: teams.add(team);
118: } catch (Exception ex) {
119: throw new EJBException(ex.getMessage());
120: }
121: }
122:
123: public void dropTeam(TeamLocal team) {
124: Debug.print("TeamBean dropTeam");
125:
126: try {
127: Collection teams = getTeams();
128:
129: teams.remove(team);
130: } catch (Exception ex) {
131: throw new EJBException(ex.getMessage());
132: }
133: }
134:
135: }
|