OSGi Community Event 2017 Presentation by Tim Ward [Paremus]
REST microservices are a powerful tool for composing large-scale systems, and now, with the new features of OSGi R7, it has never been simpler to create a modular microservice. Combining the new features in Declarative Services, the JAX-RS Whiteboard, Transaction Control and PushStreams we can create a simple, transactional, persistent, streaming microservice with a minimum of code and a maximum of function.
This talk will use practical code examples to show how new OSGi R7 features can save you time and effort when building microservices, letting you focus on business logic, not boilerplate.
Over the last decade there has been a significant shift in the way that many computer programs are written. The focus has changed from building larger, more monolithic applications that provide a single high-level function, to composing these high-level behaviours from groups of smaller, distributed services. This is generally known as a “microservice” architecture, indicating that the services are smaller and lighter weight than typical web services. With the new features in Release 7 OSGi is a better platform for building your microservices than ever before.
The Declarative Services specification is the ultimate in OSGi injection containers. It supports simple, flexible dependency injection using OSGi services; automatic lifecycle management based upon the availability of configuration and dependencies; and a concise, type-safe set of annotations to define your components. The latest round of Declarative Services updates includes new support for constructor injection, activation fields, and a host of other usability improvements designed to make your components even leaner.
The standard for REST microservices in Java is known as JAX-RS. JAX-RS provides a simple annotation-based model in which POJOs can have their methods mapped to RESTful service invocations. Ideal JAX-RS resources share many features with OSGi services, in that they provide a way for machines (or processes within a machine) to interact with one another through a defined contract. This synergy between JAX-RS resources and OSGi services is the driver for the OSGi JAX-RS whiteboard service, allowing OSGi services to be transparently exposed using JAX-RS.
Transaction management is a delicate balance between trying to take away error-prone boilerplate without replacing it entirely with magic. The problem with relying on magic is that the resulting system ends up being more complex to understand, not less. OSGi Transaction Control uses Java’s new functional APIs to simplify and minimise transaction management code, providing generic resource and transaction management in a concise, type-safe way.
OSGi Push Streams are a powerful new take on asynchronous event processing pipelines based on the Java Stream API. ....