1 package team; 2 3 import javax.ejb.*; 4 import util.*; 5 import java.util.*; 6 7 12 public abstract class TeamBean implements EntityBean, TeamLocalBusiness { 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 getTeamId(); 71 public abstract void setTeamId(String id); 72 73 public abstract String getName(); 74 public abstract void setName(String name); 75 76 public abstract String getCity(); 77 public abstract void setCity(String city); 78 79 81 public String ejbCreate(String teamId, String name, String city) throws CreateException { 82 if (teamId == null) { 83 throw new CreateException("The field \"id\" must not be null"); 84 } 85 89 setTeamId(teamId); 91 setName(name); 92 setCity(city); 93 94 return null; 95 } 96 97 public void ejbPostCreate(String teamId, String name, String city) { 98 101 } 102 public ArrayList getCopyOfPlayers() { 104 Debug.print("TeamBean getCopyOfPlayers"); 105 106 ArrayList playerList = new ArrayList(); 107 Collection players = getPlayers(); 108 109 Iterator i = players.iterator(); 110 111 while (i.hasNext()) { 112 PlayerLocal player = (PlayerLocal) i.next(); 113 PlayerDetails details = 114 new PlayerDetails(player.getPlayerId(), player.getName(), player.getPosition(), 0.0); 115 116 playerList.add(details); 117 } 118 119 return playerList; 120 } 121 122 public void addPlayer(PlayerLocal player) { 123 Debug.print("TeamBean addPlayer"); 124 125 try { 126 Collection players = getPlayers(); 127 128 players.add(player); 129 } catch (Exception ex) { 130 throw new EJBException(ex.getMessage()); 131 } 132 } 133 134 public void dropPlayer(PlayerLocal player) { 135 Debug.print("TeamBean dropPlayer"); 136 137 try { 138 Collection players = getPlayers(); 139 140 players.remove(player); 141 } catch (Exception ex) { 142 throw new EJBException(ex.getMessage()); 143 } 144 } 145 146 public abstract Collection getPlayers(); 147 148 public abstract void setPlayers(Collection players); 149 150 public abstract LeagueLocal getLeague(); 151 152 public abstract void setLeague(LeagueLocal league); 153 154 155 156 157 158 } 159 | Popular Tags |