|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
example.cmp.create.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 |
public CourseBean()
Method Detail |
public java.lang.String ejbCreate(java.lang.String courseId, java.lang.String instructor) throws javax.ejb.CreateException
ejbCreate
methods implement the create
methods
declared in the Home Interface. This is like a bean "constructor" where
entity properties are initialized.
courseId
- the name of the course to be createdname
- of the instructor who will teach the new coursepublic void ejbPostCreate(java.lang.String courseId, java.lang.String instructor)
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.
public abstract java.lang.String getCourseId()
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.
public abstract void setCourseId(java.lang.String val)
CMP accessor and mutator methods are left for Resin-CMP to implement.
val
- new idpublic abstract java.lang.String getInstructor()
CMP accessor and mutator methods are left for Resin-CMP to implement.
public abstract void setInstructor(java.lang.String val)
CMP accessor and mutator methods are left for Resin-CMP to implement.
val
- new instructor
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |