Hi

Given an interface, sub-interfaces and multiple implementations, how to 
enable the consumer to downcast to a specific implementation or interface.

For instance:
//given some interfaces

interface IPersistable{...}
interface ILocation extends IPersistable{...}
interface  IComponent extends IPersistable{...}
...

//some implementations

public class Component implements IComponent {...}
public class Location implements ILocation{..}
...

//and some osgi service

public class RequestService implements IRequestService{
...
public IPersistable syncRequest(IRequest){
//in this arbitrary case return an IComponent object
IComponent c = .......
return c;
}
...
}

//and some remote consumer 
How to avoid:
>> java.lang.ClassCastException: $Proxy39 cannot be cast to ... 
when the consumer tries doing something like:

class SomeConsumer{
...
IRequestService requestService=...;
IComponent c = (IComponent) requestService.syncRequest(request);
....
}

Many thanks

Reply via email to