Hi
I have a blocking problem dealing with downcasting proxied types under
dOSGI, and of course any help from this lovely community is very
appreciated.
//given an interface
interface IComponent extends IPersistable
//its implementation
class Component implements IComponent
//service contract
interface IRequestService{
IPersistable syncRequest();
}
// its implementation
class RequestService implements IRequestService{
IPersistable syncRequest(){
//in this arbitrary case return IComponent object
return new Component();
}
An exception such as: "java.lang.ClassCastException: $Proxy39 cannot be
cast to ... "
is thrown when the remote consumer is trying to down cast from
IPersistable to IComponent via proxy:
class SomeConsumer{
IRequestService requestService= ..;//some remote proxy to IRequestService
IComponent c = ( IComponent) requestService.syncRequest();
}
I found you can config your spring beans to be jdk/cglib proxied. I tried
adding some aop elements "like":
<aop:config proxy-target-class="true" /> to my spring/context.xml hoping
for some springful magic :).
Back to earth, the problem is that neither our objects (Component in this
case) were intended to be managed by Spring, nor are we
intercepting/advising in our osgi app, in first place.
Is going for some aop stuff (somehow overkill!) for such issues the right
solution? Please advise!
Kind regards
Ahmed Aadel
remainsoftware.com