1 package example.cmp.find; 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 /** 14 * Implementation class for the Course bean. 15 * 16 * <p>Its methods will be called only by the 17 * EJB container, and not ever by any client programs that we write. 18 * Instead, we call methods in the Remote Interface which will prompt the 19 * container to access methods in this class on our behalf. The container 20 * will also call the various housekeeping methods described below when it 21 * sees fit. 22 * 23 * <p> This CMP bean uses the following schema: 24 * 25 * <code><pre> 26 * DROP TABLE find_courses; 27 * CREATE TABLE find_courses ( 28 * course_id VARCHAR(250) NOT NULL, 29 * instructor VARCHAR(250), 30 * 31 * PRIMARY KEY(course_id) 32 * ); 33 * 34 * INSERT INTO find_courses VALUES('Potions', 'Severus Snape'); 35 * INSERT INTO find_courses VALUES('Transfiguration', 'Minerva McGonagall'); 36 * INSERT INTO find_courses VALUES('Defense Against the Dark Arts', 'Remus Lupin'); 37 * </pre></code> 38 * The implementation class for the Course bean. Its methods will be 39 * called only by the EJB container, and not by the client programs. 40 * The client calls methods in the local interface (Course) which will 41 * use the Resin-CMP-generated stub to access methods in this class 42 * on our behalf. 43 */ 44 public abstract class CourseBean extends AbstractEntityBean { 45 46 /** 47 * Returns the id (and name) of this course (CMP field). 48 * 49 * <p>Each cmp-field described in the deployment descriptor needs to 50 * be matched in the implementation class by abstract setXXX and 51 * getXXX methods. The container will take care of implementing them. 52 * 53 * <p>Unless you make these methods available in the Local Interface, 54 * you will never be able to access them from an EJB client such as 55 * a servlet. 56 * 57 * <p>Resin-CMP will implement the getCourseId method. 58 * 59 * @return the course id 60 */ 61 public abstract String getCourseId(); 62 63 /** 64 * Sets the id (and name) of this course (CMP field). Because the 65 * course id is the bean's primary key, clients may not call it. 66 * setCourseId may only be called in the ejbCreate method. 67 * 68 * <p>Resin-CMP will implement the setCourseId methods. 69 * 70 * @param courseId the new course id 71 * 72 * @exception EJBException if the database call or the transaction fails. 73 */ 74 public abstract void setCourseId(String courseId); 75 76 /** 77 * returns the name of the instructor who is teaching this 78 * course (CMP field). 79 * 80 * <p>Resin-CMP will implement the getCourseId method. 81 * 82 * @return the name of the course's instructor. 83 * 84 * @exception EJBException if the database call or the transaction fails. 85 */ 86 public abstract String getInstructor(); 87 88 /** 89 * Sets the name of the instructor who is teaching this course (CMP field). 90 * 91 * <p>Resin-CMP will implement the getCourseId method. 92 * 93 * @param instructor the name of the new course instructor. 94 * 95 * @exception EJBException if the database call or the transaction fails. 96 */ 97 public abstract void setInstructor(String instructor); 98 } 99