Class MemberResourceRESTService


  • @Path("/members")
    @RequestScoped
    public class MemberResourceRESTService
    extends Object
    JAX-RS Example

    This class produces a RESTful service to read/write the contents of the members table.

    • Constructor Detail

      • MemberResourceRESTService

        public MemberResourceRESTService()
    • Method Detail

      • listAllMembers

        @GET
        @Produces("application/json")
        public List<Member> listAllMembers()
      • lookupMemberById

        @GET
        @Path("/{id:[0-9][0-9]*}")
        @Produces("application/json")
        public Member lookupMemberById​(@PathParam("id")
                                       long id)
      • createMember

        @POST
        @Consumes("application/json")
        @Produces("application/json")
        public javax.ws.rs.core.Response createMember​(Member member)
        Creates a new member from the values provided. Performs validation, and will return a JAX-RS response with either 200 ok, or with a map of fields, and related errors.
      • emailAlreadyExists

        public boolean emailAlreadyExists​(String email)
        Checks if a member with the same email address is already registered. This is the only way to easily capture the "@UniqueConstraint(columnNames = "email")" constraint from the Member class.
        Parameters:
        email - The email to check
        Returns:
        True if the email already exists, and false otherwise