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

Handling a stream-based message


Sometimes it is desirable to send a stream of primitive values as a message. This recipe illustrates this process using the StreamMessage interface.

The advantages of using a stream of bytes are essentially the same as those for the BytesMessage: ease of read and write operations and a fixed size message. Data is written or read by storing the data in primitive format. In addition, information about the type of data written is also stored. This means that if an integer is written then only a corresponding integer read operation can be used against the data.

The StreamMessage interface differs from the BytesMessage in that data stored using StreamMessage interface incorporates information about the data type. This prevents mismatched read/write operations that can occur in BytesMessage message.

Getting ready

The essential structure of a servlet used to generate a message was introduced in the introduction. Here we will address the unique elements of creating and...