Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327029 - [r-OSGi][RemoteSrvs] Smart Proxy cannot delegate to original method
Summary: [r-OSGi][RemoteSrvs] Smart Proxy cannot delegate to original method
Status: RESOLVED FIXED
Alias: None
Product: ECF
Classification: RT
Component: ecf.protocols (show other bugs)
Version: 3.3.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.4.0   Edit
Assignee: Markus Kuppe CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-05 13:30 EDT by Markus Kuppe CLA
Modified: 2010-10-11 11:04 EDT (History)
0 users

See Also:


Attachments
mylyn/context/zip (2.41 KB, application/octet-stream)
2010-10-05 13:35 EDT, Markus Kuppe CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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