COMPONENT-ORIENTED PROGRAMMING

Similar documents
Real-Time Optimization by Extremum-Seeking Control

TASK SCHEDULING FOR PARALLEL SYSTEMS

LEGITIMATE APPLICATIONS OF PEER-TO-PEER NETWORKS DINESH C. VERMA IBM T. J. Watson Research Center A JOHN WILEY & SONS, INC., PUBLICATION

MODERN MULTITHREADING

LEGITIMATE APPLICATIONS OF PEER-TO-PEER NETWORKS

Microprocessor Theory

COSO Enterprise Risk Management

HASHING IN COMPUTER SCIENCE FIFTY YEARS OF SLICING AND DICING

Practical Database Programming with Visual Basic.NET

DIFFERENTIAL EQUATION ANALYSIS IN BIOMEDICAL SCIENCE AND ENGINEERING

Relational Database Index Design and the Optimizers

Modern Experimental Design

IP MULTICAST WITH APPLICATIONS TO IPTV AND MOBILE DVB-H

Algorithms and Parallel Computing

Agile Database Techniques Effective Strategies for the Agile Software Developer. Scott W. Ambler


7 Windows Tweaks. A Comprehensive Guide to Customizing, Increasing Performance, and Securing Microsoft Windows 7. Steve Sinchak

OVER 750 QUESTIONS AND 55 TASK-BASED SIMULATIONS! CPA EXAM REVIEW. Auditing and Attestation. O. Ray Whittington, CPA, PhD Patrick R.

Linux Command Line and Shell Scripting Bible. Third Edtion

Mastering UNIX Shell Scripting

Join the p2p.wrox.com. Wrox Programmer to Programmer. Beginning PHP 5.3. Matt Doyle

THE ARCHITECTURE OF COMPUTER HARDWARE, SYSTEM SOFTWARE, AND NETWORKING

Beginning Transact-SQL with SQL Server 2000 and Paul Turley with Dan Wood

J2EE TM Best Practices Java TM Design Patterns, Automation, and Performance

Magical Math G ROOVY G EOMETRY. Games and Activities That Make Math Easy and Fun. Lynette Long. John Wiley & Sons, Inc.


Study Guide. Robert Schmidt Dane Charlton

Mastering BEA WebLogic Server Best Practices for Building and Deploying J2EE Applications

MCITP Windows Server 2008 Server Administrator Study Guide

FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE

Cloud Phone Systems. Andrew Moore. Making Everything Easier! Nextiva Special Edition. Learn:

Linux Command Line and Shell Scripting Bible

Professional ASP.NET 2.0 Databases. Thiru Thangarathinam

Beginning Web Programming with HTML, XHTML, and CSS. Second Edition. Jon Duckett

COMPUTATIONAL DYNAMICS

Implementing Security and Tokens: Current Standards, Tools, and Practices

Multi-Core Programming

Oracle PL/SQL. DUMmIES. by Michael Rosenblum and Dr. Paul Dorsey FOR

iwork DUMmIES 2ND EDITION FOR

DATABASE DESIGN AND DEVELOPMENT

UPC DISTRIBUTED SHARED MEMORY PROGRAMMING

PHP & MySQL. Learn to: Janet Valade. Making Everything Easier! 4th Edition. Create well-formed PHP code that s compliant with PHP 4, 5, and 6

Exploiting Distributed Resources in Wireless, Mobile and Social Networks Frank H. P. Fitzek and Marcos D. Katz

Networking. 11th Edition. by Doug Lowe

Capital. Capital Logic Aero. v Student Workbook

COMPUTING FOR NUMERICAL METHODS USING VISUAL C++

Capital. Capital Logic Generative. v Student Workbook

Securing SCADA Systems. Ronald L. Krutz

Preface. This Book and Simulation Software Bundle Project


Secure Web Gateway MIB Data Breakdown

Guide to RISC Processors

Network Performance Analysis

INFORMATION RETRIEVAL SYSTEMS: Theory and Implementation

Research on Industrial Security Theory

The Internet of Things

Linux. The book you need to succeed! Boot up to Ubuntu, Fedora, KNOPPIX, Debian, opensuse, and 13 Other Distributions Edition.

Component models. Page 1

