1

I have a component UrlManager. Whenever this binds in other components I need to get unique instance of UrlManager. How can I do it ? My DS version is 1.2. Note: Im using Osgi component annotations.

    import org.osgi.service.component.annotations.Component;
    @Component(immediate=true, name="UrlManager", service={UrlManager.class})
    public class UrlManager implements Urls
    {
       public String getId()
       {
       }
    } 

    

1 Answers1

0

You will want to use ServiceScope.PROTOTYPE service components (and remove immediate=true. This feature was introduced in DS 1.3.

BJ Hargrave
  • 9,324
  • 1
  • 19
  • 27
  • Is there a way to do this in DS version lesser than 1.3 ? Also Im confused where to check on DS version – Karthikeyan V Jun 21 '23 at 14:34
  • No, since the prototype scope feature was added in DS 1.3 which relies upon support added in OSGi Core Release 6. The DS version can be seen in the package version of org.osgi.service.component. Your DS implementation should document which DS spec version is supported. – BJ Hargrave Jun 22 '23 at 15:11