-
- All Implemented Interfaces:
-
com.onesignal.common.services.IServiceBuilder
public final class ServiceBuilder implements IServiceBuilder
-
-
Constructor Summary
Constructors Constructor Description ServiceBuilder()
-
Method Summary
Modifier and Type Method Description final <T extends Any> ServiceRegistration<T>register()A reified version of register to allow the use of generics when registering a service. <T extends Any> ServiceRegistration<T>register(Class<T> c)Register T as an implementation managed by the service infrastructure. <T extends Any> ServiceRegistration<T>register(Function1<IServiceProvider, T> create)Register T as an implementation managed by the service infrastructure. <T extends Any> ServiceRegistration<T>register(T obj)Register T as an implementation managed by the service infrastructure. ServiceProviderbuild()Build the registered implementations, mapping the services they provide, and return the IServiceProvider that will be able to retrieve instances of those provided services. -
-
Method Detail
-
register
final <T extends Any> ServiceRegistration<T> register()
A reified version of register to allow the use of generics when registering a service.
-
register
<T extends Any> ServiceRegistration<T> register(Class<T> c)
Register T as an implementation managed by the service infrastructure. It is expected a service will be provided by this implementation via a subsequent call to IServiceRegistration.
The implementation will be instantiated via reflection when required. This requires all constructor parameters on this implementation to also have an implementation registered and relevant service provided.
-
register
<T extends Any> ServiceRegistration<T> register(Function1<IServiceProvider, T> create)
Register T as an implementation managed by the service infrastructure. It is expected a service will be provided by this implementation via a subsequent call to IServiceRegistration.
The first time a service provided by this implementation is required, this create lambda will be executed to instantiate the instance.
- Parameters:
create- The lambda that will be called when this implementation must be instantiated.
-
register
<T extends Any> ServiceRegistration<T> register(T obj)
Register T as an implementation managed by the service infrastructure. It is expected a service will be provided by this implementation via a subsequent call to IServiceRegistration.
The instance of the implementation is provided at registration time.
- Parameters:
obj- The instance of the implementation that will be used.
-
build
ServiceProvider build()
Build the registered implementations, mapping the services they provide, and return the IServiceProvider that will be able to retrieve instances of those provided services.
-
-
-
-