~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to usersguide/tutorials/j2ee-tut/examples/ejb/cmproster/Roster/src/java/team/PlayerBean.java

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package team;
 
2
 
 
3
import java.util.Collection;
 
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 getPlayerId();
 
70
    public abstract void setPlayerId(String id);
 
71
    
 
72
    public abstract String getName();
 
73
    public abstract void setName(String name);
 
74
    
 
75
    public abstract String getPosition();
 
76
    public abstract void setPosition(String position);
 
77
    
 
78
    public abstract Double getSalary();
 
79
    public abstract void setSalary(Double salary);
 
80
    
 
81
    // </editor-fold>
 
82
    
 
83
    public String ejbCreate(String playerId, String name, String position, Double 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 playerId, String name, String position, Double salary) {
 
98
        // TODO populate relationships here if appropriate
 
99
        
 
100
    }
 
101
 // Business methods
 
102
    public Collection getLeagues() throws FinderException {
 
103
        PlayerLocal player = (PlayerLocal) context.getEJBLocalObject();
 
104
 
 
105
        return ejbSelectLeagues(player);
 
106
    }
 
107
 
 
108
    public Collection getSports() throws FinderException {
 
109
        PlayerLocal player = (PlayerLocal) context.getEJBLocalObject();
 
110
 
 
111
        return ejbSelectSports(player);
 
112
    }
 
113
    public abstract Collection getTeams();
 
114
 
 
115
    public abstract void setTeams(Collection teams);
 
116
    
 
117
    public abstract Collection ejbSelectLeagues(PlayerLocal p0) throws FinderException;
 
118
 
 
119
    public abstract Collection ejbSelectSports(PlayerLocal p0) throws FinderException;
 
120
}