Search code examples
jrebel

jRebel, is there an event that jRebel triggers when it reloads classes that one can listen to?


It would be real handy if one could listen to class reloads in jRebel to reload for instance static variables when one needs to, for instance in development mode.

Is this possible?


Solution

  • Depends on your exact requirements. If it is enough for you to do something with the single static class that is reloaded, then you can implement the following method in that class:

      public static void __rebelReload(){
        // do whatever stuff you want with the static state
      }
    

    After the class is reloaded, JRebel will call this method.

    However, if the static state is scattered across the application, you may want to implement a custom plugin, which is just a bit more complicated to do.