CodeIdentificationService#init
Use this API to initialize the code identification service when the system gets started. This API is used to load route configuration data and schedule the updates of route configuration.
In the initialization process, the Alipay+ server SDK tries to load route configuration data from high-priority sources firstly, including remote server, local storage, and preset configuration. Once route configurations are loaded successfully, route configurations from lower-priority sources are not read. In addition, you can specify the minimum required level of the sources by the ac.route.init-route-config-level property. The initialization fails if loading from the minimum-level source fails.
It is recommended that you call this API during spring context initialization and block the application startup when the returned result is not SUCCESS
because the Alipay+ server SDK cannot make identifications when the SDK initialization failed. If you do not want to block the startup, the PRESET level might be set in the ac.route.init-route-config-level property to ensure that the SDK initialization is successful.
Request parameters
N/A
Response parameters
CodeIdentificationInitResult
Item | Type | Length | Description | Required |
result | / | Request result, which contains information such as status and error codes. See Result for details. | M |
Result
Item | Type | Length | Description | Required |
resultCode | String | 16 | Result code | M |
resultStatus | String | / | Result status. Valid values are:
| M |
resultMessage | String | 64 | Result message that describes | O |
Result code
resultCode | resultStatus | resultMessage |
SUCCESS | S | Success |
INIT_CONFIG_IS_INVALID | F | Initial configuration is invalid. |
REMOTE_CONFIG_UPDATE_FAILED | F | Remote configuration update failed. |
STORAGE_CONFIG_LOAD_FAILED | F | Loading storage configuration failed. |
PARAM_ILLEGAL | F | Illegal parameters exist. For example, a non-numeric input, or an invalid date. |
UNKNOWN_EXCEPTION | U | The API calling failed because of unknown reasons. |
Result processing logic
- If result.resultStatus is
S
, initialization is successful. - If result.resultStatus is
F
orU
, the application startup is blocked and the MPP can troubleshoot the issue based on result codes and logs.
Sample
CodeIdentificationInitResult result = codeIdentificationService.init();
if (result.getResult().getResultStatus().equals("S")){
// Initialization success.
} else {
// Block the application startup and troubleshoot
}