Git Product home page Git Product logo

hotswap's Introduction

Hotswap

Dynamic class reloading and object state migration for the JVM

About

HotSwap provides a robust library for updating the implementation of an object at runtime, otherwise known as hotswapping. This is achieved through recompilation, dynamic class reloading, and object state migration throughout the life of an application. It is fundamentally useful for runtime incremental development of an application.

Example

// Assume you have an interface 'Transformer' in your classpath
// in src/main/java.  It has a single method 'Object transform(Object)'.
// Further assume that 'MatrixTransformer' is an implementation of
// Transformer in src/test/java.

// Create a compiler instance which acts as a factory for
// ProxyClass objects.
ProxyCompiler compiler = new KJavacCompiler();
compiler.setClasspath("target/classes");
compiler.setSourcepath("src/test/java");
compiler.setDestinationpath("target/hotswap");

// Create a ProxyClass.  A monitor is setup that watches for
// source files changes in the file.
ProxyClass cls = compiler.load("org.example.MatrixTransformer");

// Create a Proxy object that implements Transformer
Transformer t = (Transformer)cls.newInstance();

// Before the transform method is actually invoked, a check is performed
// to see if the source file has changed.  If so, the class is
// recompiled and the object instance is swapped out.  The result
// object will have been generated by the updated code.  Cool!
Object input = ...
Object output = t.transform(input);

LICENSE

MIT

Requirements

WHen it was originally written in 2001, the reqs were JDK1.2 for basic use, JDK1.3 for use of Dynamic Proxy Classes. With the ProxyClassWatcher implementation, JDK 1.7 is required (java.nio.file.WatchService). If necessary, a custom alternative ProxyClassMonitor implementation can be provided, removing the JDK1.7 requirement.

Download

Maven central

Installation

Include the hotswap.jar in your classpath. You also need to include $JAVA_HOME/lib/tools.jar in the classpath in order to use KJavacCompiler.

# Documentation

The manual is the org.inxar.hotswap.* package description apidocs.

hotswap's People

Contributors

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