Digital Signal Processing System Design: LabVIEW-Based Hybrid Programming Nasser Kehtarnavaz

Tanner Analog Front End Flow. Student Workbook

MULTIMEDIA DATABASE MANAGEMENT SYSTEMS

Java Quick Syntax Reference. Second Edition. Mikael Olsson

Topological Structure and Analysis of Interconnection Networks

Capital. Capital Logic Interactive. v Student Workbook



Historical Reliability Data for IEEE 3006 Standards: Power Systems Reliability

This page intentionally left blank

EMBEDDED SYSTEMS: Jonathan W. Valvano INTRODUCTION TO THE MSP432 MICROCONTROLLER. Volume 1 First Edition June 2015

COMPUTER SECURITY AND CRYPTOGRAPHY ALAN G. KONHEIM

Computer Science. Computer Science 211. Degrees and Certificates Awarded. A.S. Computer Science Degree Requirements. Program Student Outcomes

Low Level X Window Programming

Teaching Object-Oriented Programming Concepts Using Visual Basic.NET

THE VERILOG? HARDWARE DESCRIPTION LANGUAGE

Windows. 7 Desktop Support and Administration. Real World Skills for MCITP Certification and Beyond. Darril Gibson

TEACH YOURSELF THE BASICS OF ASPEN PLUS

LOGICAL DATA MODELING

Microsoft Dynamics GP. Inventory Kardex

Developing Java TM 2 Platform, Enterprise Edition (J2EE TM ) Compatible Applications Roles-based Training for Rapid Implementation

PELLISSIPPI STATE COMMUNITY COLLEGE MASTER SYLLABUS LINUX SYSTEM ADMINISTRATION CSIT 2411

FUZZY LOGIC WITH ENGINEERING APPLICATIONS

LAB MANUAL. Craig Zacker.

Tessent TestKompress & Adv. Topics. Student Workbook

"Charting the Course to Your Success!" MOC B Core Solutions of Microsoft Lync Server 2013 Course Summary

Hands-On Oracle Application Express Security

Functional Programming in R

Design Architect Student Workbook Mentor Graphics Corporation All rights reserved.

CorelDRAW X7. Kogent Learning Solutions Inc. Authored by: Published by:

Microscan Barcode Reader

Experion LX Safety Manager Integration Guide

Fundamentals of Operating Systems. Fifth Edition

Enterprise JavaBeans 2.1

SECURITY FOR WIRELESS AD HOC NETWORKS

SDH/SONET Explained in Functional Models

FileMaker. Pro 10. The book you need to succeed! Companion Web Site. Ray Cologon. Go from basics to full-scale development

PRACTICAL GENETIC ALGORITHMS

Component-Level Design. Slides copyright 1996, 2001, 2005, 2009 by Roger S. Pressman. For non-profit educational use only

SystemVerilog UVM. Student Workbook

Google Voice. Learn to: Bud E. Smith Chris Dannen. Making Everything Easier! Set up and use Google Voice

Introduction to componentbased software development

Transcription:

COMPONENT-ORIENTED PROGRAMMING

COMPONENT-ORIENTED PROGRAMMING ANDY JU AN WANG KAI QIAN Southern Polytechnic State University Marietta, Georgia A JOHN WILEY & SONS, INC., PUBLICATION

Copyright 2005 by John Wiley & Sons, Inc. All rights reserved. Published by John Wiley & Sons, Inc., Hoboken, New Jersey. 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 Section 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, Inc., 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400, fax 978-646-8600, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008. Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages. For general information on our other products and services please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993 or fax 317-572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print, however, may not be available in electronic format. Library of Congress Cataloging-in-Publication Data: Wang, Andy Ju An. Component-oriented programming / Andy Ju An Wang & Kai Qian. p. cm. A Wiley-Interscience publication. Includes bibliographical references. ISBN 0-471-64446-3 1. Component software. 2. Computer programming. I. Qian, Kai. II. Title. QA76.76.C66W36 2005 005.3 dc22 2004015681 Printed in the United States of America. 10987654321

