Coder Social home page Coder Social logo

benze / jrebel-hooks-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from atsu85/jrebel-hooks-plugin

0.0 1.0 0.0 6 KB

JRebel Plugin that invokes JRebel hooks in application to notify when classes are loading and reloaded by JRebel to allow application specific actions to be performed

License: Apache License 2.0

Java 100.00%

jrebel-hooks-plugin's Introduction

![Release](https://img.shields.io/github/release/atsu85/jrebel-hooks-plugin.svg?label=latest release is)

jrebel-hooks-plugin

JRebel Plugin that invokes JRebel hooks in application to notify when classes are loading and reloaded by JRebel to allow application specific actions to be performed. This plugin can be used to reinitialize some application configuration, that may be created on application startup or cached after configuration has been created.

Using this plugin

Download the plugin

Download the plugin jar file and save it.

Configure JRebel to use this plugin

Add following system properties to the application launch configuration (in addition to JRebel configuration parameters):

-Drebel.jrebel-hooks-plugin=true
-Drebel.plugins=/path/to/jrebel-hooks-plugin-v1.0.0.jar

Note: You can also enable this plugin for all applications launched with JRebel if You put them to ~/.jrebel/jrebel.properties, but then don't forget to remove the "-D" prefix

If the plugin is configured properly You should see log entry in ~/.jrebel/jrebel.log file, containing: "initializing jrebel-hooks-plugin"

Create class that is called after class is loaded or reloaded by JRebel

package org.jrebelhooks;

/**
 * Used by jrebel-hooks-plugin to allow application to perform custom actions after class is loaded or reloaded by JRebel
 */
public class JRebelHooks {

  /**
   * Invoked by jrebel-hooks-plugin (using reflection) after class is loaded
   * @param klass - class that was loaded
   */
  public static void classLoaded(Class<?> klass) throws Exception {
    System.out.println("classLoaded " + klass);
    // TODO do smth useful after class is loaded
  }

  /**
   * Invoked by jrebel-hooks-plugin (using reflection) after class is reloaded
   * @param klass - class that was reloaded by JRebel
   */
  public static void classReloaded(Class<?> klass) throws Exception {
    System.out.println("classReloaded " + klass);
    // TODO do smth useful after class is reloaded by JRebel
  }

}

Note: names of the package and class must be exactly the same so that jrebel-hooks-plugin can find class that contains the methods to be called after class is loaded/reloaded. Also the method signatures must match the methods shown above.

After starting application with this class and jrebel-hooks-plugin You should see log entry in ~/.jrebel/jrebel.log file, containing: "jrebel-hooks-plugin is enabled for classloader"

Debugging

If it looks like this plugin doesn't work, make sure You have configured it properly (see above: "Using this plugin") and created class listed above.

jrebel-hooks-plugin's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.