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

Bug 327029

Summary: [r-OSGi][RemoteSrvs] Smart Proxy cannot delegate to original method
Product: [RT] ECF Reporter: Markus Kuppe <bugs.eclipse.org>
Component: ecf.protocolsAssignee: Markus Kuppe <bugs.eclipse.org>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: 3.3.0   
Target Milestone: 3.4.0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
mylyn/context/zip none

Description Markus Kuppe CLA 2010-10-05 13:30:20 EDT
A r-OSGi smart proxy [0] allows to intercept methods called on the generated service proxy on the consumer side. E.g.

public abstract class SmartProxyService implements IFooService {

	/* (non-Javadoc)
	 * @see o.e.ecf.IFooService#foo()
	 */
	public boolean foo() {
		return false;
	}
}

foo() overwrites the method declaration in IFooService. 
Unfortunately, r-OSGi does not support calling the original IFooService#foo() method from within the smart proxy, because it's not possible to get hold of the IFooService instance, e.g.:

public abstract class SmartProxyService implements IFooService {

	/* (non-Javadoc)
	 * @see o.e.ecf.IFooService#foo()
	 */
	public boolean foo() {
		return anIFooService.foo();
	}
}

Instead I have added functionality to declare a stub method inside the SmartProxyService that is dispatched to the original IFooService#foo() method at runtime. For this work, the stub method has to be abstract, declare the same signature, but prepend the original method name with "_rosgi" and the first character capitalized:

public abstract class SmartProxyService implements IFooService {

	public abstract boolean _rosgiFoo();

	/* (non-Javadoc)
	 * @see o.e.ecf.IFooService#foo()
	 */
	public boolean foo() {
		return _rosgiFoo();
	}
}

[0] http://r-osgi.sourceforge.net/advanced.html
Comment 1 Markus Kuppe CLA 2010-10-05 13:35:08 EDT
Enhancement released to HEAD
(need to file an enhancement request with upstream)
Comment 2 Markus Kuppe CLA 2010-10-05 13:35:10 EDT
Created attachment 180261 [details]
mylyn/context/zip
Comment 3 Markus Kuppe CLA 2010-10-06 01:51:37 EDT
I've updated the implementation so that if the IFooService inteface happens to declare a _rosgiFoo() method already (rather unlinkely though), that one will be preferred.
Comment 4 Markus Kuppe CLA 2010-10-06 02:47:03 EDT
TODO: add tests to r-osgi test bundle
Comment 5 Markus Kuppe CLA 2010-10-11 11:04:11 EDT
(In reply to comment #1)
> Enhancement released to HEAD
> (need to file an enhancement request with upstream)

https://sourceforge.net/tracker/?func=detail&aid=3085318&group_id=158382&atid=807609