Example: Using default scheduler calendars

The SIMPLE and CRON calendars can be used from any J2EE application. This topic describes that process.

Example

Using default scheduler calendars involves looking-up the default UserCalendarHome Enterprise JavaBeans™ (EJB) home object, creating the UserCalendar bean and calling the applyDelta() method. For details on the applyDelta method as well as the syntax for the SIMPLE and CRON calendars, see the UserCalendar interface topic.

Example:

import java.util.Date;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import com.ibm.websphere.scheduler.UserCalendar;
import com.ibm.websphere.scheduler.UserCalendarHome;

// Create an initial context
InitialContext ctx = new InitialContext();

// Lookup and narrow the default UserCalendar home.
UserCalendarHome defaultCalHome=(UserCalendarHome)
	PortableRemoteObject.narrow(ctx.lookup(
      UserCalendarHome.DEFAULT_CALENDAR_JNDI_NAME), 
	   UserCalendarHome.class);

// Create the default UserCalendar instance.
UserCalendar defaultCal = defaultCalHome.create();

// Calculate a date using CRON based on the current
// date and time.  Return the next date that is 
// Saturday at 2AM
Date newDate = 
    defaultCal.applyDelta(new Date(), 
        "CRON", "0 0 2 ? * SAT");



Related concepts
Scheduler calendars
Scheduler daemon
Related tasks
Installing default scheduler calendars
Managing schedulers
Developing and scheduling tasks
Related reference
UserCalendar interface
Interoperating with schedulers
Reference topic    

Terms of Use | Feedback

Last updated: Oct 21, 2010 1:44:59 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=compass&product=was-express-dist&topic=tsch_usingcalendar
File name: tsch_usingcalendar.html