Greetings All,

I'm having a trouble with getting my scenario to work. Would be glad if
some one can help me out!

Here's my problem scenario.

1) I have a component which provides a service A.

@scr.component name="a.b.c.service" immediate="true"
@scr.service value="a.b.c.service.myserviceInterface1"

2) I have another component which provides another service B.

@scr.component name="a.b.d.service" immediate="true"
@scr.service value="a.b.d.service.myserviceInterface2"

3) And inside a method of this 2nd service (B), I'm calling an instance of
object X.

4) Instance X, calls an operation of service A.

So my question is how can I pass the Service A object to X? What are the
scr annotations I should use and where? Please also note, that X should
aware of changes that takes place in Service A.

I tried several referencing ways [1] but failed to get the thing to work as
I want.

Thank you!

[1] example way I used was adding following annotations at class level of
object X.

@scr.component name="a.b.d.service.e" immediate="false"
@scr.reference name="a.b.c.service"
interface="a.b.c.service.myserviceInterface1"
cardinality="1..1" bind="setServiceA" unbind="unsetServiceA"

and I had following methods and variable too.

private serviceA;

public synchronized void setServiceA(myserviceInterface1 a) {
       serviceA = a;
    }


    public synchronized void unsetServiceB(myserviceInterface1 a) {
        serviceA = null;
    }


-- 
Best Regards,
Nirmal

C.S.Nirmal J. Fernando
Software Engineer,
WSO2 Inc.

Blog: http://nirmalfdo.blogspot.com/

Reply via email to