ServiceRegistry
is used to allow a given application access to application services.
Services are typically registered or requested using an alias name, but older applications may still register and request using interfaces, which is also still supported. Applications that use aliases don't normally need to manually register services as these are created lazilly upon first request, but will still need to manually register services that can't be created using a zero-arg constructor.
The ServiceRegistry
is initialized as follows:
Because blades aren't allowed to depend directly on classes in other blades, interface definitions are instead
created for particular pieces of functionality, and blades can choose to register themselves as being providers of
that functionality. The ServiceRegistry
and the caplin.core.event.EventHub are both useful
in this regard:
ServiceRegistry
.Attributes | Name and Description |
---|---|
|
caplin.core.ServiceRegistry()
The |
Attributes | Name and Description |
---|---|
<static>
|
void
clear()
Resets the |
<static>
|
void
deregisterService(String sIdentifier)
De-register a service that is currently registered in the |
<static>
|
Object
getService(String sIdentifier)
Retrieve the service linked to the identifier within the application. |
<static>
|
void
initializeServices(Function fSuccessCallback, Function fErrorCallback)
Registering with this method will notify when all services that implement caplin.core.DelayedReadinessService are ready to use. |
<static>
|
boolean
isServiceRegistered(String sIdentifier)
Determine whether a service has been registered for a given identifier. |
<static>
|
void
registerService(String sIdentifier, Object oServiceInstance)
Register an object that will be responsible for implementing the given interface within the application. |
►
caplin.core.ServiceRegistry()
The ServiceRegistry
is a static class and does not need to be constructed.
►
<static>
void
clear()
Resets the ServiceRegistry
back to its initial state.
This method isn't normally called within an application, but is called automatically before each test is run.
►
<static>
void
deregisterService(String sIdentifier)
De-register a service that is currently registered in the ServiceRegistry
.
String | sIdentifier | The alias or interface name used to uniquely identify the service. |
►
<static>
Object
getService(String sIdentifier)
Retrieve the service linked to the identifier within the application. The identifier could be a service alias or a service interface.
String | sIdentifier | The alias or interface name used to uniquely identify the service. |
►
<static>
void
initializeServices(Function fSuccessCallback, Function fErrorCallback)
Registering with this method will notify when all services that implement caplin.core.DelayedReadinessService are ready to use.
Function | fSuccessCallback | the function that is called back when all services implementing caplin.core.DelayedReadinessService are ready for use. |
Function | fErrorCallback | the function that is called back if there is an error during initialization of any of the services, a string reason will be passed in as argument. |
►
<static>
boolean
isServiceRegistered(String sIdentifier)
Determine whether a service has been registered for a given identifier.
String | sIdentifier | The alias or interface name used to uniquely identify the service. |
►
<static>
void
registerService(String sIdentifier, Object oServiceInstance)
Register an object that will be responsible for implementing the given interface within the application. Note: If the application is using aliases to access services this method is not relevant.
String | sIdentifier | The alias or interface name used to uniquely identify the service. |
Object | oServiceInstance | The object responsible for providing the service. |