Reputation: 170735
In all iPOJO examples I've seen, the @Bind
and @Unbind
callbacks take only the service instance as an argument, i.e.
// @Requires
// private Foo foo;
@Bind
public void bindFoo(Foo foo) { ... }
@Unbind
public void unbindFoo(Foo foo) { ... }
Blueprint also allows you to have
public void bindFoo(ServiceReference reference) { ... }
public void bindFoo(Foo foo, Map<String, Object> properties) { ... }
Can iPOJO callbacks also get access to service properties or ServiceReference
? Or should whiteboard handler be used for this instead?
Upvotes: 0
Views: 913
Reputation: 3192
Callbacks can have one of these signatures:
So, are supported:
@Bind
public void bind() { ... }
@Bind
public void bind(Service svc) { ... }
@Bind
public void bind(ServiceReference ref) { ... }
@Bind
public void bind(Service svc, ServiceReference ref) { ... }
@Bind
public void bind(Service svc, Map properties) { ... }
@Bind
public void bind(Service svc, Dictionary properties) { ... }
So no problem to access the service properties. Except if you really need the ServiceReference, it's probably better to not use this OSGi-specific object (reduce testability).
Upvotes: 1