ebook img

EJB cookbook PDF

353 Pages·2003·2.802 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview EJB cookbook

EJB Cookbook EJB Cookbook BENJAMIN G. SULLINS MARK B. WHIPPLE MANNING Greenwich (74° w. long.) For online information and ordering of this and other Manning books, visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact: Special Sales Department Manning Publications Co. 209 Bruce Park Avenue Fax: (203) 661-9018 Greenwich, CT 06830 email: [email protected] ©2003 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books they publish printed on acid-free paper, and we exert our best efforts to that end. . Manning Publications Co. Copyeditor: Liz Welch 209 Bruce Park Avenue Typesetter: Dottie Marsico Greenwich, CT 06830 Cover designer: Leslie Haimes ISBN 1930110944 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – VHG – 06 05 04 03 To Jenny, Elijah, and Samuel —Ben To my wonderful wife, Margie, and my son, Alexander —Mark contents preface xv acknowledgments xvii about this book xviii author online xxii about the cover illustration xxiii PART I APPETIZERS ....................................................... 1 1 Client code 3 1.1 Invoking a local EJB from another EJB 4 1.2 Invoking a remote EJB from another EJB 6 1.3 Accessing EJBs from a servlet 8 1.4 Invoking an EJB from a JavaServer Page 12 1.5 Invoking EJB business logic from a JMS system 15 1.6 Persisting a reference to an EJB instance 18 1.7 Retrieving and using a persisted EJB reference 20 1.8 Persisting a home object reference 21 1.9 Comparing two EJB references for equality 23 vii viii CONTENTS 1.10 Using reflection with an EJB 25 1.11 Invoking an EJB from an applet 27 1.12 Improving your client-side EJB lookup code 31 2 Code generation with XDoclet 33 An XDoclet appetizer 35 2.1 Generating home, remote, local, and local home interfaces 37 2.2 Adding and customizing the JNDI name for the home interface 43 2.3 Keeping your EJB deployment descriptor current 45 2.4 Creating value objects for your entity beans 47 2.5 Generating a primary key class 53 2.6 Avoiding hardcoded XDoclet tag values 56 2.7 Facilitating bean lookup with a utility object 58 2.8 Generating vendor-specific deployment descriptors 62 2.9 Specifying security roles in the bean source 63 2.10 Generating and maintaining method permissions 64 2.11 Generating finder methods for entity home interfaces 66 2.12 Generating the ejbSelect method XML 67 2.13 Adding a home method to generated home interfaces 68 2.14 Adding entity relation XML to the deployment descriptor 70 2.15 Adding the destination type to a message-driven bean deployment descriptor 71 2.16 Adding message selectors to a message-driven bean deployment descriptor 73 CONTENTS ix PART II MAIN COURSES................................................ 75 3 Working with data 77 3.1 Using a data source 78 3.2 Creating EJB 2.0 container-managed persistence 81 3.3 Using different data sources for different users 85 3.4 Using a database sequence to generate primary key values for entity beans 88 3.5 Using a compound primary key for your entity beans 92 3.6 Retrieving multiple entity beans in a single step 95 3.7 Modeling one-to-one entity data relationships 97 3.8 Creating a one-to-many relationship for entity beans 101 3.9 Using entity relationships to create a cascading delete 104 3.10 Developing noncreatable, read-only entity beans 107 3.11 Invoking a stored procedure from an EJB 109 3.12 Using EJB-QL to create custom finder methods 111 3.13 Persisting entity data into a database view 115 3.14 Sending notifications upon entity data changes 117 3.15 Creating an interface to your entity data 120 3.16 Retrieving information about entity data sets 122 3.17 Decreasing the number of calls to an entity bean 124 3.18 Paging through large result sets 126 4 EJB activities 133 4.1 Retrieving an environment variable 134 4.2 Implementing toString() functionality for an EJB 136 4.3 Providing common methods for all your EJBs 137

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.