“Jim Marino and Michael Rowley have been involved with SCA from the start and know it as well as anyone. They have great hands-on experience with the Fabric3 open source SCA project. This book also tackles the subject and its broad issues head on, and in addition to the clear and concise technical descriptions of SCA, they provide excellent sidebar perspectives on Java, Java EE, Web services, and SCA’s relationship to them all.”
—Eric Newcomer, Progress Software,
Coauthor of Understanding SOA with Web Services,
and Author of Understanding Web Services
“It was really worthwhile reading this book. It not only introduces a powerful technology, but also provides comprehensive coverage of supporting technologies. The authors have paid plenty of attention to practical issues including performance and thoroughly understand the ways that SCA can leverage state-of-the-art technologies such as JPA.”
—Tim Holloway, Forum Moderator,
The JavaRanch
“SCA is a nice, conceptually and technically sound advanced component framework. This book enables easy access to this exciting technology for software developers.”
—Dr. Steffen Becker
“Understanding SCA (Service Component Architecture) delivers the details for how to effectively use SCA leveraging open source tools such as Fabric3.”
—Dave Hendricksen, Software Architect
Upper Saddle River, NJ • Boston • Indianapolis • San Francisco
New York • Toronto • Montreal • London • Munich • Paris • Madrid
Cape Town • Sydney • Tokyo • Singapore • Mexico City
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact:
U.S. Corporate and Government Sales
(800) 382-3419
[email protected]
For sales outside the United States, please contact:
International Sales
[email protected]
Visit us on the Web: informit.com/aw
Editor-in-Chief
Karen Gettman
Executive Editor
Chris Guzikowski
Senior Development Editor
Chris Zahn
Development Editor
Susan Brown Zahn
Managing Editor
Kristy Hart
Project Editor
Jovana San Nicolas-Shirley
Copy Editor
Water Crest Publishing
Indexer
Erika Millen
Proofreaders
Seth Kerney
Apostrophe Editing Services
Publishing Coordinator
Raina Chrobak
Cover Designer
Sandra Schroeder
Compositor
Gloria Schurick
Library of Congress Cataloging-in-Publication Data:
Marino, Jim, 1969-
Understanding SCA (Service Component Architecture) / Jim Marino, Michael Rowley.
p. cm.
Includes bibliographical references and index.
ISBN 978-0-321-51508-7 (pbk. : alk. paper) 1. Application software—
Development. 2. Web services. 3. Computer software—Reusability. 4. System
design. I. Rowley, Michael. II. Title.
QA76.76.A65M339 2009
005.3—dc22
2009021249
Copyright © 2010 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to:
Pearson Education, Inc.
Rights and Contracts Department
501 Boylston Street, Suite 900
Boston, MA 02116
Fax (617) 671-3447
ISBN-13: 978-0-321-51508-7
ISBN-10: 0-321-51508-0
Text printed in the United States on recycled paper at R.R. Donnelley in Crawfordsville, Indiana.
First printing July 2009
SCA and Enterprise Architectures
Binding Services and References
Composites as a Unit of Deployment
2 ASSEMBLING AND DEPLOYING A COMPOSITE
Using Web Services Description Language (WSDL)
Remotable Versus Local Services
Creating Component Implementations
Assembling the LoanApplication Composite
Binding a Web Service Endpoint
Packaging the LoanApplication Composite
Deploying the LoanApplication Composite
Download Fabric3 LoanApplication Sample
Build and Deploy the Application
Invoking the LoanApplication Service
3 SERVICE-BASED DEVELOPMENT USING JAVA
Protocol Abstraction and Location Transparency
Using WSDL for Service Contracts
Service Contracts and Data Binding
Exception Handling, Non-Blocking Operations, and Callbacks
Component Implementation Instances
Conversation-Scoped Components
Initialization and Destruction Notifications
4 CONVERSATIONAL INTERACTIONS USING JAVA
Implementing Conversational Services
Conversation-Scoped Implementations
Conversational Services and Asynchronous Interactions
Callbacks to Conversational and Stateless Clients
The Composite Implementation Type
Configuring Composite Properties
Referencing Complex Property Values
PropagatesTransaction—An Example of a Required Intent
Policies for One-Way Messaging
Wiring to Multiple Service Providers
Interoperable Communications Outside the Domain: The Web Service Binding
Using WSDL as the Interface Definition Language
Non-Blocking Interactions Using Web Services
Callbacks and Conversations with Web Services
Accessing Messaging Infrastructure: The JMS Binding
Request-Response Messaging with JMS
Using Publish-Subscribe Messaging Patterns
Conversational Interactions with JMS
Using Bindings for Communicating Within a Domain
10 SERVICE-BASED DEVELOPMENT USING BPEL
BPEL Versus Java for Conversational Services
Using BPEL for the Loan Service
Partner Links Are Services and References
Symmetry of Partner Link Types
Static Control Flow Analysis with SCA BPEL
Partner Link Types as Interfaces
Customizing the Generated Services and References
DataSources and Transaction Policy
The Basics: Object Lifecycles and the Persistence Context
Transaction-Scoped Persistence Contexts
JPA and Conversational Services
Accessing the EntityManagerFactory
Packaging and Deploying a Web Component
Java Server Pages and the SCA Tag Library
Accessing Conversation Services
We would like to thank the reviewers of our book who provided invaluable comments, feedback, and suggestions: Dr. Steffen Becker, Dave Hendricksen, Tim Holloway, and Dave Ennis. We would also like to extend our appreciation to Raina Chrobak, Susan Zahn, Jovana San Nicolas-Shirley, and everyone at Addison-Wesley who guided us along the way.
Service Component Architecture (SCA) was the outgrowth of a truly collaborative effort. We send a special thanks to the original SCA cohorts—Graham Barber, Michael Beisiegel, Dave Booz, Mike Edwards, and Martin Nally.
Special acknowledgment goes to two individuals who selflessly gave their time, assistance, and encouragement throughout the course of writing this book: David Chappell and Ed Cobb. We are truly grateful for the extraordinary efforts they made on numerous occasions.
Jim would like to express his personal thanks to Niccolò, Jim, Kathy, Michelle, Paolo, Anna, and, in particular, Lia, whose love and support made this book possible.
Michael would like to thank Jim for the opportunity to work with him on this project. Michael would also like to thank to his wife Elise, for whose unfailing love, support, and encouragement he is eternally grateful.
Jim Marino, Ph.D., is Principal at Metaform Systems, where he provides strategic planning, architecture assistance, and training to clients worldwide. Jim is also one of the architects of the Fabric3 SCA runtime. Prior to joining Metaform Systems, Jim was Director of Technology at BEA Systems, where he was involved with the development of Service Component Architecture from its inception.
Michael Rowley, Ph.D., is the CTO of Active Endpoints, Inc. He has been involved in the development of SCA from early in its development and has contributed to 12 of the 15 SCA specifications that were published as part of the Open Service-Oriented Architecture (OSOA) collaboration. He was also an original member of the Open Component Service Architecture (OpenCSA) steering committee, which is the OASIS steering committee that oversees the work of the various SCA technical committees. Before joining Active Endpoints, he was a Director of Technology at BEA Systems where, in addition to working on SCA, he also helped develop the BPELJ extension to BPEL and was involved in the early development of BEA’s event processing and service bus products. Michael received his Ph.D. in computer science from UCLA in 1994.
What is Service Component Architecture (SCA)? What are the key SCA concepts? How will SCA impact technology choices my organization will need to make in the near-term? How should SCA fit into my enterprise architecture? How can I make the best use of SCA in my projects?
Answering these questions is fundamental to understanding SCA. The goal of this book is to help answer those questions by providing the background necessary to use SCA effectively.
SCA is a technology for creating, assembling, and managing distributed applications. However, this book is not intended solely for developers. Our aim is to benefit “technologists”—developers, but also architects, analysts, managers, and anyone who has a stake implementing information systems—by connecting SCA to broader technology trends.
In this book, we attempt to strike a balance between the “big picture” and the detailed coverage essential to developers. We also endeavor to achieve this balance in a way that is engaging, accurate, and complete.
Both of us have been involved with SCA since its inception, when it started as an informal working group composed of individuals from IBM and BEA (where both of us worked). We were directly involved in shaping SCA as it went through various iterations and changes.
Rather than simply provide a tutorial, we have sought to explain the history and reasoning behind important decisions made during the development of SCA.
Lest we be accused of operating in the “ivory tower” of technology standards, we have also attempted to be informed by practical experience. We have been key contributors to the open source Fabric3 SCA runtime. In addition, while at BEA and now in our current positions, we have had the opportunity to be involved in the development of several large-scale systems built with SCA. We have tried to reflect this experience and lessons learned throughout the book in the form of best practices and implementation advice.
Finally, while we strive for completeness and accuracy, there are inevitably things a book must leave out. SCA is a vast technology that spans multiple programming languages. We have chosen to concentrate on those aspects of SCA that pertain to creating and assembling applications using Java. Although we touch on BPEL, our focus remains on Java, as the latter is a cornerstone of modern enterprise development.
Reading a book is like listening to an album (or CD): Both are highly personal experiences. Some prefer to read thoroughly or listen from beginning to end. Others like to skip around, focusing on specific parts.
Understanding SCA is designed to be read in parts but also has a structure tying the various pieces together. The first chapter, “Introducing SCA,” provides an overview of SCA and how it fits into today’s technology landscape. The second chapter, “Assembling and Deploying a Composite,” continues the overview theme by walking through how to build an application using SCA.
Chapter 3, “Service-Based Development Using Java,” and Chapter 4, “Conversational Interactions Using Java,” respectively, turn to advanced SCA programming model topics. In these chapters, we detail how to design loosely coupled services and asynchronous interactions, manage stateful services, and provide best practices for developing with SCA.
Having explored the SCA programming model in depth, Chapters 5–9 cover the main SCA concepts: composition, policy, wires, bindings, and the domain. In these chapters, we explain how to develop modular applications, use transactions, configure cross-application policies such as security and reliability, integrate with external systems, deploy applications, and structure corporate architectures using SCA.
Chapter 10, “Service-Based Development Using BPEL,” demonstrates how to use BPEL with SCA to provide applications with long-running process capabilities.
The final two chapters round out application development with SCA by focusing on the data and presentation tiers. Chapter 11, “Persistence,” details how to use Java Persistence API (JPA) with SCA to read and write data from a database. Chapter 12, “The Presentation Tier,” demonstrates how to integrate web applications, in particular servlets and JSPs, with SCA services.