Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

I know that under strict ReSTful architecture, there should be no hint of the service being provided in the URI naming (in other words avoid rpc style naming conventions), to this end I have mapped eah URI to one and only one HTTP command.

Under the hood

Let's exam the following service entry points

Info
titleExample code

@GET
@Path("/cu/{user}")
@Produces(MediaType.APPLICATION_JSON)
public Response createUser(@PathParam("user") String userId)
{
      User usr = new User(userId, genPassword());

      return __createUser(usr);
}

@POST
@Path("/cu")
@Consumes(MediaType.APPLICATION_JSON)
public Response createUserFromObject(User usr)
{
      return __createUser(usr);
}

Essentially I have created two entry points to the same service __createUser() on the same interface class UserRestService.  I am going to repeat this pattern for all the other services I want to expose.  This is a simple case of refactoring the interfaces methods.