Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Foreword

Preface

Acknowledgments

About this Book

About the Authors

1. Introducing OSGi: modularity, lifecycle, and services

Chapter 1. OSGi revealed

1.1. The what and why of OSGi

1.1.1. Java’s modularity limitations

Low-Level Code Visibility Control

Error-Prone Class Path Concept

Limited Deployment and Management Support

1.1.2. Can OSGi help you?

1.2. An architectural overview of OSGi

1.2.1. The OSGi framework

1.2.2. Putting it all together

1.3. “Hello, world!” examples

1.3.1. Module layer example

1.3.2. Lifecycle layer example

1.3.3. Service layer example

1.3.4. Setting the stage

1.4. Putting OSGi in context

1.4.1. Java Enterprise Edition

1.4.2. Jini

1.4.3. NetBeans

1.4.4. Java Management Extensions

1.4.5. Lightweight containers

1.4.6. Java Business Integration

1.4.7. JSR 277

1.4.8. JSR 294

1.4.9. Service Component Architecture

1.4.10. .NET

1.5. Summary

Chapter 2. Mastering modularity

2.1. What is modularity?

2.1.1. Modularity vs. object orientation

2.2. Why modularize?

2.3. Modularizing a simple paint program

2.4. Introducing bundles

2.4.1. The bundle’s role in physical modularity

2.4.2. The bundle’s role in logical modularity

2.5. Defining bundles with metadata

2.5.1. Human-readable information

2.5.2. Bundle identification

2.5.3. Code visibility

2.5.4. Class-search order

2.6. Finalizing the paint program design

2.6.1. Improving the paint program’s modularization

2.6.2. Launching the new paint program

2.7. OSGi dependency resolution

2.7.1. Resolving dependencies automatically

2.7.2. Ensuring consistency with uses constraints

2.8. Reviewing the benefits of the modular paint program

2.9. Summary

Chapter 3. Learning lifecycle

3.1. Introducing lifecycle management

3.1.1. What is lifecycle management?

3.1.2. Why lifecycle management?

3.2. OSGi bundle lifecycle

3.2.1. Introducing lifecycle to the paint program

3.2.2. The OSGi framework’s role in the lifecycle

3.2.3. The bundle activator manifest entry

3.2.4. Introducing the lifecycle API

3.2.5. Lifecycle state diagram

3.2.6. Bundle cache and framework restarts

3.3. Using the lifecycle API in your bundles

3.3.1. Configuring bundles

3.3.2. Deploying bundles

3.3.3. Inspecting framework state

3.3.4. Persisting bundle state

3.3.5. Listening for events

3.3.6. Bundle suicide

3.4. Dynamically extending the paint program

3.5. Lifecycle and modularity

3.5.1. Resolving bundles

3.5.2. Refreshing bundles

3.5.3. When updating isn’t updated

3.6. Summary

Chapter 4. Studying services

4.1. The what, why, and when of services

4.1.1. What is a service?

4.1.2. Why use services?

4.1.3. When to use services

4.1.4. When not to use services

4.1.5. Still not sure?

4.2. OSGi services in action

4.2.1. Publishing a service

4.2.2. Finding and binding services

4.3. Dealing with dynamics

4.3.1. Avoiding common pitfalls

4.3.2. Listening for services

4.3.3. Tracking services

4.4. Using services in the paint example

4.4.1. Defining a shape service

4.4.2. Publishing a shape service

4.4.3. Tracking shape services

4.5. Relating services to modularity and lifecycle

4.5.1. Why can’t I see my service?

4.5.2. Can I provide a bundle-specific service?

4.5.3. When should I unget a service?

4.5.4. When should I unregister my service?

4.5.5. Should I bundle interfaces separately?

4.6. Standard services

4.6.1. Core services

4.6.2. Compendium services

Http Service

Event Admin Service

4.7. Summary

Chapter 5. Delving deeper into modularity

5.1. Managing your exports

5.1.1. Importing your exports

5.1.2. Implicit export attributes

5.1.3. Mandatory export attributes

5.1.4. Export filtering

5.1.5. Duplicate exports

5.2. Loosening your imports

5.2.1. Optional imports

5.2.2. Dynamic imports

5.2.3. Optional vs. dynamic imports

5.2.4. Logging example

5.3. Requiring bundles

5.3.1. Declaring bundle dependencies

5.3.2. Aggregating split packages

5.3.3. Issues with bundle dependencies

5.4. Dividing bundles into fragments

5.4.1. Understanding fragments

5.4.2. Using fragments for localization

5.5. Dealing with your environment

5.5.1. Requiring execution environments

5.5.2. Bundling native libraries

5.6. Summary

2. OSGi in practice

Chapter 6. Moving toward bundles

6.1. Turning JARs into bundles

6.1.1. Choosing an identity

6.1.2. Exporting packages

6.1.3. Discovering what to import

6.1.4. Embedding vs. importing

6.1.5. Adding lifecycle support

6.1.6. JAR file to bundle cheat sheet

6.2. Splitting an application into bundles

6.2.1. Making a mega bundle

6.2.2. Slicing code into bundles

6.2.3. Loosening things up

6.2.4. To bundle or not to bundle?

6.3. Summary

Chapter 7. Testing applications

7.1. Migrating tests to OSGi

7.1.1. In-container testing

7.1.2. Bundling tests

7.1.3. Covering all the bases

7.2. Mocking OSGi

7.2.1. Testing expected behavior

7.2.2. Mocking in action

7.2.3. Mocking unexpected situations

7.2.4. Coping with multithreaded tests

7.2.5. Exposing race conditions

7.3. Advanced OSGi testing

7.3.1. OSGi test tools

7.3.2. Running tests on multiple frameworks

