ca.uhn.cache.proxy
Interface IListeningMethodAdapter

All Superinterfaces:
IMethodAdapter

public interface IListeningMethodAdapter
extends IMethodAdapter

An extension of IMethodAdapter to handle methods in which results are returned to the caller via a listener instead of as a return value. The caller is assumed to provide the listener as a method argument. If a method does not use a listener, adapt it with a IMethodAdapter instead. We don't handle cases where there is more than one listener argument per method. The proxy uses this interface as follows. When a caller calls a method to perform a query, it provides listener to which results are supposed to go. The proxy wraps it in a ResultListener (A) obtained from wrapListener(). Cached results are sent to this ResultListener. The proxy then calls replaceListener() to replace the caller's listener with a new listener of the same type, which sends data to a new ResultListener (B). The underlying method is called with this new argument list. ResultListener B forwards data to both the cache and ResultListener A, which in turn passes it to the caller. In summary, results follow this path as they become available: data source -> replacement listener -> ResultListener B -> cache and ResultListener A -> caller's listener.

Version:
$Revision: 1.1 $ updated on $Date: 2005/01/24 22:53:24 $ by $Author: bryan_tripp $
Author:
Bryan Tripp

Nested Class Summary
static interface IListeningMethodAdapter.ResultListener
          A generic listener for query results.
 
Method Summary
 java.lang.Object[] replaceListener(java.lang.Object[] theMethodArgs, IListeningMethodAdapter.ResultListener theListener)
           
 IListeningMethodAdapter.ResultListener wrapListener(java.lang.Object[] theMethodArgs)
           
 
Methods inherited from interface ca.uhn.cache.proxy.IMethodAdapter
getArgs, getArgTypes, getDataInspector, getMaxGroups, getMethodName, getParamsFromArgs, getReason, includeInResults
 

Method Detail

wrapListener

public IListeningMethodAdapter.ResultListener wrapListener(java.lang.Object[] theMethodArgs)
Parameters:
theMethodArgs - one of these is a listener to which the method implementation is expected to send query results.
Returns:
a wrapper around the listener to which the cache can send additional data.

replaceListener

public java.lang.Object[] replaceListener(java.lang.Object[] theMethodArgs,
                                          IListeningMethodAdapter.ResultListener theListener)
Parameters:
theMethodArgs - one of these is a listener to which the method implementation is expected to send query results.
theListener - a listener to
Returns:
TODO:


Copyright © 2004-2005 University Health Network. All Rights Reserved.