redstone.xmlrpc
Interface XmlRpcInvocationInterceptor

All Known Implementing Classes:
DebugInvocationInterceptor

public interface XmlRpcInvocationInterceptor

Invocation processors are called by XmlRpcServers before and after a call is dispathed to its invocation handler. Processors are called for all inbound messages regardless of destination. They serve as appropriate entry points where logging and other type of processing may be inserted. For instance, a transaction processor may examine the name of the method being called, and if it starts with "tx_" it may add an additional transaction argument to the list of arguments received by the method. After the call is dispatched, the transaction may be commited or rolled back, in case of an error.

Author:
Greger Olsson

Method Summary
 java.lang.Object after(XmlRpcInvocation incovation, java.lang.Object returnValue)
          Called by an XmlRpcServer after the supplied method has been called.
 boolean before(XmlRpcInvocation invocation)
          Called by an XmlRpcServer before the method with the supplied name is called.
 void onException(XmlRpcInvocation incovation, java.lang.Throwable exception)
          Called by an XmlRpcServer when the supplied method throws an exception.
 

Method Detail

before

boolean before(XmlRpcInvocation invocation)
Called by an XmlRpcServer before the method with the supplied name is called. The arguments list may be altered if necessary. The method must have matching parameters, however.

If, for some reason, the processor wishes to cancel the invocation altogether, it returns false from this method. This may be the case for filtering processors where certain IP-addresses are restricted from particular methods, or if the arguments contain some encrypted password and username that does not authorize.

Parameters:
invocation - The invocation intercepted by the processor.
Returns:
true if the invocation should proceed, or false if not.

after

java.lang.Object after(XmlRpcInvocation incovation,
                       java.lang.Object returnValue)
Called by an XmlRpcServer after the supplied method has been called. The processor may alter the return value, if it wants, before the response is created. This may be useful if the information therein should be encrypted or compressed, for instance.

If the interceptor returns null it means that the call was intercepted completely and that the interceptor itself is responsible of generating a response to the caller through the java.io.Writer in the XmlRpcInvocation. This makes it possible to write interceptors that override the whole serialization mechanism to return customized content for invocations.

Parameters:
invocation - The invocation intercepted by the processor.
returnValue - The object returned by the method. If the method returned a primitive, it is wrapped in its object counterpart.
Returns:
The (possibly modified) returnValue argument, or null if the interceptor has intercepted the call completely and no value is to be returned.

onException

void onException(XmlRpcInvocation incovation,
                 java.lang.Throwable exception)
Called by an XmlRpcServer when the supplied method throws an exception.

Parameters:
invocation - The invocation intercepted by the processor.
exception - The exception thrown by the method.