Note that there are some explanatory texts on larger screens.

plurals
  1. POGeneric, annotation-driven event notification frameworks
    text
    copied!<p>While simple, interface-driven event notification frameworks in Java have been around since pre-Cambrian times (e.g. java.beans.PropertyChangeSupport), it is becoming increasingly popular for frameworks to use annotation-driven event notification instead. </p> <p>For an example, see <a href="http://www.jboss.org/file-access/default/members/jbosscache/freezone/docs/2.2.0.GA/userguide_en/html_single/index.html#api.listener" rel="noreferrer">JBossCache 2.2</a>. The listener class has its listener methods annotated, rather than conforming to a rigid interface. This is rather easier to program to, and easier to read, since you don't have to write empty implementations of listener callbacks that you're not interested in (and yes, I know about listener adapter superclasses).</p> <p>Here's a sample from the JBossCache docs:</p> <pre><code>@CacheListener public class MyListener { @CacheStarted @CacheStopped public void cacheStartStopEvent(Event e) { switch (e.getType()) { case Event.Type.CACHE_STARTED: System.out.println("Cache has started"); break; case Event.Type.CACHE_STOPPED: System.out.println("Cache has stopped"); break; } } @NodeCreated @NodeRemoved @NodeVisited @NodeModified @NodeMoved public void logNodeEvent(NodeEvent ne) { log("An event on node " + ne.getFqn() + " has occured"); } </code></pre> <p>}</p> <p>The problem with this, is that it's very much more of an involved process writing the framework to support this sort of thing, due to the annotation-reflection nature of it.</p> <p>So, before I charge off down the road of writing a generic framework, I was hoping someone had done it already. Has anyone come across such a thing?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload