ebook img

Java Enterprise Design Patterns: Patterns in Java PDF

497 Pages·2001·3.101 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 Java Enterprise Design Patterns: Patterns in Java

Y L F M A E T ® Team-Fly JJaavvaa™ EEnntteerrpprrisisee DDeessiiggnn PPaatttteerrnnss Patterns in JavaTM, Volume 3 MARK GRAND MARK GRAND John Wiley & Sons, Inc. New York ● ChichesterJo●hWne Winihleeiym &● SBorniss,b aInnce.● Singapore ● Toronto New York ● Chichester ● Weinheim ● Brisbane ● Singapore ● Toronto Publisher: Robert Ipsen Editor: Theresa Hudson Developmental Editor: Kathryn A. Malm Managing Editor: Angela Smith New Media Editor: Brian Snapp Text Design & Composition: Designations used by companies to distinguish their products are often claimed as trademarks. In all instances where John Wiley & Sons, Inc., is aware of a claim, the product names appear in initial capital or ALL CAPITAL LETTERS. Readers, how- ever, should contact the appropriate companies for more complete information regarding trademarks and registration. ●∞ This book is printed on acid-free paper. Copyright © 2002 by Mark Grand. All rights reserved. Published by John Wiley & Sons, Inc., New York Published simultaneously in Canada. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4744. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 605 Third Avenue, New York, NY 10158-0012, (212) 850-6011, fax (212) 850-6008, E-Mail: PERMREQ @ WILEY.COM. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold with the understanding that the publisher is not engaged in professional services. If professional advice or other expert assistance is required, the services of a competent professional person should be sought. Library of Congress Cataloging-in-Publication Data: Grand, Mark. Java Enterprise design patterns / Mark Grand. p. cm. ISBN 0-471-33315-8 (pbk.: alk. paper) 1. Java (Computer program language) 2. Web servers. 3. Object- oriented programming (Computer science) I. Title. QA76.73.J38 G72 2001 005. 13'3—dc21 2001045611 Printed in the United States of America. 10 9 8 7 6 5 4 3 2 1 C O N T E N T S Acknowledgments vii About the Author viii Chapter 1 Introduction to Software Patterns 1 Description of Patterns 2 Pattern Name 3 Synopsis 3 Context 3 Forces 3 Solution 4 Consequences 4 Implementation 4 Known Uses 4 Code Example 4 Related Patterns 4 A Very Brief History of Patterns 5 Organization of This Book 5 iv ■ CONTENTS Chapter 2 Overview of UML 7 Class Diagram 8 Collaboration Diagram 18 Statechart Diagram 26 Deployment Diagram 28 Chapter 3 The Software Life Cycle 29 Chapter 4 Transaction Patterns 33 Acid Transaction 37 Composite Transaction 55 Two Phase Commit 65 Audit Trail 75 Chapter 5 Distributed Architecture Patterns 81 Shared Object 83 Object Request Broker 89 Object Replication 99 Redundant Independent Objects 109 Prompt Repair 115 Mobile Agent 119 Demilitarized Zone 129 Process Pairs 133 Chapter 6 Distributed Computing Patterns 137 Object Identifier 139 Registry 149 Protection Proxy 157 Publish-Subscribe 175 Retransmission 187 Mailbox 195 Heavyweight/Lightweight 203 Heartbeat 209 Connection Multiplexing 229 Chapter 7 Concurrency Patterns 275 Session Object 277 Lock File 285 Static Locking Order 291 Optimistic Concurrency 297 Thread Pool 303 Ephemeral Cache Item 325 Transaction State Stack 337 Contents ■ v Chapter 8 Temporal Patterns 347 Time Server 349 Versioned Object 355 Temporal Property 373 Chapter 9 Database Patterns 387 Persistence Layer 389 CRUD 407 Stale Object 413 Type Conversion 423 IsDirty 431 Lazy Retrieval 439 Appendix A Persistence Framework 445 Bibliography 475 Index 477 A C K N O W L E D G M E N T S This book would not have been possible without the inspiration, encour- agement and assistance of others. I want to thank Brad Appleton for his diligent reviews and concern with form. Wolfgang W. Keller provided extensive feedback on the transaction patterns chapter. Frank Sauer provided excellent feedback on the database patterns chapter. I also want to thank the members of the pattern discussion group at University of Illinois, Champaign-Urbana, for their invaluable comments on my manuscript: Joe Yoder, Brian Foote, Hiroaki Nakamura, Roger Whitney, Ralph Johnson, Brian Marick, Wanghong Yuan, Paul Rubel, Frederico Balaguer, Alejandra Garrido, Don Roberts, Zhijiang “John” Han, Weerasak Witthawuskul, Peter Hatch, Dragos Malolescu, and Les Tyrrell. Last, but not least, I would like to thank my wife Nicole for her sup- port and encouragement through the most difficult of times. This book could not have been finished without her understanding and patience. A B O U T T H E A U T H O R Y L F M A E Mark Grandis a conTsultant specializing in distributed systems, object- oriented design, and Java. He is currently working on an open source framework for gluing components and programs into an application. Mark Grand is the author of a series of books titled Patterns in Java. He is a consultant who specializes in Distributed Systems, Object Oriented Design, and Java. He was the architect of the first commercial B2B e-commerce product for the Internet. Team-Fly® 1 C H A P T E R Introduction to Software Patterns Software patternsare reusable solutions to recurring problems that occur during software development. For purposes in this book, we refer to soft- ware patterns simply as patterns. What makes a bright, experienced programmer so much more produc- tive than a bright but inexperienced programmer? Experience. Experience gives programmers wisdom. As programmers gain experience, they recog- nize the similarity between new problems and those problems that they have solved before. With even more experience, they recognize that the solutions for similar problems follow recurring patterns. Experienced programmers recognize the situations where these patterns apply and quickly draw on existing solutions without having to stop, analyze the problems, and then pose possible strategies. When a programmer discovers a pattern, it’s just an insight. In most cases, to go from a nonverbalized insight to a well-thought-out idea that the programmer can clearly articulate is surprisingly difficult. It’s also an extremely valuable step. When we understand a pattern well enough to put it into words, we are able to intelligently combine it with other patterns. More important, once put into words, a pattern can be used in discussions among programmers who know the pattern. That allows programmers to more effectively collaborate and combine their wisdom. It can also help to 1

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.