getRequiredService

Retrieves a required service by name, throwing an exception if not found. This method guarantees that a service is returned or an exception is thrown.

Return

the service instance of type S

Parameters

S

the type of service to retrieve

serviceName

the name of the service to look up

Throws

if the service is not found

Samples


Retrieves a required service by Kotlin type, throwing an exception if not found. This method guarantees that a service is returned or an exception is thrown.

Return

the service instance of type S

Parameters

S

the type of service to retrieve

serviceType

the Kotlin type to look up

Throws

if the service is not found


fun <S : Any> ServiceProvider.getRequiredService(serviceType: Class<S>): S

Retrieves a required service by Java class, throwing an exception if not found. This method guarantees that a service is returned or an exception is thrown.

Return

the service instance of type S

Parameters

S

the type of service to retrieve

serviceType

the Java class to look up

Throws

if the service is not found


Retrieves a required service using reified type information, throwing an exception if not found. This is a convenience extension that automatically uses the reified type for lookup.

Return

the service instance of type S

Parameters

S

the type of service to retrieve

Throws

if the service is not found

Samples