public class JsonServiceUtil extends Object
JSON service utility methods.
| Constructor and Description |
|---|
JsonServiceUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Object |
fromJson(FileReader fr,
Class<T> pojoClass)
Creates Java POJO object from JSON string.
|
static <T> Object |
fromJson(String jsonAsString,
Class<T> pojoClass)
Creates Java POJO object from JSON string.
|
protected static org.codehaus.jackson.node.ObjectNode |
getJsonServiceErrorNode(JsonServiceError jse) |
protected static org.codehaus.jackson.node.ObjectNode |
getJsonServiceErrorNode(JsonServiceError jse,
int id) |
static org.springframework.http.ResponseEntity<String> |
getResponseEntityForMethodCall(BufferedOutputStream bos)
This method sets HTTP response headers adequate for JSON-RPC method call
and returns ResponseEntity to be used by Spring Framework.
|
static org.springframework.http.ResponseEntity<String> |
getResponseEntityForMethodCall(BufferedOutputStream bos,
org.springframework.http.HttpStatus status)
This method sets HTTP response headers adequate for JSON-RPC method call
and returns ResponseEntity to be used by Spring Framework.
|
static org.springframework.http.ResponseEntity<String> |
getResponseEntityForServiceMap(BufferedOutputStream bos)
This method sets HTTP response headers adequate for Service Mapping
Description and returns ResponseEntity to be used by Spring Framework.
|
static org.springframework.http.ResponseEntity<String> |
handle(JsonServiceRegistry service,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Class<?> clazz)
Handles HTTP request.
|
static org.springframework.http.ResponseEntity<String> |
handle(JsonServiceRegistry service,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Object obj)
Handles HTTP request.
|
static void |
setHeadersForMethodCall(BufferedOutputStream bos,
javax.servlet.http.HttpServletResponse response)
This method sets HTTP response headers adequate for JSON-RPC method call.
|
static void |
setHeadersForMethodCall(BufferedOutputStream bos,
javax.servlet.http.HttpServletResponse response,
int status)
This method sets HTTP response headers adequate for JSON-RPC method call.
|
static void |
setHeadersForServiceMap(BufferedOutputStream bos,
javax.servlet.http.HttpServletResponse response)
This method sets HTTP response headers adequate for Service Mapping
Description.
|
static org.codehaus.jackson.node.ArrayNode |
toJson(List<?> list)
Converts a list to JSON array.
|
static org.codehaus.jackson.node.ObjectNode |
toJson(Map<?,?> map)
Converts a map to JSON object.
|
static String |
toJson(Object pojo,
boolean prettyPrint)
Serialises Java POJO object to JSON string.
|
static void |
toJson(Object pojo,
FileWriter fw,
boolean prettyPrint)
Serialises Java POJO object to JSON string.
|
public static void setHeadersForServiceMap(BufferedOutputStream bos, javax.servlet.http.HttpServletResponse response)
bos - Output streamresponse - HTTP response objectpublic static void setHeadersForMethodCall(BufferedOutputStream bos, javax.servlet.http.HttpServletResponse response)
bos - Output streamresponse - HTTP response objectpublic static void setHeadersForMethodCall(BufferedOutputStream bos, javax.servlet.http.HttpServletResponse response, int status)
bos - Output streamresponse - HTTP response objectstatus - HTTP response codepublic static org.springframework.http.ResponseEntity<String> getResponseEntityForServiceMap(BufferedOutputStream bos)
bos - Output streampublic static org.springframework.http.ResponseEntity<String> getResponseEntityForMethodCall(BufferedOutputStream bos)
bos - Output streampublic static org.springframework.http.ResponseEntity<String> getResponseEntityForMethodCall(BufferedOutputStream bos, org.springframework.http.HttpStatus status)
bos - Output streamstatus - HTTP response codepublic static org.springframework.http.ResponseEntity<String> handle(JsonServiceRegistry service, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Class<?> clazz) throws IOException
service - Service registry objectrequest - HTTP request objectresponse - HTTP response objectclazz - ClassIOExceptionpublic static org.springframework.http.ResponseEntity<String> handle(JsonServiceRegistry service, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object obj) throws IOException
service - Service registry objectrequest - HTTP request objectresponse - HTTP response objectobj - Already instantiated objectIOExceptionpublic static <T> Object fromJson(String jsonAsString, Class<T> pojoClass) throws org.codehaus.jackson.map.JsonMappingException, org.codehaus.jackson.JsonParseException, IOException
T - jsonAsString - JSON stringpojoClass - POJO classorg.codehaus.jackson.map.JsonMappingExceptionorg.codehaus.jackson.JsonParseExceptionIOExceptionpublic static <T> Object fromJson(FileReader fr, Class<T> pojoClass) throws org.codehaus.jackson.JsonParseException, IOException
T - fr - File stream to read JSON string.pojoClass - POJO classorg.codehaus.jackson.JsonParseExceptionIOExceptionpublic static String toJson(Object pojo, boolean prettyPrint) throws org.codehaus.jackson.map.JsonMappingException, org.codehaus.jackson.JsonGenerationException, IOException
pojo - POJO objectprettyPrint - JSON pretty printorg.codehaus.jackson.map.JsonMappingExceptionorg.codehaus.jackson.JsonGenerationExceptionIOExceptionpublic static void toJson(Object pojo, FileWriter fw, boolean prettyPrint) throws org.codehaus.jackson.map.JsonMappingException, org.codehaus.jackson.JsonGenerationException, IOException
pojo - POJO objectfw - File stream to write JSON string.prettyPrint - JSON pretty printorg.codehaus.jackson.map.JsonMappingExceptionorg.codehaus.jackson.JsonGenerationExceptionIOExceptionpublic static org.codehaus.jackson.node.ArrayNode toJson(List<?> list)
list - Listpublic static org.codehaus.jackson.node.ObjectNode toJson(Map<?,?> map)
map - Mapprotected static org.codehaus.jackson.node.ObjectNode getJsonServiceErrorNode(JsonServiceError jse)
protected static org.codehaus.jackson.node.ObjectNode getJsonServiceErrorNode(JsonServiceError jse, int id)
Copyright © 2016. All rights reserved.