Package com.io7m.idstore.services.api
Class IdServiceDirectory
java.lang.Object
com.io7m.idstore.services.api.IdServiceDirectory
- All Implemented Interfaces:
IdServiceDirectoryType,Closeable,AutoCloseable
A service directory.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()<T extends IdServiceType>
Optional<T>optionalService(Class<T> clazz) Get an optional reference to the given service.<T extends IdServiceType>
List<? extends T>optionalServices(Class<T> clazz) Get references to the given services.<T extends IdServiceType>
voidRegister the given service.<T extends IdServiceType>
TrequireService(Class<T> clazz) Get a required reference to the given service.services()
-
Constructor Details
-
IdServiceDirectory
public IdServiceDirectory()Construct a service directory.
-
-
Method Details
-
register
Register the given service.- Type Parameters:
T- The type of service- Parameters:
clazz- The service interfaceservice- The service
-
optionalService
Description copied from interface:IdServiceDirectoryTypeGet an optional reference to the given service.- Specified by:
optionalServicein interfaceIdServiceDirectoryType- Type Parameters:
T- The service type- Parameters:
clazz- The service interface- Returns:
- A service reference, if a service exists
-
requireService
Description copied from interface:IdServiceDirectoryTypeGet a required reference to the given service.- Specified by:
requireServicein interfaceIdServiceDirectoryType- Type Parameters:
T- The service type- Parameters:
clazz- The service interface- Returns:
- A service reference
- Throws:
IdServiceException- If no service exists
-
optionalServices
public <T extends IdServiceType> List<? extends T> optionalServices(Class<T> clazz) throws IdServiceException Description copied from interface:IdServiceDirectoryTypeGet references to the given services.- Specified by:
optionalServicesin interfaceIdServiceDirectoryType- Type Parameters:
T- The service type- Parameters:
clazz- The service interface- Returns:
- A service list, if services exist
- Throws:
IdServiceException- If no required
-
services
- Specified by:
servicesin interfaceIdServiceDirectoryType- Returns:
- A read-only list of all the services present
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-