example.cmp.transaction
Class RegistrationSessionBean

example.cmp.transaction.RegistrationSessionBean
All Implemented Interfaces:
javax.ejb.SessionSynchronization

public class RegistrationSessionBean
implements javax.ejb.SessionSynchronization

Implementation Class for the RegistrationSession bean.


Field Summary
private  CourseHome courseHome
          Home Interface for the Course CMP bean.
private  boolean isComplete
          True when the registration has completed and mail has been sent.
private  boolean isCompleting
          True for the finalizing method.
private  java.util.Collection selectedCourses
          Currently selected Courses.
private  Student student
          The calling Principal.
private  StudentHome studentHome
          Home Interface for the Student CMP bean.
static int TRANSACTION_COMMITTED
           
static int TRANSACTION_ROLLEDBACK
           
 
Constructor Summary
RegistrationSessionBean()
          Standard Constructor.
 
Method Summary
 void addCourse(Course course)
          Adds a course to the set of selected courses for this session.
 void afterBegin()
          Called by Resin-CMP after a new transaction has begun -- required by the SessionSynchronization interface.
 void afterCompletion(boolean committed)
          Called by Resin-CMP when a transaction has completed -- required by the SessionSynchronization interface.
 void beforeCompletion()
          Called by Resin-CMP just before a transaction is committed -- required by the SessionSynchronization interface.
 void ejbCreate()
          Tries to resolve the calling .
 void finalizeRegistration()
          Executes a transaction that will commit the selected courses to the persistant store unless an error occurs.
 java.util.Collection getAvailableCourses()
          Returns a Collection of all Courses offered (including those that the student has already selected).
 java.util.Collection getEnrolledCourses()
          Returns a Collection of Courses that the now registering Student is currently enrolled in.
 java.util.Collection getSelectedCourses()
          Returns a Collection of all courses currently selected.
 java.lang.String getStudentName()
          Returns the name of the Student who is selecting Courses.
 boolean isComplete()
          Returns true if the registration is complete.
 void removeCourse(Course course)
          Deletes a course from the set of selected courses for this session.
 

Field Detail

courseHome

private CourseHome courseHome
Home Interface for the Course CMP bean.

studentHome

private StudentHome studentHome
Home Interface for the Student CMP bean.

student

private Student student
The calling Principal.

isCompleting

private boolean isCompleting
True for the finalizing method.

isComplete

private boolean isComplete
True when the registration has completed and mail has been sent.

selectedCourses

private java.util.Collection selectedCourses
Currently selected Courses. Note that these are in-memory only and will not be committed to the database until finalizeRegistration is called.

TRANSACTION_COMMITTED

public static final int TRANSACTION_COMMITTED

TRANSACTION_ROLLEDBACK

public static final int TRANSACTION_ROLLEDBACK
Constructor Detail

RegistrationSessionBean

public RegistrationSessionBean()
Standard Constructor.
Method Detail

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
Tries to resolve the calling .

afterBegin

public void afterBegin()
                throws javax.ejb.EJBException
Called by Resin-CMP after a new transaction has begun -- required by the SessionSynchronization interface.
Specified by:
afterBegin in interface javax.ejb.SessionSynchronization

beforeCompletion

public void beforeCompletion()
                      throws javax.ejb.EJBException
Called by Resin-CMP just before a transaction is committed -- required by the SessionSynchronization interface.

This call might update the database or do some validation. Because the transaction might still be rolled back, it should be possible to roll back any operatin in the before completion.

Specified by:
beforeCompletion in interface javax.ejb.SessionSynchronization

afterCompletion

public void afterCompletion(boolean committed)
                     throws javax.ejb.EJBException
Called by Resin-CMP when a transaction has completed -- required by the SessionSynchronization interface.

In order to keep the transaction Atomic, Consistent, Independent, and Durable, we do nothing in this method unless the transaction has been committed.

If the transaction was rolled back, we will treat it as if it never happened.

Specified by:
afterCompletion in interface javax.ejb.SessionSynchronization

getStudentName

public java.lang.String getStudentName()
Returns the name of the Student who is selecting Courses.

getEnrolledCourses

public java.util.Collection getEnrolledCourses()
Returns a Collection of Courses that the now registering Student is currently enrolled in.

addCourse

public void addCourse(Course course)
               throws javax.ejb.FinderException
Adds a course to the set of selected courses for this session. Note that this method does not commit data to the database.

removeCourse

public void removeCourse(Course course)
                  throws javax.ejb.FinderException
Deletes a course from the set of selected courses for this session.

getAvailableCourses

public java.util.Collection getAvailableCourses()
Returns a Collection of all Courses offered (including those that the student has already selected).

getSelectedCourses

public java.util.Collection getSelectedCourses()
Returns a Collection of all courses currently selected.

isComplete

public boolean isComplete()
Returns true if the registration is complete.

finalizeRegistration

public void finalizeRegistration()
                          throws RegistrationDeniedException
Executes a transaction that will commit the selected courses to the persistant store unless an error occurs.