applied java - gbv

5
Applied Java Patterns TM Stephen Stelting Olav Maassen Sun Microsystems Press A Prentice Hall Title

Upload: others

Post on 12-Apr-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Applied Java - GBV

Applied Java Patterns

TM

Stephen Stelting Olav Maassen

Sun Microsystems Press A Prentice Hall Title

Page 2: Applied Java - GBV

Table of Contents

Preface Why We Wrote This Book What This Book Is About Who Should Read This Book . Conventions Used How This Book Is Organized . How to Use This Book Companion Web Site Acknowledgments

Introduction

IX

...ix

...ix

....x

....x

...xi

...xi

. xi i xii

XV

Why Patterns? x v

History of the Patterns Movement x v i i

Basic Concepts in Patterns x v j u -Software Abstraction and Reuse v i v

Summary .....xxi

Part One: Commonly Used Patterns 7

Chapter 1: Creational Patterns 3 Introduction to Creational Patterns 5 Abstract Factory *• Builder , ^

v

Page 3: Applied Java - GBV

vi / Table of Contents

Factory Method 21 Prototype 28 Singleton 34

Chapter 2: Behavioral Patterns 39 Introduction to Behavioral Patterns 41 Chain of Responsibility 42 Command 51 Interpreter 59 Iterator 69 Mediator 77 Memento 88 Observer 94 State 104 Strategy 114 Visitor 121 Template Method 131

Chapter 3: Structural Patterns 139 Introduction to Structural Patterns 141 Adapter 142 Bridge 150 Composite 157 Decorator 166 Facade 175 Flyweight 183 Half-Object Plus Protocol (HOPP) 189 Proxy 197

Chapter 4: System Patterns 205 Introduction to System Patterns 207 Model-View-Controller (MVC) 208 Session 220 Worker Thread 231 Callback 238 Successive Update 248 Router 258 Transaction 265

Page 4: Applied Java - GBV

Table of Contents / vii

Part Two: Patterns in the Java Programming Language 273

Chapter 5: Introduction to Java Programming Language Patterns 275

Chapter 6: Java Core APIs 279

Event Handling 281 JavaBeans 284 AWT and Swing - The Graphical User Interface APIs 288 Collections Framework 294 Input-Output (I/O) 298 Reflection 300

Chapter 7: Distributed Technologies 303 304

Java Naming and Directory Interface (JNDI) 305 JDBC 308 RMI 311 CORBA 314

Chapter 8: Jini and J2EE Architectures 317 Jini 319 Java 2, Enterprise Edition (J2EE) 322 Servlets and JSPs 327 Enterprise JavaBeans 330

Appendix A: Full Code Examples 335 System Requirements 337 Creational Pattern Code Examples 337 Abstract Factory 338 Builder 343 Factory Method 352 Prototype 357 Singleton 360

Page 5: Applied Java - GBV

viii / Table of Contents

Chain of Responsibility 366 Command 374 Interpreter 381 Iterator 389 Mediator 395 Memento 403 Observer 408 State 414 Strategy 424 Visitor 432 Template Method 440 Adapter 445 Bridge 448 Composite 453 Decorator 462 Facade 468 Flyweight 477 Half-Object Plus Protocol (HOPP) 483 Proxy 492 Model-View-Controller (MVC) 501 Session 507 Worker Thread 517 Callback 525 Successive Update 532 Router 540 Transaction 548

Appendix B: Bibliography 559

Index 563