There is an upcoming specification in OSGi R7 that allows you to define JAX RS components using an OSGi whiteboard. This would completely solve your problem, but the spec and implementation are still being developed.
For now you could fix this by registering your existing servlet as a service and adding a second component which extends/delegates to a JAX-RS container servlet. If the container servlet component depends on your JAX-RS service then it can register it as a JAX-RS Application containing a pre-instantiated singleton bean. This model can easily be changed to be spec compliant in the future, simply removing/disabling the servlet and adding properties to the JAX-RS component using config admin (no code changes needed). I hope this helps, Tim Sent from my iPhone > On 3 Nov 2016, at 02:05, Tanvir <tanvir.ah...@oracle.com> wrote: > > I have a REST resource class, say Employees, and I need access to another > service using DS. Hence I have to make this call a component. Now objects > instantiated by @component and JAX-RS Servlet are not same. > > I do not want to use static reference to the service as shown below. How this > can be handled? > > ----------------------------------------------- > @Component > @Path("employees") > public class EmployeeResource { > static MyService service; > @Reference > void setMyService(MyService s) { > service = s; > } > > @GET > @Produces("text/plain") > public String getEmployees() { > return service.get(); > } > } > > -- > Best, > Tanvir > > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev _______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev