felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chetan mehrotra <chetan.mehro...@gmail.com>
Subject Re: Design pattern for working with multiple implementations of an interface
Date Sun, 24 Jul 2011 08:38:07 GMT
What if you use @Reference with ReferenceCardinality set
ReferenceCardinality.OPTIONAL_MULTIPLE. Then you would get bind and
unbind callbacks
Have a look at Sling AdapterManagerImpl [1] which uses this approach
(though it uses Javadoc based SCR config mechanism). Same thing done
using annotations would look like
@Reference(
        name="AdapterFactory",
        referenceInterface = org.apache.sling.api.adapter.AdapterFactory.class,
        cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
        policy = ReferencePolicy.DYNAMIC
)
And then you add
protected void bindAdapterFactory(ServiceReference reference)
protected void unbindAdapterFactory(ServiceReference reference)

Chetan Mehrotra
[1] http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/adapter/src/main/java/org/apache/sling/adapter/internal/AdapterManagerImpl.java

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message