public class ServiceManager extends Object
setEndPoint(EndPoint). This end point is than attached to each ServiceConnection
object that is created whenever a desired services PROXY instance is requested via services(Class)
or its configuration is requested via servicesConfiguration(Class).
As it is described in ServiceManager.ServicesConfiguration class, each services configuration object
caches its services PROXY instance and re-creates it only in case of configuration change. Also
ServiceManager caches each instance of these configuration objects and maps them to theirs
corresponding services interface.
| Modifier and Type | Class and Description |
|---|---|
static class |
ServiceManager.ServicesConfiguration<S>
Class used for configuration of a specific Retrofit services interface.
|
| Constructor and Description |
|---|
ServiceManager()
Creates a new instance of ServiceManager without specified end point.
|
ServiceManager(EndPoint endPoint)
Creates a new instance of ServiceManager with the specified endPoint.
|
| Modifier and Type | Method and Description |
|---|---|
EndPoint |
getEndPoint()
Returns the end point specified for this manager.
|
protected ServiceManager.ServicesConfiguration |
onCreateServicesConfiguration(Class<?> servicesInterface)
Invoked whenever
servicesConfiguration(Class) or services(Class) is called
for the first time for the specified servicesInterface. |
<S> S |
services(Class<S> servicesInterface)
Returns the PROXY instance for the requested servicesInterface.
|
<S> ServiceManager.ServicesConfiguration<S> |
servicesConfiguration(Class<S> servicesInterface)
Returns the services configuration object for the requested servicesInterface.
|
void |
setEndPoint(EndPoint endPoint)
Sets an end point for this manager.
|
void |
setEndPoint(String baseUrl)
Same as
setEndPoint(EndPoint) with EndPoint instance providing the given baseUrl
as its base url via EndPoint.getBaseUrl(). |
public ServiceManager()
setEndPoint(EndPoint)public ServiceManager(EndPoint endPoint)
endPoint - The desired end point. This end point will be attached to each services
configuration created via onCreateServicesConfiguration(Class).getEndPoint()public void setEndPoint(String baseUrl)
setEndPoint(EndPoint) with EndPoint instance providing the given baseUrl
as its base url via EndPoint.getBaseUrl().baseUrl - Base url of the desired end point.public void setEndPoint(EndPoint endPoint)
The specified end point will be attached to each services configuration created via
onCreateServicesConfiguration(Class).
endPoint - The desired end point.getEndPoint()public EndPoint getEndPoint()
null if no end
point has been specified.public <S> S services(Class<S> servicesInterface)
Each services interface can be configured via its corresponding configuration object that can
be obtained via servicesConfiguration(Class).
S - Type of the services interface.servicesInterface - The services interface for which to access its PROXY instance.servicesConfiguration(Class)public <S> ServiceManager.ServicesConfiguration<S> servicesConfiguration(Class<S> servicesInterface)
S - Type of the services interface.servicesInterface - The services interface for which to return its configuration.ServiceManager.ServicesConfiguration,
services(Class)protected ServiceManager.ServicesConfiguration onCreateServicesConfiguration(Class<?> servicesInterface)
servicesConfiguration(Class) or services(Class) is called
for the first time for the specified servicesInterface.
Default implementation creates a new instance of ServicesConfiguration with the given services interface and end point specified for this manager (if any).
Custom implementations of ServiceManager may override this method to perform default services configuration for them specific.
servicesInterface - Class of the services interface for which to create new configuration
object.