通过 XML 文件配置服务组件

发送反馈


服务组件对不同服务提供者的功能进行组合和封装,封装成粒度较粗的模块,例如地图组件、数据组件等,同时支持将一个或多个服务组件组装成服务组件集合提供服务。服务组件的配置是在<component>节点中进行,服务组件集合的配置在<componentSet>节点中进行。

服务组件和服务组件集都可以与服务接口相结合来提供服务实例,假设已配置了一个名为 rest 的 REST 服务接口(参见:服务接口层的配置),在以上 map-world 组件的配置中,已经绑定了“rest”接口,则 map-world 组件与 rest 服务接口组合提供的服务实例的 URI 依次如下:

http://<server>:<port>/iserver/services/map-world/rest

http://<server>:<port>/iserver/services/components-rest/rest

分别表示 map-world 服务组件包含的 REST 服务的根目录和 components-rest 组件集包含的 REST 服务的根目录,通过后者,可以访问到 map-world、data-world、3D-sample、transportationanalyst-sample 几个服务组件包含的全部 REST 服务。

其中,不同服务组件绑定的服务接口类型也是不完全相同的,目前 SuperMap iServer 中服务组件与服务接口的对应情况如表1_服务组件与服务接口对照表所示。

表1 服务组件与服务接口对照表

服务组件类型 服务接口类型 预定义的服务接口
地图服务组件
(MapImpl)
REST 接口(RestServlet)
ArcGIS REST 接口(AGSRestServlet)
Baidu REST 接口 (BaiduRestServlet)
Google REST 接口 (GoogleRestServlet)
WMS 接口(WMSServlet)
WMTS 接口(WMTSServlet)
rest、arcgisrest1、baidurest1、googlerest1
wms111、wms130
wmts100、wmts-china
数据服务组件
(DataImpl)
REST 接口(RestServlet)
ArcGIS REST 接口(AGSRestServlet)
WFS 接口(WFSSServlet)
WCS 接口(WCSServlet)
rest 、arcgisrest1
wfs100、wfs200
wcs111、wcs112
影像服务组件
(ImageImpl)
REST/JSR 接口(JaxrsServletForJersey)
WMTS 接口(WMTSServlet)
restjsr,wmts100
空间分析服务组件
(SpatialAnalystImpl)
REST/JSR 接口(JaxrsServletForJersey)
WPS 接口(WPSServlet)
restjsr
wps100
交通网络分析服务组件
(TransportationAnalystImpl)
REST 接口(RestServlet)
ArcGIS REST 接口(AGSRestServlet)
rest、arcgisrest1
交通换乘分析服务组件
(TrafficTransferAnalystImpl)
REST/JSR 接口(JaxrsServletForJersey) restjsr
三维服务组件
(RealspaceImpl)
REST 接口(RestServlet) rest
三维网络分析
(NetworkAnalyst3DImpl)
REST/JSR 接口(JaxrsServletForJersey) restjsr
空间建模服务组件
(GeoprocessorComponent)
GP 接口(GeoprocessorServlet) gpserver
动态标绘服务组件
(PlotImpl)
REST接口(RestServlet) rest
地址匹配服务组件
(AddressMatchImpl)
REST接口(RestServlet)

restjsr

注1:iServer高级版和iEdge提供该接口。

服务组件配置基本结构

<component> 和 <componentSet> 在配置文件中的结构如下所示:

<application>
                ...
                <componentSets>
                        ...
                        <componentSet>
                              ...
                        <componentSet/>
                </componentSets>
                <components>
                        ...
                        <component>
                             ...
                        <component/>
                </components>
</application>

地图组件配置

地图服务组件配置示例:

<component name="map-china400" class="com.supermap.services.components.impl.MapImpl"
     interfaceNames="rest,wms111,wms130,wmts100,wmts-china" providers="ugcMapProvider-China400">
        <config class="com.supermap.services.components.MapConfig">
           <useCache>false</useCache> 
           <tileCacheConfig class="com.supermap.services.tilesource.SMTilesTileSourceInfo"> 
               <datastoretype>TILES</datastoretype>
               <outputPath>D:/supermap/soft/supermap_iserver/webapps/iserver/output/sqlite</outputPath> 
           </tileCacheConfig>  
           <utfGridCacheConfig class="com.supermap.services.tilesource.UTFGridTileSourceInfo"> 
               <datastoretype>TILES</datastoretype>
               <type>UTFGrid</type>  
               <outputPath>D:/supermap/soft/supermap_iserver/webapps/iserver/output/sqlite</outputPath> 
           </utfGridCacheConfig>  
           <vectorTileCacheConfig class="com.supermap.services.tilesource.SVTilesTileSourceInfo"> 
               <datastoretype>TILES</datastoretype>
               <type>SVTiles</type>  
           </vectorTileCacheConfig>  
               <useUTFGridCache>false</useUTFGridCache>
               <useVectorTileCache>true</useVectorTileCache>
           <expired>0</expired> 
           <cacheReadOnly>false</cacheReadOnly> 
        </config>
</component>

其中<component>节点的 class 属性标识的是地图组件的实现类;providers 属性是地图组件用到的服务提供者(集合),(参见:服务提供者层的配置);interfaceNames 属性标识的是服务组件绑定的服务接口,多个服务接口之间用“,”分隔,参见:服务接口层的配置。<config>节点是该地图组件实现对应的配置项,对应接口配置类MapConfig,以下参数均为可选参数:

数据服务组件配置

数据服务组件配置示例:

<component name="data-world" class="com.supermap.services.components.impl.DataImpl"
           interfaceNames="rest,wfs100,wfs200,wcs111,wcs112" providers="ugcDataProvider-World"> 
      <config class="com.supermap.services.components.DataConfig">
         <editable>true</editable>
         <cacheStrategyConfig>
            <maxElementInMemory>100</maxElementInMemory>
            <timeToLiveSeconds>3</timeToLiveSeconds>
            <timeToIdleSeconds>3</timeToIdleSeconds>
         </cacheStrategyConfig>
      </config> 
</component>

其中,<component>节点的 class 属性标识组件类型,对应实现类 DataImpl,<config>节点是该 Data 组件对应的配置项,即接口配置类DataConfig。主要参数说明:

影像服务组件配置

影像服务组件配置示例:

    <component class="com.supermap.services.components.impl.ImageImpl" enabled="true" initPriority="0" instanceCount="0" interfaceNames="wmts100,restjsr" name="imageservice-ChinaImages" providers="imageservice-ChinaImages">
      <config class="com.supermap.services.components.ImageConfig"> 
        <editable>false</editable>
        <downloadable>false</downloadable> 
      </config>
    </component>

其中,<component>节点的 class 属性标识组件类型,对应实现类 ImageImpl,<config>节点是该影像服务组件对应的配置项,即接口配置类ImageConfig。主要参数说明:

服务组件集合配置

<componentSet>节点可以将一个或多个服务组件组装成服务组件集,一个<componentSet>节点的示例如下:

<componentSet name="components-rest">
        <component-reference  name="map-world"></component-reference>
        <component-reference  name="3D-sample"></component-reference>
        <component-reference  name="data-world"></component-reference>
        <component-reference  name="transportationanalyst-sample"></component-reference>
</componentSet>

自定义服务组件配置

添加一个自定义组件类型,在系统配置文件(iserver-system.xml)中配置,示例如下:

<component-type  alias="SuperMap 自定义服务组件" configClass="com.supermap.services.components.SMConfig">
   com.supermap.services.components.impl.SMImpl
</component-type> 

其中 com.supermap.services.components.impl.SMImpl 是自定义的服务组件类型的实现类,com.supermap.services.components.SMConfig 是自定义的服务组件类型的配置类。

<component-type>节点在配置文件中的结构如下所示:

<server>
     <management>
              …
         <component-types>
                  …
               <component-type>
                      …
               </component-type> 
 
         </component-types>
      </management>
</server>

开启动态化管理的服务组件配置

以数据服务组件为例,示例如下:

<component name="data-world" class="com.supermap.services.components.impl.DataImpl" enabled="true" initOnCreate="true" initPriority="0" 
           instanceCount="0" interfaceNames="rest,wfs100,wfs200,wcs111,wcs112" providers="ugcDataProvider-World"> 
      <config class="com.supermap.services.components.DataConfig">
            <editable>true</editable>
      </config> 
</component>

其中,对于<component>节点:

注意,只有开启服务实例动态化功能后,该参数才有效。