public abstract class AbstractMethodHandler
extends java.lang.Object
HTTP request processing abstract class.
Both the default and extended HTTP request processing classes inherit this class. For example, the process of customizing the HTTP request handler is as follows:
A simple extension of the HTTP request processing class is implemented as follows, the processor only handles GET requests and generates only XML-formatted representations:
public class MyMethodHandler extends AbstractMethodHandler { public void handleGet(ResourceBase targetResource, Request request, Response response) { // TODO Auto-generated method stub Encoder encoder = null; if (targetResource.isResourceExist()) { //Forced to use the XML expression generators. encoder = new XMLEncoder(); Object content = targetResource.getResourceContent(); if (content != null) { // Regardless of the request, the representation of the XML-formatted resource is returned. Representation entity = encoder.toRepresentation(MediaType.TEXT_XML, content); response.setEntity(entity); response.setStatus(Status.SUCCESS_OK); } else { // Resources are not shown. response.setStatus(Status.SUCCESS_NO_CONTENT); } } else { // There is no exception in processing resources. response.setStatus(Status.CLIENT_ERROR_NOT_FOUND); } } public void handleHead(ResourceBase arg0, Request arg1, Response arg2) { // TODO Auto-generated method stub } public void handleOptions(ResourceBase arg0, Request arg1, Response arg2) { // TODO Auto-generated method stub } public void handlePost(ResourceBase arg0, Request arg1, Response arg2) { // TODO Auto-generated method stub } public void handlePut(ResourceBase arg0, Request arg1, Response arg2) { // TODO Auto-generated method stub } public void handleDelete(ResourceBase arg0, Request arg1, Response arg2) { } }
Constructor and Description |
---|
AbstractMethodHandler() |
Modifier and Type | Method and Description |
---|---|
abstract void |
handleDelete(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handleDelete_Title}
|
abstract void |
handleGet(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handleGet_Title}
|
abstract void |
handleHead(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handleHead_Title}
|
abstract void |
handleOptions(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handleOptions_Title}
|
abstract void |
handlePost(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handlePost_Title}
|
abstract void |
handlePut(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handlePut_Title}
|
public abstract void handleGet(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handleGet_Title}
${services_rest_MethodHandler_method_handleGet_Description}
targetResource
- ${services_rest_MethodHandler_method_handleGet_param_targetResource}request
- ${services_rest_MethodHandler_method_handleGet_param_request}response
- ${services_rest_MethodHandler_method_handleGet_param_response}public abstract void handlePut(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handlePut_Title}
${services_rest_MethodHandler_method_handlePut_Description}
targetResource
- ${services_rest_MethodHandler_method_handlePut_param_targetResource}request
- ${services_rest_MethodHandler_method_handlePut_param_request}response
- ${services_rest_MethodHandler_method_handlePut_param_response}public abstract void handlePost(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handlePost_Title}
${services_rest_MethodHandler_method_handlePost_Description}
targetResource
- ${services_rest_MethodHandler_method_handlePost_param_targetResource}request
- ${services_rest_MethodHandler_method_handlePost_param_request}response
- ${services_rest_MethodHandler_method_handlePost_param_response}public abstract void handleDelete(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handleDelete_Title}
${services_rest_MethodHandler_method_handleDelete_Description}
targetResource
- ${services_rest_MethodHandler_method_handleDelete_param_targetResource}request
- ${services_rest_MethodHandler_method_handleDelete_param_request}response
- ${services_rest_MethodHandler_method_handleDelete_param_response}public abstract void handleHead(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handleHead_Title}
${services_rest_MethodHandler_method_handleHead_Description}
targetResource
- ${services_rest_MethodHandler_method_handleHead_param_targetResource}request
- ${services_rest_MethodHandler_method_handleHead_param_request}response
- ${services_rest_MethodHandler_method_handleHead_param_response}public abstract void handleOptions(ResourceBase targetResource, Request request, Response response)
${services_rest_MethodHandler_method_handleOptions_Title}
${services_rest_MethodHandler_method_handleOptions_Description}
targetResource
- ${services_rest_MethodHandler_method_handleOptions_param_targetResource}request
- ${services_rest_MethodHandler_method_handleOptions_param_request}response
- ${services_rest_MethodHandler_method_handleOptions_param_response}