Book Image

EJB 3.1 Cookbook

By : Richard M. Reese
Book Image

EJB 3.1 Cookbook

By: Richard M. Reese

Overview of this book

<p>Enterprise Java Beans enable rapid and simplified development of secure and portable applications based on Java technology.Creating and using EJBs can be challenging and rewarding. Among the challenges are learning the EJB technology itself, learning how to use the development environment you have chosen for EJB development, and the testing of the EJBs.<br /><br />This EJB 3.1 Cookbook addresses all these challenges and covers new 3.1 features, along with explanations of useful retained features from earlier versions. It brings the reader quickly up to speed on how to use EJB 3.1 techniques through the use of step-by-step examples without the need to use multiple incompatible resources. The coverage is concise and to the point, and is organized to allow you to quickly find and learn those features of interest to you.<br /><br />The book starts with coverage of EJB clients. The reader can choose the chapters and recipes which best address his or her specific needs. The newer EJB technologies presented include singleton beans which support application wide needs and interceptors to permit processing before and after a target method is invoked. Asynchronous invocation of methods and enhancements to the timer service are also covered. <br /><br />The EJB 3.1 CookBook is a very straightforward and rewarding source of techniques supporting Java EE applications.</p>
Table of Contents (19 chapters)
EJB 3.1 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Understanding calendar-based scheduling


Calendar-based scheduling is used with the @Schedule annotation and with the ScheduleExpression class. It provides an alternative approach for specifying the time when a callback should be made. The calendar-based timer expressions are similar to those used by the UNIX Cron facility.

Using a calendar expression we can express one of several types of events:

  • A single event in time

  • A repeating set of times

  • A time interval

This approach provides a more powerful technique for expressing a point in time.

Getting ready

A calendar expression can be expressed using the @Schedule annotation or using a ScheduleExpression object. These two approaches are closely related. In fact, the Timer class has an isCalendarTimer and a getSchedule method. If the timer was created using calendar scheduling, then the getSchedule method returns a ScheduleExpression object representing the schedule. These methods are illustrated in the Using the timer interface recipe.

The @Schedule...