7.3.3. Unit testing

7.3.4. Integration testing

7.3.5. Management testing

7.4. Summary

Chapter 8. Debugging applications

8.1. Debugging bundles

8.1.1. Debugging in action

8.1.2. Making things right with HotSwap

8.2. Solving class-loading issues

8.2.1. ClassNotFoundException vs. NoClassDefFoundError

8.2.2. Casting problems

8.2.3. Using uses constraints

8.2.4. Staying clear of Class.forName()

8.2.5. Following the Thread Context Class Loader

8.3. Tracking down memory leaks

8.3.1. Analyzing OSGi heap dumps

8.4. Dangling services

8.4.1. Finding a dangling service

8.4.2. Protecting against dangling services

8.5. Summary

Chapter 9. Managing bundles

9.1. Versioning packages and bundles

9.1.1. Meaningful versioning

9.1.2. Package versioning

9.1.3. Bundle versioning

9.2. Configuring bundles

9.2.1. Configuration Admin Service

9.2.2. Metatype Service

9.2.3. Preferences Service

9.3. Starting bundles lazily

9.3.1. Understanding activation policies

9.3.2. Using activation policies

9.4. Summary

Chapter 10. Managing applications

10.1. Deploying bundles

10.1.1. Introducing management agents

10.1.2. OSGi Bundle Repository

10.1.3. Deployment Admin

10.2. Ordering bundle activation

10.2.1. Introducing the Start Level Service

10.2.2. Using the Start Level Service

10.3. Summary

3. Advanced topics

Chapter 11. Component models and frameworks

11.1. Understanding component orientation

11.1.1. What are components?

11.1.2. Why do we want components?

11.2. OSGi and components

11.2.1. OSGi’s service-oriented component model

11.2.2. Improving upon OSGi’s component model

11.2.3. Painting with components

11.3. Declarative Services

11.3.1. Building Declarative Services components

11.3.2. Providing services with Declarative Services

11.3.3. Consuming services with Declarative Services

11.3.4. Declarative Services component lifecycle

11.4. Summary

Chapter 12. Advanced component frameworks

12.1. Blueprint Container

12.1.1. Blueprint architecture

12.1.2. Providing services with Blueprint

12.1.3. Consuming services with Blueprint

12.1.4. Blueprint component lifecycle

12.1.5. Advanced Blueprint features

12.2. Apache Felix iPOJO

12.2.1. Building iPOJO components

12.2.2. Providing services with iPOJO

12.2.3. Consuming services with iPOJO

12.2.4. iPOJO component lifecycle

12.2.5. Instantiating components with iPOJO

12.3. Mix and match

12.4. Summary

Chapter 13. Launching and embedding an OSGi framework

13.1. Standard launching and embedding

13.1.1. Framework API overview

13.1.2. Creating a framework instance

13.1.3. Configuring a framework

13.1.4. Starting a framework instance

13.1.5. Stopping a framework instance

13.2. Launching the framework

13.2.1. Determining which bundles to install

13.2.2. Shutting down cleanly

13.2.3. Configuring, creating, and starting the framework

13.2.4. Installing the bundles

13.2.5. Starting the bundles

13.2.6. Starting the main bundle

13.2.7. Waiting for shutdown

13.3. Embedding the framework

13.3.1. Inside vs. outside

13.3.2. Who’s in control?

13.3.3. Embedded framework example

13.4. Summary

Chapter 14. Securing your applications

14.1. To secure or not to secure

14.2. Security: just do it

14.2.1. Java and OSGi security

14.3. OSGi-specific permissions

14.3.1. PackagePermission

14.3.2. BundlePermission

14.3.3. AdminPermission

14.3.4. ServicePermission

14.3.5. Relative file permissions

14.4. Managing permissions with Conditional Permission Admin

14.4.1. Conditional permissions

14.4.2. Introducing the Conditional Permission Admin Service

14.4.3. Bundle location condition

14.4.4. Using ConditionalPermissionAdmin

14.4.5. Implementing a policy-file reader

14.5. Digitally signed bundles

14.5.1. Learning the terminology

14.5.2. Creating certificates and signing bundles

14.5.3. BundleSignerCondition

14.6. Local permissions

14.7. Advanced permission management

14.7.1. Custom conditions overview

14.7.2. Date-based condition

14.7.3. User-input condition

14.8. Bringing it all back home

14.9. Summary

Chapter 15. Web applications and web services

15.1. Creating web applications

15.1.1. Using the HTTP Service specification

15.1.2. Using the Web Applications specification

15.1.3. Standard WARs: the Web URL Handler

15.2. Providing and consuming web services

15.2.1. Providing a web service

15.2.2. Consuming a web service

15.2.3. Distributing services

15.3. Summary

Appendix A. Building bundles

A.1. Building with Ant

A.1.1. Introducing the bnd tool

A.1.2. Headers

A.1.3. Directives

A.1.4. Variables and macros

A.1.5. Choosing a version policy

A.1.6. Mending split packages

A.2. Building with Maven

A.2.1. Introducing the maven-bundle-plugin

A.2.2. Going undercover

A.2.3. Embedding dependencies

A.2.4. Deploying artifacts to OBR

A.2.5. Bundling non-JAR projects

A.3. For your consideration

A.3.1. Eclipse PDE

A.3.2. Apache Felix Sigil

A.3.3. Eclipse bndtools

A.3.4. IDEA Osmorc

A.3.5 NetBeans Netisgo

A.3.6. Maven Tycho

A.3.7. Spring Bundlor

Appendix B. OSGi standard services

B.1. Core OSGi services

B.2. Compendium OSGi services

B.3. Enterprise OSGi services

Index

List of Figures

List of Tables

List of Listings

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.27.72