JAX-RS-based extension

Feedback


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:
  1. It provides the resource base class: JaxrsResourceBase and JaxAlgorithResultSetResource<T>, for users to extend and implement the new resource.
  2. SuperMap iServer provides several output formats like xml, json and rjson. Resource created based on the base class support the output formats by default.
  3. It provides the @Template annotation, and a series of FreeMarker variables, for users to customize the *.ftl template and configurate it to the resource. Therefore, the resource can support the html output format.
  4. It provides the JSON decoder. The default identification type of the resource created based on the resource base class is the JSON format.
  5. It provides the service interface context (InterfaceContext). The resource created based on the base class can get the service component and other information through InterfaceContext.
  6. The domain functionalities are tightly attached to the three-layer architecture of SuperMap iServer, which induces the creation of domain resources through the combination with the current GIS functionalities.

Therefore, the REST resource extensions based on JAX-RS include:

The extend flow is as follows:

  1. 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.

  1. Configuration

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.