Class RESTService

java.lang.Object
com.invirgance.convirgance.web.service.RESTService
All Implemented Interfaces:
Routable, Service

@Wiring public class RESTService extends Object implements Service, Routable
A meta-service that routes requests based on the HTTP Method. If a service is not set for a particular method, a 404 Not Found error code will be returned. This router is intended for implementing the REST pattern where GET obtains a record, POST inserts the record, PUT updates the record, and DELETE removes the record.
Author:
jbanes
  • Constructor Details

    • RESTService

      public RESTService()
  • Method Details

    • getGET

      public Service getGET()
      The service handling the GET request
      Returns:
      the service handling the GET request, null if no service set
    • setGET

      public void setGET(Service get)
      Set the service to handle GET requests
      Parameters:
      get - the service to handle GET
    • getPOST

      public Service getPOST()
      The service handling the POST request
      Returns:
      the service handling the POST request, null if no service set
    • setPOST

      public void setPOST(Service post)
      Set the service to handle POST requests
      Parameters:
      post - the service to handle POST
    • getPUT

      public Service getPUT()
      The service handling the PUT request
      Returns:
      the service handling the PUT request, null if no service set
    • setPUT

      public void setPUT(Service put)
      Set the service to handle PUT requests
      Parameters:
      put - the service to handle PUT
    • getDELETE

      public Service getDELETE()
      The service handling the DELETE request
      Returns:
      the service handling the DEKETE request, null if no service set
    • setDELETE

      public void setDELETE(Service delete)
      Set the service to handle DELETE requests
      Parameters:
      delete - the service to handle DELETE
    • getService

      public Service getService(String method)
      Obtain the service handling the given method
      Parameters:
      method - the HTTP method in uppercase characters
      Returns:
      the service handling the given method or null if there is no handler
    • getDestinationService

      public Service getDestinationService(HttpRequest request)
      Description copied from interface: Routable
      Obtain the service that will handle this request.
      Specified by:
      getDestinationService in interface Routable
      Parameters:
      request - the object representing the http request
      Returns:
      the service that will handle this request, or null if it cannot be routed
    • execute

      public void execute(HttpRequest request, HttpResponse response)
      Description copied from interface: Service
      Executes the service, processing the HTTP request and generating a response.
      Specified by:
      execute in interface Service
      Parameters:
      request - The HTTP request to process
      response - The HTTP response to populate