CONTENTS Preface ix 1 Introduction 1 1.1 What Is COP? 1 1.2 Why Is COP Important? 3 1.3 What Is a Component? 5 1.4 Hardware Components and Software Components, 7 1.5 From OOP to COP, 8 1.6 Component-Based Software Engineering, 10 1.7 Summary, 11 1.8 Self-Review Questions, 12 1.9 Exercises, 14 References, 14 2 Theory of Components 16 2.1 Principles of COP, 16 2.2 Infrastructures of COP, 18 2.3 Component Models, 20 2.4 Connection Models, 21 2.5 Deployment Models, 26 2.6 Unifying Component Technologies, 26 2.7 Summary, 32 2.8 Self-Review Questions, 33 2.9 Exercises, 35 References, 35 3 COP with JavaBeans 37 3.1 Overview of JavaBeans Technology, 37 3.2 Component Model of JavaBeans, 38 v

vi CONTENTS 3.3 Connection Model of JavaBeans, 64 3.4 Deployment Model of JavaBeans, 72 3.5 Examples and Lab Practice, 76 3.6 Summary, 83 3.7 Self-Review Questions, 85 3.8 Exercises, 86 References, 87 4 Enterprise JavaBeans Components 88 4.1 EJB Architecture, 88 4.2 Component Model of EJB, 90 4.3 Connection Model of EJB, 100 4.4 Deployment Model of EJB, 104 4.5 Examples and Lab Practice, 105 4.6 Summary, 142 4.7 Self-Review Questions, 143 4.8 Exercises, 143 4.9 Programming Exercises, 144 References, 145 5 CORBA Components 146 5.1 CORBA Component Infrastructure, 146 5.2 CORBA Component Model (CCM), 149 5.3 Connection Model of CORBA and CCM, 173 5.4 Deployment Model of CORBA and CCM, 176 5.5 Examples and Lab Practice, 184 5.6 Summary, 189 5.7 Self-Review Questions, 190 5.8 Exercises, 191 5.9 Programming Exercises, 192 References, 192 6.NET Components 194 6.1.NET Framework, 194 6.2 Component Model of.net, 198 6.3 Connection Model of.net, 204 6.4.NET Component Deployments, 212 6.5 Visual Studio.NET, 215 6.6 Examples and Lab Practice, 224 6.7 Summary, 234 6.8 Self-Review Questions, 234 6.9 Exercises, 235 6.10 Programming Exercises, 236 References, 237 7 COP with OSGi Components 238 7.1 Overview of OSGi Technology, 238 7.2 Component Model of OSGi, 239

CONTENTS vii 7.3 Connection Model of OSGi, 247 7.4 Deployment Model of OSGi, 250 7.5 Examples and Lab Practice, 252 7.6 Summary, 261 7.7 Self-Review Questions, 263 7.8 Exercises, 265 References, 266 8 Web Services Components 267 8.1 Web Services Framework, 267 8.2 Component Model of Web Services, 281 8.3 Connection Model of Web Services, 293 8.4 Web Services Component Deployment, 297 8.5 Examples and Lab Practice, 299 8.6 Summary, 311 8.7 Self-Review Questions, 312 8.8 Exercises, 313 8.9 Programming Exercises, 314 References, 314 Index 315

PREFACE This book is about component-oriented programming (COP for short), a new programming paradigm beyond object-oriented programming. Component-oriented programming offers higher reusability and better modular structure with greater flexibility, compared with object-oriented programming or library-based programming approaches. This book discusses principles of component-oriented programming and provides a unified component infrastructure to describe different component technologies. Hands-on programming practice is emphasized in this book. Readers of this book will learn how to develop reusable software components and how to build a software system out of prebuilt software components. Both authors have been teaching Component-Based Software Development (CBSD) to graduate and undergraduate students for several years. We strongly believe that we need a textbook emphasizing the programming aspect of CBSD or CBSE (Component- Based Software Engineering). Thus, students majoring in computer science, software engineering, or related areas can take this course as one of the major concentrations following OOP (Object-Oriented Programming) and elementary software engineering courses. CBSD is not just a philosophy, a theory, or some standard. It represents a new programming paradigm beyond OOP and library-based programming paradigms this is partially why we chose the title Component Oriented Programming. In a librarybased programming paradigm, multiple layers of software abstractions stack up one on top of the other, whereas in a component-based model, multiple software components plug in side-by-side with one another. In a library-based model, once a module is compiled into the software, it is always available at runtime. In a component-based model, a component can come and go dynamically at runtime. In a library-based paradigm, one most likely must rebuild and repackage the entire set of libraries to fix bugs and add features at compile-time. In a component-based paradigm, new components can be added or existing components can be updated in an incremental way at runtime. In a library-based paradigm, changes made to public interfaces have less impact because one has to rebuild the software in its entirety. In a component-based paradigm, the cost of ix

