How to create multiple unique instance of an osgi component?

72 Views Asked by At

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

There are 1 best solutions below

2
On

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