Cover image for Building Modular Cloud Apps with OSGi

Book description

If you’re an experienced Java developer in the enterprise, this practical, hands-on book shows you how to use OSGi to design, develop, and deploy modular cloud applications. You’ll quickly learn how to use OSGi, through concise code examples and a set of best practices derived from the authors’ experiences with real-world projects.

Table of Contents

  1. Dedication
  2. Special Upgrade Offer
  3. Preface
    1. Who Should Read This Book
    2. How This Book Is Organized
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. How to Contact Us
    7. Acknowledgments
  4. I. Introducing Modularity in Java
    1. 1. Modularity Introduction
      1. Dealing with Increasing Complexity
      2. Divide and Conquer
      3. Service Oriented Architecture All Over Again?
      4. A Better Look at Modularity and What It Really Means
        1. Design Time Modularity
        2. Runtime Modularity
      5. Modularity Solutions
        1. OSGi
        2. Jigsaw
        3. JBoss Modules
        4. Maven
      6. Choosing a Solution: OSGi
        1. What Is OSGi?
        2. OSGi in the Real World
      7. Tooling
        1. Bndtools
        2. Maven with the BND Maven Plug-in
        3. Eclipse Tycho
        4. NetBeans and IntelliJ
    2. 2. Basic Concepts of OSGi
      1. Hiding Implementations
      2. Import Package Myths
      3. Depending on Other Modules
      4. Service Dynamics
      5. The Bundle Format
        1. Bundle-SymbolicName
        2. Bundle-Name
        3. Bundle-Version
        4. Import-Package
        5. Export-Package
        6. Bundle-Activator
      6. Running an OSGi Application
      7. The Framework Lifecycle
    3. 3. Creating the First OSGi Application
      1. Prerequisites
      2. Getting Started
      3. Creating an API Bundle
      4. Creating an OSGi Service
      5. Running the Code
      6. Using the Agenda Service
      7. Service Instances
      8. Understanding Service Dynamics
        1. Services and Bundle States
        2. Debugging Services
        3. Having Multiple Service Implementations
        4. Service Properties
        5. Service Ranking
        6. Service Registration and Deregistration Callbacks
        7. Injecting Multiple Service Implementations and the Whiteboard Pattern
        8. Lifecycle Callbacks
        9. Injecting BundleContext and DependencyManager
    4. 4. Advanced OSGi
      1. Semantic Versioning
        1. Provider and Consumer Types
        2. Baselining in Bndtools
        3. Semantic Bundle Versioning
      2. Integration Testing
        1. Writing Integration Tests
        2. Running Integration Tests
      3. Configuring Services
        1. Managed Services
        2. Configuring a Managed Service
        3. Required Configuration
        4. Managed Service Factories
        5. MetaType
        6. Providing Configuration
      4. Log Service
        1. Installing and Using the LogService
        2. Logging Performance
      5. Extender Pattern
      6. Event Admin
        1. Using Event Admin
      7. Aspect Services
      8. The Bundle Cache
    5. 5. Pointers and Pitfalls
      1. Better Understanding OSGi Specifications
      2. Require Bundle
      3. Fragment Bundles
      4. Loading Extra System Packages
      5. Profilers, Coverage Tools, and Bootpath Delegation
      6. Dealing with Non-OSGi Libraries
      7. Transitive Dependencies
      8. Classloading Problems in Libraries and Frameworks
        1. Passing the Bundle Classloader Manually
        2. Handling Classpath Scanning
      9. The Low-Level Service API
        1. Registering Services
        2. Using Services
        3. Service Tracker
      10. Dynamic Classloading
        1. DynamicImport-Package
        2. Optional Import-Package
  5. II. Developing Cloud Applications
    1. 6. Cloud Application Architecture
      1. Technology Stack
      2. The Amdatu Project
      3. The Layered Architecture
      4. Inside a Bundle
      5. API Bundles
      6. Separation of Concerns
      7. Services Are Responsible for Their Own Data
      8. Bndtools Project Structure
      9. Comparing with SOA Again
      10. Remoting
    2. 7. Architectural Capabilities
      1. Maintainability
      2. Extensibility
      3. Scalability
      4. Testability
    3. 8. Creating Web Applications
      1. Modular Web Applications
      2. HTTP Service
        1. Taking It One Step Further with Servlets
        2. Adding Filters into the Mix
      3. Handling Web Resources Automatically
      4. Rethinking Web Applications
      5. RESTful Web Services
        1. Getting Started
        2. Implementing an Agenda Resource
        3. Extending the Agenda Resource
        4. Simplified Object Mapping
        5. Self-Documenting RESTful Endpoints
        6. Modularizing RESTful Resources
      6. Modular User Interfaces Using HTML 5
      7. Token Based Security
        1. Using the Token Provider
      8. Web Application Bundles
      9. OpenSocial
        1. Getting Started
        2. Creating Gadgets
    4. 9. Persistence
      1. Relational Databases
        1. JDBC
        2. Object Relational Mapping with JPA
      2. NoSQL
        1. Document Stores
        2. Using MongoDB as a Document Store
        3. Getting Started
        4. Implementing a Persistent Service
        5. Using the MongoDB Query System
        6. Taking It Back to the Web
  6. III. Deploying Applications in the Cloud
    1. 10. Deployment
      1. Understanding OSGi Runtimes
      2. Choosing an OSGi Framework for Deployment
      3. IaaS versus PaaS versus SaaS
      4. A Modular PaaS
      5. Apache ACE
        1. Installing Apache ACE
        2. Starting Deployment Targets
      6. Creating a Deployment
        1. Incremental Updates
        2. Deploying Configuration
        3. Parameterized Configuration
        4. Solving Deployment Issues
        5. Configuring the Apache ACE Launcher
      7. Autoscaling
    2. 11. Alternative Deployment Methods
      1. Packaging an Application as an Executable JAR
      2. Application Servers
        1. Oracle GlassFish Application Server
          1. Using Apache ACE to provision GlassFish
          2. Using the OSGi shell
          3. Interacting with GlassFish Java EE APIs
          4. EJB and JPA
          5. Web Application Bundles and JAX-RS
          6. GlassFish versus a plain OSGi container
        2. RedHat JBoss Application Server
        3. IBM WebSphere® Application Server
        4. Apache Karaf
        5. Eclipse Virgo
  7. A. Example Application
    1. Introduction
    2. Finding and Running the Source Code
    3. Layered View
    4. Component View
    5. Development View
    6. Modularized Frontend
    7. Authentication
    8. Configuration Admin
    9. Scheduled Jobs
    10. Event Admin
    11. Testing
  8. Index
  9. About the Authors
  10. Colophon
  11. Special Upgrade Offer
  12. Copyright