OSGi in Action. RICHARD S. HALL KARL PAULS STUART McCULLOCH DAVID SAVAGE CREATING MODULAR APPLICATIONS IN JAVA MANNING. Greenwich (74 w. long.

Similar documents
Agenda. Why OSGi. What is OSGi. How OSGi Works. Apache projects related to OSGi Progress Software Corporation. All rights reserved.

OSGi on the Server. Martin Lippert (it-agile GmbH)

Modular Java Applications with Spring, dm Server and OSGi

Patterns and Best Practices for Dynamic OSGi Applications

Apache Felix. Richard S. Hall. A Standard Plugin Model for Apache. Atlanta, Georgia U.S.A. November 13th, 2007

OSGi In Action: Creating Modular Applications In Java By Richard Hall, Karl Pauls READ ONLINE

Patterns and Best Practices for dynamic OSGi Applications

Liberate your components with OSGi services

Equinox OSGi: Pervasive Componentization

JSR 277, 291 and OSGi, Oh My! - OSGi and Java Modularity

Tutorial ipojo. 2. Preparation

Introduction to OSGi. Marcel Offermans. luminis

Carsten Ziegeler

Java Modularity Support in OSGi R4. Richard S. Hall ApacheCon (San Diego) December 14 th, 2005

The Definitive Guide to. NetBeans Platform 7. Heiko Bock. Apress*

Scripting Languages in OSGi. Thursday, November 8, 12

Design patterns using Spring and Guice

SAP Edge Services, cloud edition Edge Services Predictive Analytics Service Guide Version 1803

Lab 1 Introduction ipojo Component Model

1.2. Name(s) and address of Document Author(s)/Supplier: Sahoo: 1.3. Date of This Document: 12 July 2008

Adobe Experience Manager

G l a r I m y Presentation on

Using Apache Felix: OSGi best practices. Marcel Offermans luminis

Understanding ClassLoaders WebSphere 5.1, 6.0 and 6.1

Copyright 2016 Pivotal. All rights reserved. Cloud Native Design. Includes 12 Factor Apps

OSGi. Building and Managing Pluggable Applications

Wednesday, June 23, JBoss Users & Developers Conference. Boston:2010

OSGi in Action. Ada Diaconescu

SOA Software Policy Manager Agent v6.1 for WebSphere Application Server Installation Guide

Pro JPA 2. Mastering the Java Persistence API. Apress* Mike Keith and Merrick Schnicariol

Jigsaw and OSGi: What the Heck Happens Now?

Equinox Framework: How to get Hooked

Jim Jackson II Ian Gilman

Building Secure OSGi Applications. Karl Pauls Marcel Offermans. luminis

Contents at a Glance

Oracle BI 12c: Build Repositories

Oracle Data Integrator: Administration and Development Volume I Student Guide

Equinox Project Update

Managing Installations and Provisioning of OSGi Applications. Carsten Ziegeler

SOA Software Platform 7.2 Installation Guide for Windows and UNIX Platforms

foreword to the first edition preface xxi acknowledgments xxiii about this book xxv about the cover illustration

J2EE Development. Course Detail: Audience. Duration. Course Abstract. Course Objectives. Course Topics. Class Format.

StreamSets Control Hub Installation Guide

Cloud-Native Applications. Copyright 2017 Pivotal Software, Inc. All rights Reserved. Version 1.0

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p.

SAS 9.2 Foundation Services. Administrator s Guide

Learning Karaf Cellar

Implementing the Twelve-Factor App Methodology for Developing Cloud- Native Applications

Restlet in Action. Developing RESTful web APIs injava JEROME LOUVEL MANNING THIERRY TEMPLIER THIERRY BOILEAU. Shelter Island

Oracle Data Integrator 11g: Integration and Administration Student Guide - Volume I

Cheat Sheet: Wildfly Swarm

COPYRIGHTED MATERIAL

Richard S. Hall Karl Pauls Stuart McCulloch David Savage

Leverage Rational Application Developer v8 to develop OSGi application and test with Websphere Application Server v8

Adobe Experience Manager Dev/Ops Engineer Adobe Certified Expert Exam Guide. Exam number: 9A0-397

Java Platform, Enterprise Edition 6 with Extensible GlassFish Application Server v3

Lotus Exam IBM Websphere Portal 6.1 Application Development Version: 5.0 [ Total Questions: 150 ]

Modularity for Java and How OSGi Can Help

Oracle BI 11g R1: Build Repositories

Richard S. Hall Karl Pauls Stuart McCulloch David Savage

Sun Java System Application Server 8.1: Administration & Deployment

Acknowledgments Introduction. Part I: Programming Access Applications 1. Chapter 1: Overview of Programming for Access 3

Red Hat Fuse 7.0 Deploying into Apache Karaf

SpringSource dm Server User Guide

Virgo Web Server User Guide

Microsoft. Inside Microsoft. SharePoint Ted Pattison. Andrew Connell. Scot Hillier. David Mann

FlexiNet 2.1 Roundup. Richard Hayton ANSA Consortium

SOA Software Policy Manager Agent v6.1 for tc Server Application Server Installation Guide

OSGi Subsystems from theory to practice Glyn Normington. Eclipse Virgo Project Lead SpringSource/VMware

Tivoli Application Dependency Discovery Manager Version 7.3. Discovery Library Adapter Developer's Guide IBM

object/relational persistence What is persistence? 5

IBM WebSphere Application Server 8. Java EE 6 Feature Packs

Expeditor Client for Desktop. Web Container and Web Applications

Google Cloud Platform for Systems Operations Professionals (CPO200) Course Agenda

Identity Connect Release Notes,,,

Spring Dynamic Modules

SAS 9.4 Foundation Services: Administrator s Guide

IBM Cloud Orchestrator Version Content Development Guide

Oracle Application Express: Administration 1-2

Selftestengine.P questuons P IBM FileNet P8 System Implementation Technical Mastery Test v1

Christopher Frost Virgo Committer Martin Lippert Lead, Spring Development Tools SpringSource, a division of VMware 3rd November 2011

CHAPTER 1: GETTING STARTED WITH ASP.NET 4 1

Red Hat Decision Manager 7.0

Java EE 6: Develop Web Applications with JSF

IBM. Java Applications in CICS. CICS Transaction Server for z/os Version 4 Release 2 SC

Tuscany: Applying OSGi modularity after the fact

Modularity in Java. With OSGi. Alex Docklands.LJC January Copyright 2016 Alex Blewitt

ANGULAR 2.X,4.X + TYPESRCIPT by Sindhu

Oracle Fusion Middleware

Platform SDK Deployment Guide. Platform SDK 8.1.2

Europe on a Disk Geodata Processing with Eclipse and OSGi. Harald Wellmann 10 Nov 2008

CHAPTER 20. Integrating Code Libraries Plug-ins as JARs

Developing and Deploying vsphere Solutions, vservices, and ESX Agents. 17 APR 2018 vsphere Web Services SDK 6.7 vcenter Server 6.7 VMware ESXi 6.

Exam Name: IBM Certified System Administrator - WebSphere Application Server Network Deployment V7.0

Java.. servlets and. murach's TRAINING & REFERENCE 2ND EDITION. Joel Murach Andrea Steelman. IlB MIKE MURACH & ASSOCIATES, INC.

SAS AppDev Studio TM 3.4 Eclipse Plug-ins. Migration Guide

Sonatype CLM - IDE User Guide. Sonatype CLM - IDE User Guide

Is OSGi Modularity Always Worth It? Glyn Normington

COPYRIGHTED MATERIAL. Contents. Introduction. Chapter 1: Welcome to SQL Server Integration Services 1. Chapter 2: The SSIS Tools 21

ORACLE ENTERPRISE MANAGER 10g ORACLE DIAGNOSTICS PACK FOR NON-ORACLE MIDDLEWARE

Transcription:

OSGi in Action CREATING MODULAR APPLICATIONS IN JAVA RICHARD S. HALL KARL PAULS STUART McCULLOCH DAVID SAVAGE 11 MANNING Greenwich (74 w. long.)

contents foreword xiv preface xvii acknowledgments xix about this book xx about the authors xxv PART 1 INTRODUCING OSGI: MODULARITY, LIFECYCLE, AND SERVICES OSGi revealed 3 1.1 The what and why of OSGi 4 Java's modularity limitations 5 Can OSGi help you? 8 1.2 An architectural overview of OSGi 9 The OSGi framework 9 Putting it all together 12 1.3 "Hello, world!" examples 12 Module layer example 12 Lifecycle layer example 14 Service layer example 16 Setting the stage 18

1.4 Putting OSGi in context 19 Java Enterprise Edition 19 Jini 20' NetBeans 20 Java Management Extensions 20 Lightweight containers 21 Java Business Integration 21 JSR277 21 JSR294 22 Service Component Architecture 22.NET 22 1.5 Summary 23 Mastering modularity 24 2.1 What is modularity? 25 Modularity vs. object orientation 25 2.2 Why modularize? 27 2.3 Modularizing a simple paint program 28 2.4 Introducing bundles 31 The bundle's role in physical modularity 32 The bundle's role in logical modularity 33 2.5 Defining bundles with metadata 34 Human-readable information 35 Bundle identification 36 Code visibility 39 Class-search order 48 2.6 Finalizing the paint program design 50 Improving the paint program's modularization 51 Launching the new paint program 52 2.7 OSGi dependency resolution 53 Resolving dependencies automatically 53 Ensuring consistency with uses constraints 59 2.8 Reviewing the benefits of the modular paint program 64 2.9 Summary 68 Learning lifecycle 69 3.1 Introducing lifecycle management 70 What is lifecycle management? 70 Why lifecycle management? 72 3.2 OSGi bundle lifecycle 72 Introducing lifecycle to the paint program 73 The OSGi framework's role in the lifecycle 75 The bundle activator manifest entry 76 Introducing the lifecycle API 77 Lifecycle state diagram 83 Bundle cache and framework restarts 84 3.3 Using the lifecycle API in your bundles 85 Configuring bundles 86 Deploying bundles 88 Inspecting framework state 92 Persisting bundle state 93 Listening for events 96 Bundle suicide 99

3.4 Dynamically extending the paint program 101 3.5 Lifecycle and modularity 108 Resolving bundles 108 Refreshing bundles 110 When updating isn 't updated 114 3.6 Summary 115 A Studying services 117 * 4.1 The what, why, and when of services 118 What is a service? 118- Why use services? 119 When to use services 123 When not to use services 124 Still not sure? 124 4.2 OSGi services in action 125 Publishing a service 126 Finding and binding services 128 4.3 Dealing with dynamics 132 Avoiding common pitfalls 133 Listening for services 136 Tracking services 141 4.4 Using services in the paint example 143 Defining a shape service 144 Publishing a shape service 144 Tracking shape services 145 4.5 Relating services to modularity and lifecycle 146 Why can't I see my service? 147 Can I provide a bundle-specific service? 147' When should 1unget a service? 148 When should I unregister my service? 148 Should I bundle interfaces separately? 149 5 Delving 4.6 Standard services 149 Core services 150 Compendium services 151 4.7 Summary 152 deeper into modularity 154 5.1 Managing your exports 155 Importing your exports 155 Implicit export attributes 158 Mandatory export attributes 160 Export filtering 161 Duplicate exports 162 5.2 Loosening your imports 164 Optional imports 164 Dynamic imports 165 Optional vs. dynamic imports 166 Logging example 167 5.3 Requiring bundles 171 Declaring bundle dependencies 171 Aggregating split packages 173 Issues with bundle dependencies 176

5.4 Dividing bundles into fragments 177 Understanding fragments 177 Using fragments for localization 180 5.5 Dealing with your environment 183 Requiring execution environments 184 Bundling native libraries 185 5.6 Summary 187 PART 2 OSGi IN PRACTICE.,... 189 Moving toward bundles 191 6.1 TurningJARs into bundles 192 Choosing an identity 192 Exporting packages 195 Discovering what to import 199 Embedding vs. importing 203 Adding lifecycle support 204 JAR file to bundle cheat sheet 205 6.2 Splitting an application into bundles 206 Making a mega bundle 206 Slicing code into bundles 216 Loosening things up 221 To bundle or not to bundle? 226 6.3 Summary 229 Testing applications 230 7.1 Migrating tests to OSGi 231 In-container testing 231 Bundling tests 232 Covering all the bases 235 7.2 Mocking OSGi 237 Testing expected behavior 237 Mocking in action 238 Mocking unexpected situations 240 Coping with multithreaded tests 241 Exposing race conditions 243 7.3 Advanced OSGi testing 244 OSGi test tools 245 Running tests on multiple frameworks 246 Unit testing 250 Integration testing 251 Management testing 254 7.4 Summary 257 Debugging applications 258 8.1 Debugging bundles 259 Debugging in action 261 Making things right with HotSwap 266

8.2 Solving class-loading issues 271 ClassNotFoundException vs. NoClassDefFoundError 272 Casting problems 274- Using uses constraints 275' Staying clear of Class.forName() 278 Following the Thread Context Class Loader 280 8.3 Tracking down memory leaks 283 Analyzing OSGi heap dumps 283 8.4 Dangling services 287 Finding a dangling service 287 Protecting against dangling services 288 8.5 Summary 290 Managing bundles 292 9.1 Versioning packages and bundles 293 Meaningful versioning 293 Package versioning 295 Bundle versioning 297 9.2 Configuring bundles 299 Configuration Admin Service 299 Metaiype Service 309 Preferences Service 312 9.3 Starting bundles lazily 314 Understanding activation policies 315 Using activation policies 316 9.4 Summary 317 ~f/i Managing applications 319 JL\J 10.1 Deploying bundles 320 Introducing management agents 320 OSGi Bundle Repository 321 Deployment Admin 330 10.2 Ordering bundle activation 337 Introducing the Start Level Service 338 Using the Start Level Service 339 10.3 Summary 342 PART 3 ADVANCED TOPICS 343 Component models and frameworks 345 11.1 Understanding component orientation 346 What are components? 346 Why do we want components? 348

11.2 OSGi and components 349 OSGi's service-oriented component model 349 Improving upon OSGi's component model 351 Painting with components 355 11.3 Declarative Services 355 Building Declarative Services components 356 Providing services with Declarative Services 357 Consuming services with Declarative Services 359 Declarative Services component lifecycle 364 11.4 Summary 371 Advanced component frameworks 373 12.1 Blueprint Container 374 Blueprint architecture 374 Providing services with Blueprint 375 Consuming services with Blueprint 378 Blueprint component lifecycle 382 Advanced Blueprint features 387 12.2 Apache Felix ipojo 391 Building ipojo components 392 Providing services with ipojo 393 Consuming services with ipojo 395 ipojo component lifecycle 400 Instantiating components with ipojo 404 12.3 Mix and match 408 12.4 Summary 411 Launching and embedding an OSGi framework 412 13.1 Standard launching and embedding 413 Framework API overview 413 Creating a framework instance 415 Configuring a framework 417 Starting a framework instance 419 Stopping a framework instance 420 13.2 Launching the framework 421 Determining which bundles to install 422 Shutting down cleanly 422 Configuring, creating, and starting the framework 423 Installing the bundles 424 Starting the bundles 424 Starting the main bundle 425 Waiting for shutdown 426 13.3 Embedding the framework 427 Inside vs. outside 427 Who's in control? 431 Embedded framework example 432 13.4 Summary 437 Securing your applications 438 14.1 To secure or not to secure 439

14.2 Security:justdoit 440 Java and OSGi security 440 14.3 OSGi-specific permissions 444 PackagePermission 444 BundlePermission 445 Admin- Permission 446 ServicePermission 447 Relative file permissions 448 14.4 Managing permissions with Conditional Permission Admin 449 Conditional permissions 449 Introducing the Conditional Permission Admin Service 450 Bundle location condition 451 Using ConditionalPermissionAdmin 452 Implementing a policy-file reader 456 14.5 Digitally signed bundles 457 Learning the terminology 458 Creating certificates and signing bundles 458 BundleSignerCondition 461 14.6 Local permissions 464 14.7 Advanced permission management 465 Custom conditions overview 465 Date-based condition 466 User-input condition 467 14.8 Bringing it all back home 471 14.9 Summary 475 Web applications and web services 477 15.1 Creating web applications 478 Using the HTTP Service specification 479 Using the Web Applications specification 488 Standard WARs: the Web URL Handler 492 15.2 Providing and consuming web services 493 Providing a web service 494 Consuming a web service 499 Distributing services 502 15.3 Summary 510 appendix A Building bundles 513 appendix B OSGi standard services 528 index 531