Class RESTService
java.lang.Object
com.invirgance.convirgance.web.service.RESTService
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(HttpRequest request, HttpResponse response) Executes the service, processing the HTTP request and generating a response.The service handling the DELETE requestgetDestinationService
(HttpRequest request) Obtain the service that will handle this request.getGET()
The service handling the GET requestgetPOST()
The service handling the POST requestgetPUT()
The service handling the PUT requestgetService
(String method) Obtain the service handling the given methodvoid
Set the service to handle DELETE requestsvoid
Set the service to handle GET requestsvoid
Set the service to handle POST requestsvoid
Set the service to handle PUT requests
-
Constructor Details
-
RESTService
public RESTService()
-
-
Method Details
-
getGET
The service handling the GET request- Returns:
- the service handling the GET request, null if no service set
-
setGET
Set the service to handle GET requests- Parameters:
get
- the service to handle GET
-
getPOST
The service handling the POST request- Returns:
- the service handling the POST request, null if no service set
-
setPOST
Set the service to handle POST requests- Parameters:
post
- the service to handle POST
-
getPUT
The service handling the PUT request- Returns:
- the service handling the PUT request, null if no service set
-
setPUT
Set the service to handle PUT requests- Parameters:
put
- the service to handle PUT
-
getDELETE
The service handling the DELETE request- Returns:
- the service handling the DEKETE request, null if no service set
-
setDELETE
Set the service to handle DELETE requests- Parameters:
delete
- the service to handle DELETE
-
getService
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
Description copied from interface:Routable
Obtain the service that will handle this request.- Specified by:
getDestinationService
in interfaceRoutable
- Parameters:
request
- the object representing the http request- Returns:
- the service that will handle this request, or null if it cannot be routed
-
execute
Description copied from interface:Service
Executes the service, processing the HTTP request and generating a response.
-