JavaJava
Using auto Java compilation and change detection
Home > Books > Solutions Developer Guide > Scripting Languages > Java

Rate this page:
Really useful
Satisfactory
Not helpful
Confusing
Incorrect
Unsure
Extra comments:


NetKernel supports dynamic compilation of Java. Changes made to Java source code can be detected and the code compiled and executed seamlessly, just as if Java were a dynamic language.

Enabling Dynamic Compilation for Java

Dynamic Java compilation is configured on a per-module basis as follows:

  1. Ensure you have a Dynamic Compilation Provider set in the Kernel Parameter Manager. By default this should be com.ten60.netkernel.dcp.JavacProvider.
  2. Ensure the module to support dynamic compilation is in a directory and not a JAR file.
  3. Add the <dynamic/> tag to the <info> section of the module's module.xml file.
  4. Perform a cold restart. You should see the following messages appear in the system log during startup:
    Using [com.ten60.netkernel.dcp.JavacProvider] to provide dynamic Java classes
    [0] source files to be compiled in [urn:your:module:URI]

Once these steps are completed the module will automatically detect changes made to Java source code and recompile the classes.

To disable dynamic compilation of a module simply remove the <dynamic/> tag from the module.xml declaration and perform a cold-restart.

Operation

When dynamic compilation is enabled, uncompiled or out-of-date Java classes are compiled when NetKernel starts. The compiler uses the module's Java classpath. Warning and error messages from the compiler are written to the system log which is made visible in the console.

While NetKernel runs all modules tagged as "dynamic" are periodically scanned for changes. When changes are detected the module's minor-minor version number is incremented (e.g. 1.0.0 -> 1.0.1) and a hot restart is automatically initiated. The hot restart will decommission the dynamic module plus any modules that depend upon classes in that module. All modules will then be recommissioned and Java classes will be compiled.

Hot restart is typically very fast as only effected modules are restarted. Transports are typically unaffected and the restart process results in only a short pause in request processing.

Development Environment

For information on setting up classpath and IDEs for working with Java see the practicalities guide.

© 2003-2007, 1060 Research Limited. 1060 registered trademark, NetKernel trademark of 1060 Research Limited.