uCosminexus Application Server, Web Service Development Guide
Description
This method acquires a map containing all the features.
Syntax
public Map<String,Boolean> getFeatures()
Parameter
None.
Return value
The method returns a feature map. The method does not return null.
Notes
An example of using the getFeatures() method is as follows:
// Generate a ClientConfig object
ClientConfig cc = new DefaultClientConfig();
// Add a feature to enable JSON POJO mapping
// in the ClientConfig object
cc.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true);
// Specify the ClientConfig object generated above and
// create the Client object
Client client = Client.create(cc);
// Set the property read timeout
client.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, 10000);
// Generate a POJO object that maps to the JSON format
Pojo pojo = new Pojo();
// Generate an HTTP request and send the mapped POJO object
ClientRequest cRequest = ClientRequest.create().entity(pojo).type("application/json").build(new URI("http://example.com/example"), "POST");
try{
// Receive the HTTP response as the ClientResponse object
ClientResponse cResponse = client.handle(cRequest);
} catch(ClientHandlerException e){
// Execute the appropriate processing
}
|
In this example, initially a changeable property map is acquired with the getFeatures method and then, the feature to enable the JSON POJO mapping is added. Then, the ClientRequest object is created, the handle() method of the Client class is used to perform the HTTP communication, and the HTTP response is received as the ClientResponse object. The POJO object that was sent as the HTTP request entity is mapped in the JSON format according to the JSON POJO mapping. This is achieved with the features added for enabling the JSON POJO mapping.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.