JAX-RS-based extension |
SuperMap iServer not only provides REST services, publishing a large number of GIS functions as resource, but also provides an extension mechanism, adding users' applications to SuperMap iServer server, which can implement the custom resources to be a part of REST services.
SuperMap iServer has two ways to provide REST services: based on Restlet and JAX-RS. When extending, you should use different extending methods according to the implementation of function modules.
The REST resource module of SuperMap iServer implemented based on the JAX-RS is the spatial analysis module.
SuperMap iServer provides the resource extension mechanism based on the JAX-RS framework (refer to JAX-RS Introduction), which is used for the REST service extension:Therefore, the REST resource extensions based on JAX-RS include:
The extend flow is as follows:
Code implementation.
New resources implement based on com.supermap.services.rest.resources.JaxAlgorithResultSetResource or com.supermap.services.rest.resources.JaxrsResourceBase;
The Encoder implement based on javax.ws.rs.ext.MessageBodyWriter;
The Decoder implement based on javax.ws.rs.ext.MessageBodyReader.
Configuration
Extending the Encoder (consistent with Extending the Encoder for existing modules)
Extending the Decoder (consistent with Extending the Decoder for existing modules)
Here it introduces FakeKMLEncoder, FakeJsonDecoder and myBuffer. The source codes locate in: %SuperMap iServer_HOME%\samples\code\ExtendExist_JSR. It is an overall project file. Users only need to import this project and compile a JAR (See extendexist_jsr.jar). Then put Jar into %SuperMap iServer_HOME%\webapps\iserver\WEB-INF\lib,and restart iServer.