Search code examples
javaspringweb-servicesrestopenmrs

Not able to find the Implementation Class for an Interface in Java


I am trying to modify Openmrs rest call given at this link: https://github.com/openmrs/openmrs-module-webservices.rest/blob/master/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/SessionController.java

It imports a spring framework org.springframework.web.context.request.WebRequest in the code. I am not able to track where in the openmrs repo is the class implementing this interface WebRequest.

The openmrs repo is given on this link -https://github.com/openmrs/openmrs-module-webservices.rest

Till now I have come across this small line on Openmrs wiki that says- All of our services are interfaces. The default implementation of these services are named *ServiceImpl.java. The implementations can be found in the impl directory of the api package.

Can anyone help me in figuring out how to find the implementation class ?


Solution

  • It is Spring's interface. So Spring create and inject some implementation of it.

    import org.springframework.web.context.request.WebRequest;
    

    If you can run and debug the code, put breakpoint into this controller, make request to this endpoint and than you can figure out implementation class.

    It will be one of these classes according documentation: DispatcherServletWebRequest, FacesWebRequest, NoSupportAsyncWebRequest, PortletWebRequest, ServletWebRequest, StandardServletAsyncWebRequest

    By quick find, I couldn't find servlet configuration in that repo. So really don't know which of this classes it would be. DispatcherServletWebRequest is most common because Spring MVC is mostly used with Spring's DispatcherServlet filter.