KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > example > cmp > transaction > CourseBean


1 package example.cmp.transaction;
2
3 import java.io.Serializable;
4 import java.util.Enumeration;
5
6 import javax.ejb.*;
7 import javax.naming.InitialContext;
8 import javax.naming.NamingException;
9 import javax.sql.DataSource;
10
11 import com.caucho.ejb.AbstractEntityBean;
12
13 import java.util.Collection;
14
15 /**
16  * Implementation class for the Course bean.
17  */

18 public abstract class CourseBean extends AbstractEntityBean {
19
20
21   /**
22    * Returns the ID of this course (CMP field). This is also the primary key.
23    */

24   public abstract int getId();
25
26   /**
27    * Returns the name of this Course (CMP field).
28    */

29   public abstract String getName();
30
31   /**
32    * SSets the name of this Course (CMP field).
33    */

34   public abstract void setName(String val);
35
36   /**
37    * Sets the maximum amount of students allowed to be enrolled in this course
38    * (CMP field).
39    */

40   public abstract void setMaxStudentAmount(int amount);
41
42   /**
43    * returns the maximum amount of students allowed to be enrolled in this
44    * course (CMP field).
45    */

46   public abstract int getMaxStudentAmount();
47
48   /**
49    * Returns a <code>Collection</code> of all Student who are currently
50    * enrolled in this Course (CMR field).
51    */

52   abstract public Collection getStudentList();
53
54   /**
55    * Returns true if the course is full and no more students can enroll in it.
56    */

57   public boolean isFull()
58   {
59     int studentCount = getStudentList().size();
60     if (studentCount == getMaxStudentAmount())
61       return true;
62     return false;
63   }
64 }
65
Popular Tags