Building Modular Cloud Apps with OSGi
Paul Bakker
Bert Ertman
Beijing Cambridge Farnham Kln Sebastopol Tokyo
Dedication
To Qiushi, my love, for supporting all my crazy ideas and always being there for me.
Paul Bakker
To Jorien, my incredible wife, and to Amber, my beautiful and joyful daughter. Thank you girls for supporting me throughout my career and for putting up with me. I love you!
Bert Ertman
Special Upgrade Offer
If you purchased this ebook directly from oreilly.com, you have the following benefits:
DRM-free ebooksuse your ebooks across devices without restrictions or limitations
Multiple formatsuse on your laptop, tablet, or phone
Lifetime access, with free updates
Dropbox syncingyour files, anywhere
If you purchased this ebook from another retailer, you can upgrade your ebook to take advantage of all these benefits for just $4.99. to access your ebook upgrade.
Please note that upgrade offers are not available from sample content.
Preface
The increasing complexity of software systems, together with the agile way in which we develop and evolve them today, demand an approach that makes the architecture of such systems deal with change. The solution to this challenge is called modularity . Modularity is a core design principle that makes code easier to understand and maintain by splitting it into small, isolated modules. This is not a new concept, but becomes more relevant each day. A modular code base lets us change, refactor, or simply replace code of modules without breaking other parts of the system. This makes modularity the ultimate agile tool.
Bringing modularity from the design to the runtime is not always easy and straightforward and cannot be done with plain Java alone. The only mature modularity solution for Java is OSGi. Over the years, OSGi has had the reputation of being too complex and difficult to use. Recently a lot has changed in the area of tooling and frameworks, however, bringing it on par with the development experience of traditional development stacks. With this we can focus on writing code while keeping an architectural focus on modularity.
This book describes how to apply those tools and techniques available today, and gives pragmatic insights into getting up and running with the required technology in no time. Using easy to understand, concise, but real-world code samples, we explore the application of modularity toward a new breed of web applications; software as a service over the Internet, more affectionately known as cloud applications . Along the way, we address typical cloud-age topics such as RESTful Web Services, NoSQL, Provisioning, Elasticity, Auto-Scaling, Hot Updates, and Automated Failover.
Who Should Read This Book
Primarily, this book is targeted to experienced enterprise Java developers who have a keen interest in modularity and who are looking for solutions to overcome some of todays most advanced software development problems: how to deal with change and how to manage complexity in a code base. The authors of this book use the tools and techniques described throughout the book in everyday development and have put some sophisticated cloud applications in production using them. A significant part of what you will learn here is based upon OSGi. We will focus on practical advice, rather than the more theoretical approach commonly found in other books and resources.
The book will also be useful to developers who have tried using OSGi in the past, but for some reason got stuck. Because OSGi is not a product owned by a single vendor, it is sometimes hard to find hands-on, to-the-point information on how to get things working. To those readers, this book can be an approachable and practical guide to become unstuck and get things going again. By no means is this book a complete OSGi reference, but it does contain everything that you need to know in order to build sophisticated applications in the cloud age.
How This Book Is Organized
This book is organized into three parts. deals with deploying these applications to production and setting up advanced cloud infrastructure capabilities such as auto-scaling and failover.
Additionally, describes an example application that puts everything from this book together in a showcase. The code of this application is hosted online, and the appendix contains instructions on how to get it.
Conventions Used in This Book
The following typographical conventions are used in this book:
Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords. Constant width bold
Shows commands or other text that should be typed literally by the user. Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Tip
This icon signifies a tip, suggestion, or general note.
Warning
This icon indicates a warning or caution.
Using Code Examples
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless youre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from OReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your products documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: Building Modular Cloud Apps with OSGi by Paul Bakker and Bert Ertman (OReilly). Copyright 2013 Paul Bakker and Bert Ertman, 978-1-449-34515-0.
You can download the full source code from .
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .
Safari Books Online
Note
Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the worlds leading authors in technology and business.
Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.
Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like OReilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.