Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 364713

Summary: Need the possibility to intercept remote service calls
Product: [RT] Riena Reporter: Stefan Liebig <Stefan.Liebig>
Component: communicationAssignee: Stefan Liebig <Stefan.Liebig>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Stefan Liebig CLA 2011-11-24 07:53:42 EST
When calling remote services it is sometimes desirable to intercept the call before it will be passed to the remote server.
This can be used e.g. to implement caching strategies, logging, ..
Such "interceptors" should be hooked in transparently without the need to modify existing code.
Comment 1 Stefan Liebig CLA 2011-11-24 10:02:53 EST
It is now possible to define call-interceptors via the extension-point "org.eclipse.riena.communication.core.callInterceptors", e.g.

    <extension
          point="org.eclipse.riena.communication.core.callInterceptors">
       <callInterceptor
             callInterceptorClass="de.whatever.project.internal.example.client.swt.MonitorReceiverInterceptor3"
             name="Interceptor-Three"
             preInterceptors="Interceptor-Two"
             serviceInterfaceClass="org.eclipse.riena.monitor.common.IReceiver">
       </callInterceptor>
    </extension>

For description of the attributes see extension-point description/definition of "callInterceptors" in bundle "org.eclipse.riena.communication.core".

The specified call-interceptor has (of course) to implement the interface of the intercepted service and it has to implement a public constructor with a single parameter which has to be of the same type as the intercepted service, e.g.

public class MonitorReceiverInterceptor3 implements IReceiver {

	private final IReceiver delegate;

	public MonitorReceiverInterceptor3(final IReceiver delegate) {
		this.delegate = delegate;
	}

	public boolean take(final long senderTime, final List<Collectible<?>> collectibles) {
		System.out.println(getClass().getSimpleName());
		System.out.println("SenderTime:" + senderTime);
		return delegate.take(senderTime, collectibles);
	}

}

As you can see the interceptor delegates the call to the provided delegate. If there are multiple interceptors riena.communication will create a chain of interceptors ending with real remote call.
Comment 2 Stefan Liebig CLA 2011-11-29 09:55:59 EST
*** Bug 364712 has been marked as a duplicate of this bug. ***