HOT reloading

HOT reloading means new version of a class is automatically reloaded on the fly. Due to HOT reloading, when you change the source code, you can see the changed result on your browser without restarting web application.

HOT reloading works by creating a new class loader per request.
See and

Classes that are under <slim3.rootPackage> except cool package are HOT reloadable. <slim3.rootPackage> is defined in web.xml. Classes that are not HOT reloadable are called "COOL classes".
For example:
  • <slim3.rootPackage>.Aaa(HOT reloadable)
  • <slim3.rootPackage>.controller.IndexController(HOT reloadable)
  • <slim3.rootPackage>.model.Bbb(HOT reloadable)
  • <slim3.rootPackage>.cool.Ccc(COOL)
  • <slim3.rootPackage>.cool.model.Ddd(COOL)
  • <slim3.rootPackage>.cool.service.EeeService(COOL)
  • <slim3.rootPackage>.cool.servlet.FffServlet(COOL)
  • <slim3.rootPackage>.cool.filter.GggFilter(COOL)
A HOT reloadable class can reference a HOT reloadable class and a COOL class. A COOL class can reference A COOL class, but cannot reference a HOT reloadable one.
For example, EeeService can reference Ddd, but cannot reference Bbb.

If a COOL class wants to reference a HOT reloadable class, use CoolBridge. To use CoolBridge, You need to create a COOL interface and a HOT reloadable implementation class. A COOL interface must not depends on HOT reloadable classes.

COOL interface


public interface EeeService {
   void foo();

HOT reloadable implementation class

package root.service;


public class EeeServiceImpl implements EeeService {
    public void foo() {
        Bbb bbb = new Bbb();

Naming convension from COOL interface to HOT reloadable implementation class:
  • Replace ".cool." with "."
    • -> root.service.EeeService
  • Add "Impl" to the end of the class name
    • root.service.EeeService -> root.service.EeeServiceImpl
Let's use CoolBridge:

COOL class to use CoolBridge


import org.slim3.util.CoolBridge;

public class GggFilter implements Filter {

    public void init(FilterConfig config) throws ServletException {

    public void destroy() {

    public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain) throws IOException, ServletException {
        EeeService service = CoolBridge.create(EeeService.class);;
        chain.doFilter(request, response);

If you use MemcacheService or JCache, use org.slim3.memcache.Memcache instead of it.

A HOT reloadable class does not support singleton pattern using static field. In this case you should use a COOL class.