Hi,

On Fri, Dec 11, 2020 at 4:16 PM Nicola Cisternino <ncis...@cointa.it> wrote:
> ...I can select single datasource using DS annotations:
> @Reference(target =
> "(&(objectclass=javax.sql.DataSource)(datasource.name=*source1*))")
> private DataSource dataSource;
>
> But ... how can I select single datasource programmatically ?

The BundleContext.getServiceReferences(java.lang.Class<S> clazz,
java.lang.String filter) method [1] takes an OSGi LDAP-style filter
with the same syntax quoted above, that's probably what you need.
There are a number of examples using it in the Sling codebase.

-Bertrand

[1] 
https://docs.osgi.org/javadoc/osgi.core/7.0.0/org/osgi/framework/BundleContext.html#getServiceReferences-java.lang.Class-java.lang.String-

Reply via email to