Are those the SCR annotations, or the newer official OSGi declarative
service annotations?

In either cause, I suppose you'd need to to adjust the cardinality property
on the @Reference annotation to tell it you want multiple service
references.

Regards,
-Eric

On Thu, Sep 20, 2018 at 7:42 PM David Daniel <david.daniel.1...@gmail.com>
wrote:

> I had switched form a servicetracker to constructor injection of a list
> with scr 2.1.6 . The servicetracker got all the services correctly but the
> list is only getting 1.  I was wondering if I did not understand something
> or if there was an open bug.
>
> Thanks for any help,
>   David
>
> From
>
>         try {
>             mBundleContext = bc;
>             String filterString = "(" + Constants.OBJECTCLASS + "=" +
> IHandlerFactory.class.getName() + ")";
>             Filter filter = bc.createFilter(filterString);
>             tracker = new ServiceTracker(bc, filter, this);
>             tracker.open();
>
>         } catch (InvalidSyntaxException e) {
>             if (log != null) {
>                 log.log(LogService.LOG_ERROR, e.getMessage());
>             }
>         }
>
> To
>
> @Activate
> public HandlerBuilder(@Reference List<IHandlerFactory> handlerFactories) {
> pathHandler.addExactPath("/", new Forwarding());
> pathHandler.addExactPath("/manifest.json", new Manifest());
> for(IHandlerFactory handler : handlerFactories) {
> if (handler.Type().equals("path")) {
> if (handler instanceof IPathHandlerFactory) {
> logger.info("Adding Handler for: " + ((IPathHandlerFactory)
> handler).Prefix
> ());
> pathHandler.addPrefixPath(((IPathHandlerFactory) handler).Prefix(),
> handler.
> Get());
> }
> }
> }
> }
>

Reply via email to