registerServices

The registerService API is used by the Super App to register the services (such as the services provided by SPIs).

Method signature

copy
void registerServices(Class<? extends BaseService>... serviceClasses) throws BaseService.NoServiceMetaInfoException, BaseService.ServiceRegisterException

Request parameters

Field

Data type

Description

Required

serviceClasses

Class<? extends BaseService>

The list of service classes to be registered

No

Response parameters

N/A

Exceptions

Message

Description

Service initialization error [10001]

Catch IllegalAccessException

Service initialization error [10002]

Catch InstantiationException

Service initialization error [10003]

Catch InvocationTargetException

No default null constructor found. Please ensure a null constructor is available

Catch NoSuchMethodException

Samples

Java

copy
try {
    Class[] services = new Class[]{
        //xxServiceImpl.class
    };
    WalletServiceManager.getInstance().registerServices(services);
} catch (BaseService.NoServiceMetaInfoException | BaseService.ServiceRegisterException e) {
    //Handle exceptions;
}

Kotlin

copy
try {
    val services = arrayOf(
        //xxServiceImpl::class.java
    )
    WalletServiceManager.getInstance().registerServices(*services)
} catch (e: NoServiceMetaInfoException) {
    //Handle exceptions
} catch (e: ServiceRegisterException) {
    //Handle exceptions
}