/scalate-jrebel/src/main/scala/org/fusesource/scalate/jrebel/ScalateReloader.scala
http://github.com/scalate/scalate · Scala · 32 lines · 18 code · 6 blank · 8 comment · 0 complexity · 7b98b3873dabda9a5965a675211b1c9b MD5 · raw file
- package org.fusesource.scalate
- package jrebel
- import org.zeroturnaround.javarebel.ClassEventListener
- import org.zeroturnaround.javarebel.ReloaderFactory
- import util.Logging
- /**
- * A JRebel plugin to reload templates in a Scalate TemplateEngine if dependent classes are modified
- */
- object ScalateReloader extends TemplateEngineAddOn with Logging {
- /**
- * Reloads templates in a template engine if the classes are modified
- */
- @deprecated("Scalate-jrebel is deprecated", "1.9.6")
- def apply(engine: TemplateEngine): Unit = {
- info("Installing JRebel Scalate plugin on instance: " + engine + " " + System.identityHashCode(engine))
- ReloaderFactory.getInstance.addClassReloadListener(new ClassEventListener {
- def priority = ClassEventListener.PRIORITY_DEFAULT
- def onClassEvent(i: Int, clazz: Class[_]) = {
- // TODO we could be a bit more clever to figure out which templates need to be reloaded
- // for now lets just flush all templates!
- info("Flushing Scalate templates on instance: " + engine)
- engine.invalidateCachedTemplates()
- }
- })
- }
- }