KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > example > cmp > create > CourseHome


1 package example.cmp.create;
2
3 import javax.ejb.*;
4
5 import java.util.Collection;
6
7 /**
8  * Home interface for the Course bean.
9  *
10  * The Home Interface enables you to create new entities and to obtain
11  * references to existing ones.
12  *
13  * <p>The idea is that you use the Home Interface to obtain references
14  * to whatever entities you're interested in. Each entity that you
15  * get from the Home Interface (using its create or finder methods)
16  * is then represented by its Remote Interface.
17  *
18  * <p>With this Remote Interface, you can obtain information about a particular
19  * course, but you cannot change it. The Remote Interface is your only
20  * point of access to an entity, and there are no setXXX methods in this
21  * example.
22  */

23 public interface CourseHome extends EJBLocalHome {
24   /**
25    * returns the <code>Course</code> that has <code>courseId</code>
26    * as its primary key.
27    * Every entity EJB needs to have a finder method that returns an entity
28    * based on the primary key.
29    *
30    * @param courseId id and name of the course that is to be retreived
31    */

32   Course findByPrimaryKey(String courseId)
33     throws FinderException;
34
35   /**
36    * returns a <code>Collection</code> of all courses.
37    */

38   Collection findAll()
39     throws FinderException;
40
41   /**
42    * create a new course entity-
43    * <p The home interface allows us to create new entities through
44    * one of its <code>create</code> methods. The container will implement
45    * the <code>create</code> methods for us, based on code that we write in
46    * our implementation class (CourseHome.java). For each <code>create</code>
47    * method in this home interface, there needs to be a corresponding
48    * <code>ejbCreate</code> method in CourseHome.java that has the same
49    * parameters and doesn't throw <code>CreateException</code>.
50    */

51   public Course create(String courseId, String instructor)
52     throws CreateException;
53 }
54
Popular Tags