example.cmp.create
Class CourseBean

example.cmp.create.CourseBean

public abstract class CourseBean

Implementation class for the Course bean. The implementation class of the Course entity bean. Its methods will be called only by the EJB container, and not ever by any client programs that we write. Instead, we call methods in the Local Interface which will prompt the container to access methods in this class on our behalf.

AbstractEntityBean is a convenience superclass that provides a set of methods required by the spec.

This CMP entity bean use the following schema:

 DROP TABLE create_courses;
 CREATE TABLE create_courses (
   course_id VARCHAR(250) NOT NULL,
   instructor VARCHAR(250),

   PRIMARY KEY(course_id)
 );

 INSERT INTO create_courses VALUES('Potions', 'Severus Snape');
 INSERT INTO create_courses VALUES('Transfiguration', 'Minerva McGonagall');
 INSERT INTO create_courses VALUES('Defense Against the Dark Arts', 'Remus Lupin');
 


Constructor Summary
CourseBean()
           
 
Method Summary
 java.lang.String ejbCreate(java.lang.String courseId, java.lang.String instructor)
          Creates a new Course entity.
 void ejbPostCreate(java.lang.String courseId, java.lang.String instructor)
          required by ejbCreate(String, String)
abstract  java.lang.String getCourseId()
          returns the id of this course, which is also the name of the course (CMP field).
abstract  java.lang.String getInstructor()
          returns the name of the instructor who is teaching this course (CMP field).
abstract  void setCourseId(java.lang.String val)
          sets the id of this course (CMP field).
abstract  void setInstructor(java.lang.String val)
          sets the name of the instructor whi is teaching this course (CMP field).
 

Constructor Detail

CourseBean

public CourseBean()
Method Detail

ejbCreate

public java.lang.String ejbCreate(java.lang.String courseId,
                                  java.lang.String instructor)
                           throws javax.ejb.CreateException
Creates a new Course entity.

ejbCreate methods implement the create methods declared in the Home Interface. This is like a bean "constructor" where entity properties are initialized.

Parameters:
courseId - the name of the course to be created
name - of the instructor who will teach the new course

ejbPostCreate

public void ejbPostCreate(java.lang.String courseId,
                          java.lang.String instructor)
required by ejbCreate(String, String)

The container will call ejbPostCreate after the corresponding ejbCreate has completed and the entity has a new identity. The method is not used in this example.


getCourseId

public abstract java.lang.String getCourseId()
returns the id of this course, which is also the name of the course (CMP field).

CMP accessor and mutator methods are left for Resin-CMP to implement. Each cmp-field described in the deployment descriptor needs to be matched in the implementation class by abstract setXXX and getXXX methods. The container will take care of implementing them.

Note that unless you make these methods available in the Local Interface, you will never be able to access them from an EJB client such as a servlet.


setCourseId

public abstract void setCourseId(java.lang.String val)
sets the id of this course (CMP field).

CMP accessor and mutator methods are left for Resin-CMP to implement.

Parameters:
val - new id

getInstructor

public abstract java.lang.String getInstructor()
returns the name of the instructor who is teaching this course (CMP field).

CMP accessor and mutator methods are left for Resin-CMP to implement.


setInstructor

public abstract void setInstructor(java.lang.String val)
sets the name of the instructor whi is teaching this course (CMP field).

CMP accessor and mutator methods are left for Resin-CMP to implement.

Parameters:
val - new instructor