Class LLServices
java.lang.Object
com.io7m.looseleaf.server.internal.services.LLServices
- All Implemented Interfaces:
Closeable,AutoCloseable
The main service directory implementation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()<T extends LLServiceType>
Optional<T>optionalService(Class<T> clazz) Fetch an optional service reference.<T extends LLServiceType>
List<? extends T>optionalServices(Class<T> clazz) Fetch a set of optional service references.<T extends LLServiceType>
voidRegister the given service.<T extends LLServiceType>
TrequireService(Class<T> clazz) Fetch a required service reference.services()
-
Constructor Details
-
LLServices
public LLServices()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
Fetch an optional service reference.- Type Parameters:
T- The type of service- Parameters:
clazz- The service class- Returns:
- A service, if one is registered
-
requireService
Fetch a required service reference.- Type Parameters:
T- The type of service- Parameters:
clazz- The service class- Returns:
- A service, if one is registered
- Throws:
LLServiceException- If no service is registered of the given type
-
optionalServices
public <T extends LLServiceType> List<? extends T> optionalServices(Class<T> clazz) throws LLServiceException Fetch a set of optional service references.- Type Parameters:
T- The type of service- Parameters:
clazz- The service class- Returns:
- The registered services, if any
- Throws:
LLServiceException- On errors
-
services
- Returns:
- The list of registered services
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-