1 package team; 2 3 import java.util.Collection ; 4 import javax.ejb.*; 5 import util.Debug; 6 7 12 public abstract class LeagueBean implements EntityBean, LeagueLocalBusiness { 13 private EntityContext context; 14 15 21 public void setEntityContext(EntityContext aContext) { 22 context = aContext; 23 } 24 25 28 public void ejbActivate() { 29 30 } 31 32 35 public void ejbPassivate() { 36 37 } 38 39 42 public void ejbRemove() { 43 44 } 45 46 49 public void unsetEntityContext() { 50 context = null; 51 } 52 53 56 public void ejbLoad() { 57 58 } 59 60 63 public void ejbStore() { 64 65 } 66 68 70 public abstract String getLeagueId(); 71 public abstract void setLeagueId(String id); 72 73 public abstract String getName(); 74 public abstract void setName(String name); 75 76 public abstract String getSport(); 77 public abstract void setSport(String sport); 78 79 81 public String ejbCreate(String leagueId, String name, String sport) throws CreateException { 82 if (leagueId == null) { 83 throw new CreateException("The field \"id\" must not be null"); 84 } 85 86 setLeagueId(leagueId); 88 setName(name); 89 setSport(sport); 90 91 return null; 92 } 93 94 public void ejbPostCreate(String leagueId, String name, String sport) { 95 97 } 98 99 public abstract Collection getTeams(); 100 101 public abstract void setTeams(Collection teams); 102 103 public void addTeam(TeamLocal team) { 105 Debug.print("TeamBean addTeam"); 106 107 try { 108 Collection teams = getTeams(); 109 110 teams.add(team); 111 } catch (Exception 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 teams = getTeams(); 121 122 teams.remove(team); 123 } catch (Exception ex) { 124 throw new EJBException(ex.getMessage()); 125 } 126 } 127 128 } 129 | Popular Tags |