Hi,
I am trying to figure out why the @WBP annotation exist, and what are the
advantages compared to using the @Requires annotation.
I failed to find some details regarding that point on the documentation.
(http://felix.apache.org/site/white-board-pattern-handler.html)
I managed to create the @WBP behavior using the @Requires, @Bind, @Unbind
annotations (explained in the example 1).
And in my point of view it does quite the same.
So I think perhaps I mist something.
The main advantage that I see with this kind of implementation is that the
filtered class is not a 'dead String', but a reference to an existing interface.
For example I see one difference. The @WBP annotation have a 'onModification'
field (as exposed in the example 2).
But I didn't manage to try it, because I never reach the case when it is called.
-------------------------------------------------------------------------------------------
Implementation example 1:
@Component
public class RestActivator
{
@Requires(id = "plugins", optional = true)
private Plugin[] plugins;
@Bind(id = "plugins")
private synchronized void addplugin(Restplugin plugin)
{
// ...
}
@Unbind(id = "plugins")
private synchronized void removeplugin(Restplugin plugin)
{
// ...
}
}
-------------------------------------------------------------------------------------------
Implementation example 2:
@Component
@Wbp(filter = "(objectClass=com.test.Plugin)",
onArrival = "onArrival", onDeparture = "onDeparture", onModification =
"onModification")
public class PluginContainer
{
public void onArrival(ServiceReference ref)
{
// ...
}
public void onDeparture(ServiceReference ref)
{
// ...
}
public void onModification(ServiceReference ref)
{
// ...
}
}
Regards,
/Etienne