About this Book

This is a book about the enterprise OSGi programming model, and it’s also a book about using OSGi in the enterprise. It shows you how to combine OSGi’s elegant, modular, service-oriented approach with Java EE’s well-established persistence, transaction, and web technologies. It guides you through the cases when your project has lots of bits spread all over the network, some new, some old, some that you don’t even recognize, and many that you didn’t write yourself. It’s packed with tips on how to use OSGi in the messy real world, with guidance on tools, building, testing, and integrating with non-OSGi systems and libraries.

Audience

Three groups of developers should find this book interesting. The first is developers who know Java EE, but who want to bring more modularity to their applications by learning OSGi. The second is those who know OSGi, but want to learn how to take advantage of some of Java EE’s higher-level programming models. The last is developers who are familiar with both Java EE and OSGi, but who never knew the two could be combined! We don’t assume knowledge of either Java EE or OSGi, but familiarity with at least one of them will help.

Roadmap

This book is divided into three parts. Part 1 introduces the most important enterprise OSGi technologies: web applications, JNDI lookups of OSGi services, Blueprint dependency injection, JPA persistence, declarative transactions, and application packaging. Part 2 explains how to use these building blocks most effectively with best practices, tools, and a deeper understanding of some subtle areas. Part 3 considers how enterprise OSGi fits in with your existing applications and systems. It covers distribution technologies, migration tips and traps, and server options.

The appendixes provide important OSGi background. If you’re new to OSGi, you may want to skip to the appendixes after reading chapter 1.

Chapter 1 explains what OSGi is, why it’s such an exciting technology, and why it’s so relevant to the enterprise.

Chapter 2 lets you get your hands dirty with real code. It introduces the OSGi sandbox you’ll use to run the samples. You’ll write an OSGi web application and hook it up to backend OSGi services. You’ll use JNDI to connect OSGi services to legacy code, and Blueprint dependency injection to wire together the services.

Chapter 3 introduces JPA persistence and JTA transactions, and shows how to use them in an OSGi environment.

Chapter 4 shows how to group OSGi bundles together into coarser-grained applications.

In part 2, chapter 5 steps back from new technologies and discusses best practices for writing enterprise OSGi applications. It explains how to structure your applications, introduces some new OSGi-centric patterns, and discusses which familiar patterns may not be such a great idea in an OSGi environment.

Chapter 6 investigates OSGi dynamism and Blueprint dependency injection in more depth.

Chapter 7 discusses how to use OBR to dynamically provision application dependencies.

Chapter 8 introduces a range of command-line tools for generating OSGi manifests and building bundles. It also considers how to test OSGi bundles.

Chapter 9 continues the discussion of useful tools by comparing several IDEs that support OSGi.

In part 3, chapter 10 explains how to use distributed OSGi to allow OSGi services to be published and consumed across remote systems.

Chapter 11 discusses your options for migrating non-OSGi legacy code to OSGi. It also discusses technologies for integrating OSGi applications with the non-OSGi legacy code you haven’t yet migrated!

Chapter 12 sets out strategies for handling non-OSGi libraries. It shows how to turn ordinary JARs into bundles and explains how to deal with common problems, such as classloading and logging issues.

Finally, chapter 13 compares the various commercial and open source OSGi runtimes and gives guidance on how you should choose a stack that’s right for you.

Appendix A covers the basics of OSGi. It explains why OSGi is such a necessary technology, and provides grounding in versioning, bundles, bundle lifecycles, and OSGi services. It includes some practical hints on OSGi frameworks and consoles.

Appendix B describes the broader OSGi ecosystem. It explains how the OSGi alliance works and what’s in the various OSGi specifications.

Code downloads

You can download the sample code for this book via a link found on the book’s homepage on the Manning website, www.manning.com/EnterpriseOSGiinAction. The SourceCodeEnterpriseOSGiinAction.zip archive includes source code for an application with a web frontend and a JPA backend, as well as distributed variations. There’s a Maven build that produces bundles and a .eba application that can be installed into an OSGi framework. See section 2.1.2 for instructions on how to assemble a runtime environment in which to run the application.

Author Online

The purchase of Enterprise OSGi in Action includes free access to a forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and other users. You can access and subscribe to the forum at www.manning.com/EnterpriseOSGiinAction. This page provides information on how to get on the forum once you’ve registered, what kind of help is available, and the rules of conduct in the forum.

Manning’s commitment to our readers is to provide a venue where a meaningful dialog between individual readers, and between readers and the authors, can take place. It isn’t a commitment to any specific amount of participation on the part of the authors, whose contributions to the book’s forum remain voluntary (and unpaid). We suggest you try asking the authors some challenging questions, lest their interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

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

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