org.sapia.ubik.rmi.interceptor
Interface Interceptor

All Known Implementing Classes:
ClientSideInterceptor, HitCountInterceptor, SecurityServiceImpl, ServerSideInterceptor

public interface Interceptor

This interface is a marker that interceptor objects must implement. Interceptor classes are expected to defined methods that correspond to the event types (or classes) they expect. Events are objects that encapsulate state and are handled to the call back interceptor methods.

For example, suppose we define a given "event", through the LogEvent class (note that the "event" string does not need to appear in the class name). To intercept instances of this event, an interceptor needs to be implemented, which will have the following method:

public void onLogEvent(LogEvent evt);

As shown below, the method's signature must have the following pattern:

onEventClassName(EventClass)

Once an interceptor class has been designed, it can be registered with a dispatcher to intercept events of the specified class:

 SingleDispatcher disp = new SingleDispatcher();
 LogInterceptor it = new LogInterceptor();
 disp.registerInterceptor(LogEvent.class, it);

 // the following event will be intercepted by our interceptor.
 disp.dispatch(new LogEvent());
 

As one might have guessed, Java's introspection capabilities are used to match the event class to the proper interceptor method at registration time. This one-event-per-method scheme allows one interceptor to register for multiple event types.

Dispatching behavior and event registration policies can vary from one dispatcher to another.

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site



Copyright © 2010 Sapia OSS. All Rights Reserved.