x PREFACE redoing public interfaces can be prohibitive because other components may have relied on them at runtime. We can make a long list of differences between traditional, library-based programming and new, component-based programming. Many software engineers have not realized or appreciated this shift in programming paradigms. As many experts have predicted, CBSE and component-oriented programming will be the future of software development following structured programming, library-based programming, and object-oriented programming. It is essential to make students realize that componentbased software development requires more discipline on the part of developers during the design and programming stages to provide more stability, extensibility, and flexibility. Such disciplined activity and techniques have to be established through well-developed training and practice following component-based software development principles. However, books published on CBSE are not suited to provide such training. Some are highly theoretical, targeting academic researchers, while others emphasize software life cycle and project management; yet others are too specific for particular component technology. In a typical computer science or software engineering curriculum setting in colleges and universities, the course for component-based software development is usually designed for students with previous training on OOP and fundamental software engineering principles. Hence, it is challenging to shift students from the mindset of library-based programming and OOP to the mindset of component-oriented programming. Both authors have followed a programming-centered approach to teaching the Component-Based Software Development course, which has turned out to be successful in emphasizing programming methodology and programming practice in the CBSE context. The programming paradigm is changing from object-oriented programming to component-oriented programming. We predict that in the next few years, component-based development will be the mainstream practice in software engineering. This book will provide in-depth knowledge about component-based development. It intends to introduce component-oriented programming to college students majoring in computer science, software engineering, information technology and to professional software engineers working in the industry as well. We assume that the readers of the book are familiar with at least one high-level programming language. The emphasis will be on component-oriented programming principles, methods, and techniques. Any reader who is interested in component-based software engineering in general will find useful information in this book. Readers can expect to gain the comprehensive knowledge necessary for component software development. Three efforts have been made to help readers understand and master componentoriented programming techniques. First, a unified component infrastructure is used for all component technologies covered in this book, namely, JavaBeans, EJB, COM/DCOM/.NET, CORBA, OSGi, and Web Services. This common component infrastructure contains a component model, a connection model, and a deployment model. It represents standard conventions for component specification, interfaces, composing connectors, architecture, packaging, and deployment. It also helps to apply the component principles to practical component software development following a well-defined format. The unified component infrastructure also serves as a pedagogical tool to keep readers concentrating on technical essentials rather than being distracted by those technical details.

PREFACE xi Second, we have paid careful attention to the pedagogical organization of the book. For instance, we put forward briefly at the beginning of each chapter its main objectives, and we explain all potential tricky points in detail in the process of presenting the content. At the end, a brief summary is provided to highlight the key points of the chapter. Self-Review Questions are designed for readers to test their understanding of the materials in each chapter, and key solutions for these questions are supplied. Exercises and Lab Practice are provided at the end of each chapter, serving as an integral part of the book. Third, a supplementary Web site (ftp://ftp.wiley.com/public/sci tech med/component/) is provided containing all examples, laboratory project guidelines, software packages, and developing tools used in the book. Overview of Chapters Chapter 1 is a brief introduction to component-oriented programming and the benefits of component-based software development. Chapter 2 discusses the principles of component-oriented programming, and provides a unified framework for describing different component technologies. Chapter 3 introduces the component infrastructure of JavaBeans. Both BDK (Bean Development Kit) and Bean Builder are discussed. Chapter 4 covers J2EE framework and EJB component architecture. Chapter 5 discusses CORBA (Common Object Request Broker Architecture) component infrastructure. Chapter 6 introduces Microsoft.NET framework and Visual Studio.NET component technology. Chapter 7 covers the component technology proposed by OSGi (Open Service Gateway initiative). Chapter 8 investigates Web services component technology. Acknowledgments Thanks to Cassie Craig of John Wiley & Sons, Inc., for her incredibly positive support in the writing of this text. We want to thank all the other people who helped improve the text, from the reviewers and editors to those who sent suggestions and feedback in the early drafts of this book.