Reloading Java Applications Like A Pro

Reloading Java Applications Like A Pro

1bc80e2eee2adeaa8bb577798d92e9d0?s=128

Anton Arhipov

March 14, 2013
Tweet

Transcript

  1. 5.

    package everything into WAR/EAR rackage modules into JARs compile classes

    copy static resources resolve dependencies build
  2. 7.

    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. 8.

    “…I  know  about  JRebel,  but  I  cannot   pay  for

     it,  so  I  tried  Maven…”                                                                                        -­‐  Stackoverflow  
  4. 10.

    package everything into WAR/EAR rackage modules into JARs compile classes

    copy static resources resolve dependencies build
  5. 11.

    package everything into WAR/EAR rackage modules into JARs compile classes

    copy static resources resolve dependencies build
  6. 17.

    MyObject   MyObject.class   OldClassLoader   NewClassLoader   MyObject.class  

    MyObject   Recreate  object   naiive class reloading
  7. 18.

    Classes Libraries OldClassLoader NewClassLoader Sevlet New Classes New Libraries Sevlet

    Session Session init()   App State App State serialize/deserialize
  8. 20.

    MyObject MyObject.class   OldClassLoader Code   101000101   100010010  

    Debugger HotSwap   New  code   111000100   101010010   New  code   111000100   101010010   hotswap Make  changes  
  9. 21.

    MyObject MyObject.class   OldClassLoader Code   101000101   100010010  

    New  code   111000100   101010010   JRebel   Framework   ConfiguraJon   (XML,  annotaJons,..)   jrebel Make  changes  
  10. 22.

    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. 23.
  12. 31.
  13. 32.

    application reloading is hard • requires more than just class reloading

    • reloading of different components should appear in particular order • bootstrapping
  14. 34.

    jrebel for java ee • JSP • JAX-RS • JAX-WS • JSF • CDI • JPA

    • EJB • Jasper • Jersey, CXF • Metro • Mojarra, MyFaces • Weld • EclipseLink, OpenJPA, Hibernate
  15. 37.

    Remote Deployments 0. make a change 1. git commit; git

    push 2. mvn clean install 3. deploy.sh