Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Let's consider a specific example. We want to move ObsResource to 2.x. You need to start from changing dependencies in your poms and creating a single controller to define your module namespace. See Adding a Web Service Step by Step Guide for Core Developers.

  1. Open ObsResource.java and remove @Handler. Change the resource annotation to @Resource(name = "obs", supportedClass = Obs.class, supportedOpenmrsVersions = { "1.8.", "1.9." }). Fix imports if any.
  2. Open ObsController.java. You can see that it has two custom search methods. Create ObsSearchHandler implementing SearchHandler, which can do the same searches depending on which request parameter is given. The alternative is to implement searches directly in the resource by overriding the doSearch method. We recommend SearchHandler as it is more robust.
  3. Remove ObsController.java. It is no longer necessary since all requests are handled by the main controller and you moved custom searches to ObsSearchHandler.
  4. If you had ObsControllerTest.java which called ObsController methods, then you need to change it to extend MainResourceControllerTest and call newGetRequest, newPostRequest or newDeleteRequest with the correct URL. See the new ObsController1_8Test.java for example.

...