1 package org.sapia.ubik.rmi.interceptor; 2 3 4 /** 5 * This interface is a marker that interceptor objects must implement. 6 * Interceptor classes are expected to defined methods that correspond 7 * to the event types (or classes) they expect. Events are objects that 8 * encapsulate state and are handled to the call back interceptor methods. 9 * <p> 10 * For example, suppose we define a given "event", through the 11 * <code>LogEvent</code> class (note that the "event" string does not need to 12 * appear in the class name). To intercept instances of this event, an 13 * interceptor needs to be implemented, which will have the following 14 * method: 15 * <p> 16 * <code>public void onLogEvent(LogEvent evt);</code> 17 * <p> 18 * As shown below, the method's signature must have the following pattern: 19 * <p> 20 * <code>on</code><i>EventClassName</i>(<i>EventClass</i>) 21 * <p> 22 * Once an interceptor class has been designed, it can be registered 23 * with a dispatcher to intercept events of the specified class: 24 * <p> 25 * <pre> 26 * SingleDispatcher disp = new SingleDispatcher(); 27 * LogInterceptor it = new LogInterceptor(); 28 * disp.registerInterceptor(LogEvent.class, it); 29 * 30 * // the following event will be intercepted by our interceptor. 31 * disp.dispatch(new LogEvent()); 32 * </pre> 33 * <p> 34 * As one might have guessed, Java's introspection capabilities are 35 * used to match the event class to the proper interceptor method at 36 * registration time. This one-event-per-method scheme allows one interceptor 37 * to register for multiple event types. 38 * <p> 39 * Dispatching behavior and event registration policies can vary from 40 * one dispatcher to another. 41 * 42 * @author Yanick Duchesne 43 * <dl> 44 * <dt><b>Copyright:</b><dd>Copyright © 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt> 45 * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the 46 * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt> 47 * </dl> 48 */ 49 public interface Interceptor { 50 } 51