List of usage examples for org.apache.wicket.util.listener IChangeListener IChangeListener
IChangeListener
From source file:de.micromata.less.LessWicketApplicationInstantiator.java
License:Open Source License
/** * adds a resource watcher entry to the given less source * // w w w. jav a 2 s .c om * @param resourceWatcher * @param importedSource */ private void addWatcher(final IModificationWatcher resourceWatcher, final LessSource importedSource) { log.info("adding watcher to less file " + importedSource.getAbsolutePath()); resourceWatcher.add(new org.apache.wicket.util.file.File(new File(importedSource.getAbsolutePath())), new IChangeListener() { @Override public void onChange() { try { compile(); } catch (final Exception e) { log.error("unable to compile less source during watcher for file " + importedSource.getAbsolutePath(), e); } } }); }
From source file:wicket.contrib.groovy.GroovyClassResolver.java
License:Apache License
/** * Load the groovy file and watch for changes. If changes to the groovy * happens, than reload the file./*from w w w .j ava 2 s . c o m*/ * * @param classname * @param resource * @return Loaded class */ private Class loadGroovyFileAndWatchForChanges(final String classname, final IResourceStream resource) { // Watch file in the future final IModificationWatcher watcher = application.getResourceSettings().getResourceWatcher(true); if (watcher != null) { watcher.add(resource, new IChangeListener() { public void onChange() { try { log.info("Reloading groovy file from " + resource); // Reload file and update cache final Class clazz = loadGroovyFile(classname, resource); log.debug("Groovy file contained definition for class: " + clazz.getName()); } catch (Exception e) { log.error("Unable to load groovyy file: " + resource, e); } } }); } log.info("Loading groovy file from " + resource); return loadGroovyFile(classname, resource); }