Spring Dynamic Modules in Action potx

543 1.9K 0
Spring Dynamic Modules in Action potx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

MANNING Arnaud Cogoluègnes Thierry Templier Andy Piper F OREWORD BY P ETER K RIENS www.it-ebooks.info Spring Dynamic Modules in Action www.it-ebooks.info www.it-ebooks.info Spring Dynamic Modules in Action ARNAUD COGOLUÈGNES THIERRY TEMPLIER ANDY PIPER MANNING Greenwich (74° w. long.) www.it-ebooks.info For online information and ordering of this and other Manning books, please 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. 180 Broad Street Suite 1323 Stamford, CT 06901 Email: orders@manning.com ©2011 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 we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Development editor: Cynthia Kane Manning Publications Co. Copyeditor: Andy Carroll 180 Broad Street, Suite 1323 Cover designer: Marija Tudor Stamford, CT 06901 Typesetter: Gordan Salinovic ISBN 9781935182306 Printed in the United States of America 12345678910 –MAL –151413121110 Download from Wow! eBook <www.wowebook.com> www.it-ebooks.info v brief contents PART 1 SPRING DM BASICS. 1 1 ■ Modular development with Spring and OSGi 3 2 ■ Understanding OSGi technology 24 3 ■ Getting started with Spring DM 63 PART 2 CORE SPRING DM . 101 4 ■ Using Spring DM extenders 103 5 ■ Working with OSGi services 133 6 ■ OSGi and Spring DM for enterprise applications 164 7 ■ Data access in OSGi with Spring DM 199 8 ■ Developing OSGi web components with Spring DM and web frameworks 236 PART 3 ADVANCED TOPICS 281 9 ■ Advanced concepts 283 10 ■ Testing with Spring DM 323 11 ■ Support for OSGi compendium services 351 12 ■ The Blueprint specification 374 Download from Wow! eBook <www.wowebook.com> www.it-ebooks.info Download from Wow! eBook <www.wowebook.com> www.it-ebooks.info vii contents foreword xv preface xvii acknowledgments xix about this book xxi about the authors xxv about the title xxvi about the cover illustration xxvii PART 1 SPRING DM BASICS 1 1 Modular development with Spring and OSGi 3 1.1 Java modularity 4 What is modularity and what is it good for? 4 ■ Java—the end and the beginning 4 ■ Are your applications really modular? 5 1.2 The Spring Framework 5 Loose coupling of classes 6 ■ Dependency injection 7 ■ Aspect- oriented programming (AOP) 8 ■ Enterprise support 9 1.3 A new approach to modular development with OSGi 10 Aims of OSGi 10 ■ OSGi layers 11 ■ What OSGi offers 12 Download from Wow! eBook <www.wowebook.com> www.it-ebooks.info CONTENTS viii 1.4 Using Spring in an OSGi environment with Spring DM 13 What is Spring DM? 13 ■ Embedding Spring within an OSGi container 15 ■ Benefits of Spring DM for real-life OSGi applications 17 1.5 Spring DM Hello World 18 Provisioning the OSGi container 18 ■ Writing the Spring DM– powered bundle 21 ■ Deploying the bundle 22 1.6 Summary 23 2 Understanding OSGi technology 24 2.1 OSGi components 25 Component structure 25 ■ Component configuration 26 OSGi containers 28 ■ OSGi component lifecycle 29 2.2 Component dependencies 30 Classloader isolation and chaining 31 ■ Providing dependencies 33 Consuming dependencies with the Import-Package header 34 Consuming dependencies with the Require-Bundle header 36 Matching and versioning 38 2.3 Interacting with the OSGi container 42 Bundles 43 ■ Lifecycle management 44 ■ Properties 46 ■ Event support 46 ■ Persistent storage area 48 ■ Bundle activator 48 2.4 Service support in OSGi 50 Providing services 51 ■ Using services 54 ■ Service event support 56 2.5 Handling native code 58 2.6 Diagnosing errors 59 Detecting components with problems 60 ■ Detecting different kinds of problems 61 2.7 Summary 62 3 Getting started with Spring DM 63 3.1 Using Spring in OSGi components 64 Embedding the Spring application context within components 64 Spring DM’s OSGi-aware application context 66 ■ Spring DM’s extender mechanisms 67 ■ Kinds of supported bundles 69 Spring DM’s osgi namespace 70 3.2 Installing Spring DM 72 Configuring a container 72 ■ Provisioning a container for simple use 73 ■ Provisioning a container for web use 76 Download from Wow! eBook <www.wowebook.com> www.it-ebooks.info CONTENTS ix 3.3 Using a fragment to configure the LOG4J bundle 80 Using the fragment configuration pattern 80 ■ Implementing a fragment 81 ■ Installing a fragment into the OSGi container 82 3.4 Developing Spring DM bundles 82 Creating and configuring a bundle 82 ■ Packaging a bundle 85 Checking a bundle within a container 86 ■ Developing an integration test 87 3.5 Developing Spring DM web bundles 94 Creating and configuring a web bundle 94 ■ Packaging a web bundle 95 ■ Checking the operation of a web bundle in a container 97 Developing an integration test for a web bundle 97 3.6 Summary 100 PART 2 CORE SPRING DM 101 4 Using Spring DM extenders 103 4.1 Unleashing Spring DM’s standard extender 104 A word about dependencies 104 ■ Structure of standard Spring OSGi components 106 ■ Initializing and destroying the Spring container 110 ■ Customizing application context creation 116 Listening to extender events with the whiteboard pattern 118 Hard dependencies on the OSGi environment 123 4.2 Unleashing Spring DM’s web extender 126 Structure of Spring DM web OSGi components 126 ■ Classloading in web bundles 127 ■ OSGi-aware Spring web container 129 Spring DM web deployer 131 4.3 Summary 132 5 Working with OSGi services 133 5.1 Dependency injection and OSGi services 134 Combining OSGi services and dependency injection 134 ■ XML- based registration and referencing 136 ■ Annotation-based service referral 139 5.2 The thread context classloader and its use in OSGi 141 Using the thread context classloader 141 ■ Using the thread context classloader with OSGi 142 5.3 Advanced OSGi service configuration 144 Configuration for registering services 144 ■ Configuration for referencing services 148 Download from Wow! eBook <www.wowebook.com> www.it-ebooks.info [...]... Developing OSGi web components with Spring DM and web frameworks 236 8.1 Using action- based web frameworks with Spring DM Using Spring DM with action- based frameworks 237 Spring MVC with Spring DM 238 8.2 ■ 237 Using Using component-based web frameworks with Spring DM 244 Using Spring DM with component-based frameworks 244 Using JSF with Spring DM 245 Using Wicket with Spring DM 251 ■ ■ 8.3 Using AJAX... frameworks with Spring DM 256 Using Spring DM with AJAX frameworks 257 Using DWR with Spring DM 257 Using GWT with Spring DM 262 ■ ■ 8.4 Using web services with Spring DM 267 Using Spring DM with web service frameworks 267 Using Spring WS with Spring DM 268 Using Restlet with Spring DM 273 ■ ■ 8.5 Summary 279 PART 3 ADVANCED TOPICS 281 9 Advanced concepts 283 9.1 Configuring Spring DM core components... Using JDBC within OSGi with Spring DM 200 JDBC concepts 200 JDBC issues when used within OSGi 202 Configuring JDBC data sources 203 Provisioning the OSGi container for JDBC 207 Using JDBC within OSGi with Spring DM 207 ■ ■ ■ 7.2 Using ORM within OSGi with Spring DM 209 Object/relational mapping 210 Load-time weaving 215 Provisioning a container for JPA implementations 218 Using JPA in OSGi with Spring. .. passion for Spring technologies and for anything that can help us build better software Arnaud remembers his first contact with Spring Dynamic Modules he attended Costin Leau’s (Spring Dynamic Modules project lead) talk at SpringOne Europe in 2008 What could be more exciting for a Spring enthusiast than to be able to use Spring on the OSGi platform? At last, real, runtime modularity meets Spring! Unfortunately,... the time, much in the way of resources around Spring Dynamic Modules That was when he met Thierry and they both went on to write a French book on Spring In contrast, Andy in 2008 had already been working with Spring Dynamic Modules for a couple of years, having been involved with its original development and having used it extensively on several BEA products It was later in 2009 that Manning Publications... Download from Wow! eBook Part 1 Spring DM basics W elcome to Spring Dynamic Modules in Action Spring Dynamic Modules a synthesis of Spring and OSGi-is the technology that can help you write better, more beautiful, programs In these first three chapters, we are going to discuss the basics of all three technologies Spring, OSGi, and Spring DM—and by the end you should have a good idea... the Spring Framework and OSGi, combining the simplicity and power of Spring with the modularity, flexibility, and dynamism of OSGi Spring hardly needs any introduction, being the framework of choice for a significant segment of the Enterprise Java development market OSGi, in contrast, although not a new technology is one that is just becoming mainstream, helped in no small part by Spring DM Spring Dynamic. .. world’s interest in OSGi, so I too was interested It turned out that Interface 21, BEA, and Oracle were considering creating support for OSGi in the Spring Framework Spring is very good at configuring an application built out of simple objects that use, among other things, the simplified Spring interfaces to communicate with the world However, Spring did not provide any support for modularity In contrast,... and we introduce all of the main features and concepts here—dependency injection, extenders, writing bundles container provisioning, fragment configuration, and application development using Maven In part 2 we delve deeper into the main features of core Spring DM, covering each in a good amount of detail In part 3 we look at some more advanced topics surrounding the use of Spring DM www.it-ebooks.info... aid them in action The books in this series are designed for such readers xxvi www.it-ebooks.info Download from Wow! eBook about the cover illustration The figure on the cover of Spring Dynamic Modules in Action is an “Alkar” from the small town of Sinj in Croatia The Alka is an equestrian tournament held in Sinj every first Sunday in August since 1715, commemorating the definitive . <www.wowebook.com> www.it-ebooks.info CONTENTS viii 1.4 Using Spring in an OSGi environment with Spring DM 13 What is Spring DM? 13 ■ Embedding Spring within an OSGi container 15 ■ Benefits. 60 ■ Detecting different kinds of problems 61 2.7 Summary 62 3 Getting started with Spring DM 63 3.1 Using Spring in OSGi components 64 Embedding the Spring

Ngày đăng: 17/03/2014, 20:21

Từ khóa liên quan

Mục lục

  • Spring Dynamic Modules in Action

  • brief contents

  • contents

  • foreword

  • preface

  • acknowledgments

    • Arnaud Cogoluègnes

    • Thierry Templier

    • Andy Piper

    • about this book

      • Who should read this book

      • Roadmap

      • Code

      • Author online

      • about the authors

      • about the title

      • about the cover illustration

      • Spring DM basics

        • Modular development with Spring and OSGi

          • 1.1 Java modularity

            • 1.1.1 What is modularity and what is it good for?

            • 1.1.2 Java—the end and the beginning

            • 1.1.3 Are your applications really modular?

            • 1.2 The Spring Framework

              • 1.2.1 Loose coupling of classes

              • 1.2.2 Dependency injection

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan