This section will implement a service provider based on the previous section: Creating a service component.
In this section, we'll improve the following aspects to the example provided in Creating a service component:
- The weather information was directly specified in the code, while here we will create a service provider: TemperatureProvider, which gets the weather information by reading a Temperature.txt file.
- The Temperature.txt file will be configured through the iserver-services.xml file and is not longer directly specified in the code.
- In previous section, MapProvider was internally created within the Temperature service component, and the providers attribute of the component node in iserver-services.xml file was empty. While here we'll configure independent providers in service-services.xml, one is MapProvider, one is TemperatureProvider, the calling of which by the service component will be based on the dependency injection method provided by SuperMap iServer.
- The map to be accessed was internally specified in the Temperature service component, while here we'll set the map name by modifying the child element config of the component node in the iserver-services.xml file.
Main contents:
Note: All the above improvements are based on the example provided in previous section: Creating a service component, so all the codes in previous section will be used in this part.