Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ITT 2017 - Maciek Próchniak - OSGi, Java 9? do we still need modularity in the world of microservices

ITT 2017 - Maciek Próchniak - OSGi, Java 9? do we still need modularity in the world of microservices

Maciek Próchniak talks about Microservices. Microservices architecture is one of the most trendy topics in IT these days. Everyone looks at Netflix, LinkedIn or Zalando and tries to be like them.
It’s all very good. But at heart of this revolution lie some well known ideas on modularity and decoupling.
And guess what? Idea of modular Java applications is also not new. Even term “microservice” has been in use on JVM since many, many years. However, the main technology for modular Java - OSGi - was always struggling to gain proper attention and we’re still waiting for modules in JDK itself.
In this talk, Maciek Próchniak explains why you shouldn’t too easily dismiss both OSGi and Java 9 - in many use cases, with little effort they can give you important benefits, without having to spin hundreds of VMs or containers.

Istanbul Tech Talks

April 03, 2017

More Decks by Istanbul Tech Talks

Other Decks in Programming


  1. Export/Import module mproch.services.order { requires mproch.services.user; exports pl.mproch.services.order.api; } Export-Package:

    pl.mproch.services.order.api; uses:="javax.ws.rs,javax.ws.rs.core";version="1.0.0" Import-Package: javax.ws.rs;version="[2.0,3)"
  2. OSGi? Error executing command: Error restarting bundles: Unable to start

    bundle 278: Uses constraint violation. Unable to resolve resource demo-persistence-jpa [demo-persistence-jpa [278](R 278.0)] because it is exposed to package 'javax.persistence' from resources javax.persistence [javax.persistence [248](R 248.0)] and org.apache.geronimo.specs.geronimo-jpa_2.0_spec [org.apache.geronimo.specs.geronimo-jpa_2.0_spec [266](R 266.0)] via two dependency chains. Chain 1: demo-persistence-jpa [demo-persistence-jpa [278](R 278.0)] import: (&(osgi.wiring.package=javax.persistence)(version>=2.1.0)) | export: osgi.wiring.package: javax.persistence javax.persistence [javax.persistence [248](R 248.0)] Chain 2: demo-persistence-jpa [demo-persistence-jpa [278](R 278.0)] import: (osgi.wiring.package=org.hibernate.proxy) | export: osgi.wiring.package=org.hibernate.proxy; uses:=javax.persistence com.springsource.org.hibernate [com.springsource.org.hibernate [230](R 230.0)] import: (&(osgi.wiring.package=javax.persistence)(version>=1.0.0)(!(version>=2.0.0))) | export: osgi.wiring.package: javax.persistence org.apache.geronimo.specs.geronimo-jpa_2.0_spec [org.apache.geronimo.specs.geronimo-jpa_2.0_spec [266](R 266.0)] Unresolved requirements: [[demo-persistence-jpa [278](R 278.0)] osgi.wiring.package; (osgi.wiring.package=org.hibernate.proxy)]
  3. Java 9? module UserModule { provides pl.mp.user.api.UserService with pl.mp.user.impl.DbUserService; }

    module OrderModule { requires UserModule; uses pl.mp.user.api.UserService; } ServiceLoader<UserService> services = ServiceLoader.load(UserService.class); services.iterator()
  4. Context separation @Singleton @OsgiServiceProvider public class UserService { } public

    class OrderService { @OsgiService @Inject UserService userService }
  5. Lifecycle? @Singleton public class UserService { @PostConstruct public void init()

    { } } @Component public class UserService { @Activated @Updated public void init() { } }