Hello Felix,
serviceAimpl has the following code:
package serviceAimpl;
import serviceA.*;
import serviceB.*;
import org.osgi.service.component.*;
public class serviceAimpl implements serviceA{
serviceB b;
public void set(serviceB b)
{
System.out.println("This is the set");
this.b=b;
}
public void unset(serviceB b)
{
System.out.println("This is the unset");
this.b=null;
}
public void activate(ComponentContext cnt)
{
System.out.println("Activation of componentA");
b.printB();
}
public void deactivate(ComponentContext cnt)
{
System.out.println("Deactivation of componentA");
}
public void printA()
{
System.out.println("This is the printA function");
}
}
serviceBimpl has the following code:
package serviceBimpl;
import serviceB.*;
import serviceA.*;
import org.osgi.service.component.*;
public class serviceBimpl implements serviceB{
serviceA a;
public void printB()
{
System.out.println("This is the service b print function");
}
public void set(serviceA a)
{
System.out.println("This is the set");
this.a=a;
}
public void unset(serviceA a)
{
System.out.println("This is the unset");
this.a=null;
}
public void activate(ComponentContext cnt)
{
System.out.println("Activation of componentA");
a.printA();
}
public void deactivate(ComponentContext cnt)
{
System.out.println("Deactivation of componentA");
}
}
This is what i did in the osgi console
972 RESOLVED ComponentA_1.0.0
984 RESOLVED ComponentB_1.0.0
osgi> start 984
osgi> start 972
osgi> Activation of componentA
b.printB() is not invoked... why is it?????????????/
Thank you,
Raji
Hi Raji,
rajalaxmi chandran schrieb:
>
> Hi,
> please help....
> i am stuck with circular dependecies in osgi. i am using declarative
> services. This is my situation
> *Component A registers ServiceA
> *Component B registers ServiceB
> *Component A needs to use ServiceB
> *Component B needs to use ServiceA.
>
> *componetA.xml file has:*
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <component name="componentA" immediate="true">
>
> <implementation class="serviceAimpl.serviceAimpl"/>
>
> <service>
>
> <provide interface="serviceA.serviceA"/>
>
> </service>
>
> <reference name="SERVICEBUSE" interface="serviceB.serviceB"
> bind="set" unbind=unset" cardinality="1..1" policy="dynamic"/>
>
> </component>
>
>
>
> *componentB.xml file has:*
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <component name="componentB">
>
> <implementation class="serviceBimpl.serviceBimpl"/>
>
> <service>
>
> <provide interface="serviceB.serviceB"/>
>
> </service>
>
> <reference name="SERVICEAUSE" interface="serviceA.serviceA"
> bind="set" unbind="unset" cardinality="0..1" policy="dynamic"/>
>
> </component>
>
>
>
> component A gets activated because of the immediate attribute being
> true, but i cannot use the serviceB nor is componentB able to use
> serviceA.... how do i rectify this error????????????
What do you mean by "I cannot use the serviceB" ? What is the signature
of your serviceAimpl.set method ?
Regards
Felix
Cricket on your mind? Visit the ultimate cricket website. Enter
http://beta.cricket.yahoo.com_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev