Hello everybody,
I am using osgi for my thesis project and i have faced a problem by using declarative services.
Specifically i want to declare a service which refers to another. Here is the source code.
Service Interface :
package admin.service.adjustLight;
import classes.*;
public interface LightAdjustment {
public void adjustLight (Light light);
}
Service Implementation Class :
package admin.service.adjustLight;
import admin.decision.module.*;
import classes.ConsoleMessages;
import classes.Light;
public class LightAdjustmentImpl implements LightAdjustment{
ConsoleMessages consoleMessages = new ConsoleMessages();
static AdjustmentDecision decisionService;
protected void bind(AdjustmentDecision decision) {
System.out.println("A new service was bind");
decisionService=decision;
}
protected void unbind(AdjustmentDecision decision) {
decisionService=null;
}
public void adjustLight(Light light) {
Object object=null;
decisionService.getDecision(object);
}
}
Component Description xml file :
<?xml version="1.0"?>
<component name="L">
<implementation class="admin.service.adjustLight.LightAdjustmentIm pl"/>
<service>
<provide interface="admin.service.adjustLight.LightAdjustme nt"/>
</service>
<reference name="LOG"
interface="admin.decision.module.AdjustmentDecisio n"
bind="bind"
unbind="unbind"
/>
</component>
The problem is that, although my service
LightAdjustment is registered, the binding with the reference service
AdjustmentDecision is never happened (the message
"A new service was bind" is not printed).
I would be very glad if anyone could help me.
Thanks.