Call method of subclass from parent reference

zdhim :

I have 3 OSGi bundles in such as way, implemented class is of same name but in different bundles :

Bundle A (com.adobe) ---- Interface ( foo() )
Bundle B (org.custom) ---- ChildClassA ( foo() {} )
Bundle C (myprj.adobe) ---- ChildClassA ( foo() {} )

I have a snippet as below :

Interface refObj;
refObj.foo();

How can i inject the object of specific implemented class from another bundle.

Thanks,

Christian Schneider :

If you have different services that implement the same interface then you can add properties to the services.

On the client side you can use a reference with a target.

@Reference(target="(key=value)")

This reference will only match a service with a property "key" that has the value "value".

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=121783&siteId=1
Recommended