Reloading Java Applications Like A Pro

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

Reloading Java Applications Like A Pro

Anton Arhipov

March 14, 2013

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

40 slides
  1. package everything into WAR/EAR rackage modules into JARs compile classes

    copy static resources resolve dependencies build
  2. public class Launcher { public static void main(String[] args) {

    Server server = new Server(); SelectChannelConnector connector = new SelectChannelConnector(); connector.setPort(8080); server.addConnector(connector); WebAppContext context = new WebAppContext("war", "/"); server.setHandler(context); server.start(); } } jetty launcher
  3. “…I  know  about  JRebel,  but  I  cannot   pay  for

     it,  so  I  tried  Maven…”                                                                                        -­‐  Stackoverflow  
  4. package everything into WAR/EAR rackage modules into JARs compile classes

    copy static resources resolve dependencies build
  5. package everything into WAR/EAR rackage modules into JARs compile classes

    copy static resources resolve dependencies build
  6. MyObject   MyObject.class   OldClassLoader   NewClassLoader   MyObject.class  

    MyObject   Recreate  object   naiive class reloading
  7. Classes Libraries OldClassLoader NewClassLoader Sevlet New Classes New Libraries Sevlet

    Session Session init()   App State App State serialize/deserialize
  8. MyObject MyObject.class   OldClassLoader Code   101000101   100010010  

    Debugger HotSwap   New  code   111000100   101010010   New  code   111000100   101010010   hotswap Make  changes  
  9. MyObject MyObject.class   OldClassLoader Code   101000101   100010010  

    New  code   111000100   101010010   JRebel   Framework   ConfiguraJon   (XML,  annotaJons,..)   jrebel Make  changes  
  10. HotSwap   JRebel   Changing  method  bodies   +  

    +   Adding/removing  methods   -­‐   +   Adding/removing  constructors   -­‐   +   Adding/removing  fields   -­‐   +   Adding/removing  classes   -­‐   +   Adding/removing  annotaJons   -­‐   +   Replacing  superclass   -­‐   -­‐   Adding/removing  implemented   interfaces   -­‐   -­‐   jrebel vs hotswap
  11. application reloading is hard • requires more than just class reloading

    • reloading of different components should appear in particular order • bootstrapping
  12. jrebel for java ee • JSP • JAX-RS • JAX-WS • JSF • CDI • JPA

    • EJB • Jasper • Jersey, CXF • Metro • Mojarra, MyFaces • Weld • EclipseLink, OpenJPA, Hibernate
  13. Remote Deployments 0. make a change 1. git commit; git

    push 2. mvn clean install 3. deploy.sh

More Decks by Anton Arhipov

Other Decks in Programming