com.ibm.websphere.samples.scheduler.accountreportejb
Class SampleCalendarBean

java.lang.Object
  extended by com.ibm.websphere.samples.scheduler.accountreportejb.SampleCalendarBean
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean

public class SampleCalendarBean
extends java.lang.Object
implements javax.ejb.SessionBean

Implements a UserCalendar which will increment a given date by N seconds. UserCalendar session beans can implement the UserCalendarBean interface so that the method signatures are checked at compile time.

See Also:
Serialized Form

Constructor Summary
SampleCalendarBean()
           
 
Method Summary
 java.util.Date applyDelta(java.util.Date baseTime, java.lang.String calendar, java.lang.String delta)
          Increments the base time by a delta.
 void ejbActivate()
          A container invokes this method when the instance is taken out of the pool of available instances to become associated with a specific EJB object.
 void ejbCreate()
          A container invokes this method when it creates the EJB object
 void ejbPassivate()
          A container invokes this method on an instance before the instance becomes disassociated with a specific EJB object.
 void ejbRemove()
          A container invokes this method before it removes the EJB object that is currently associated with the instance.
 java.lang.String[] getCalendarNames()
          Retrieves an array of valid calendar names that this UserCalendar implementation supports.
 void setSessionContext(javax.ejb.SessionContext ctx)
          Set the associated session context.
 void validate(java.lang.String calendar, java.lang.String delta)
          Checks that a given delta String is suitable for use with this calendar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SampleCalendarBean

public SampleCalendarBean()
Method Detail

validate

public void validate(java.lang.String calendar,
                     java.lang.String delta)
              throws com.ibm.websphere.scheduler.UserCalendarSpecifierInvalid,
                     com.ibm.websphere.scheduler.UserCalendarPeriodInvalid
Checks that a given delta String is suitable for use with this calendar.

Parameters:
calendar - The calendar to check
delta - The delta to be checked
Throws:
com.ibm.websphere.scheduler.UserCalendarSpecifierInvalid - if the calendar parameter is not "seconds"
com.ibm.websphere.scheduler.UserCalendarPeriodInvalid - if the delta is not suitable for use with this calendar

applyDelta

public java.util.Date applyDelta(java.util.Date baseTime,
                                 java.lang.String calendar,
                                 java.lang.String delta)
                          throws com.ibm.websphere.scheduler.UserCalendarSpecifierInvalid,
                                 com.ibm.websphere.scheduler.UserCalendarPeriodInvalid
Increments the base time by a delta. The only supported

Parameters:
baseTime - The base time to which the increment will be added
calendar - Used by this calendar bean to specify the unit to be scaled. The only accepted value at this time is "seconds"
delta - A scalar which determines how much to add onto the base time. The unit to be scaled is determined by the calendar parameter.
Returns:
The new date which is the baseTime + delta
Throws:
com.ibm.websphere.scheduler.UserCalendarSpecifierInvalid - if the calendar parameter is not "seconds"
com.ibm.websphere.scheduler.UserCalendarPeriodInvalid - if the delta is not suitable for use with this calendar

getCalendarNames

public java.lang.String[] getCalendarNames()
Retrieves an array of valid calendar names that this UserCalendar implementation supports.

Returns:
the array of calendar names.

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
A container invokes this method when it creates the EJB object

Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
javax.ejb.CreateException

ejbActivate

public void ejbActivate()
A container invokes this method when the instance is taken out of the pool of available instances to become associated with a specific EJB object.

Specified by:
ejbActivate in interface javax.ejb.SessionBean
Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.

ejbPassivate

public void ejbPassivate()
A container invokes this method on an instance before the instance becomes disassociated with a specific EJB object.

Specified by:
ejbPassivate in interface javax.ejb.SessionBean
Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.

ejbRemove

public void ejbRemove()
A container invokes this method before it removes the EJB object that is currently associated with the instance.

Specified by:
ejbRemove in interface javax.ejb.SessionBean
Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.

setSessionContext

public void setSessionContext(javax.ejb.SessionContext ctx)
Set the associated session context.

Specified by:
setSessionContext in interface javax.ejb.SessionBean
Parameters:
ctx - A SessionContext interface for the instance. The instance should store the reference to the context in an instance variable.
Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.