Package org.jboss.weld.bootstrap.api
Interface ServiceRegistry
- All Known Implementing Classes:
ForwardingServiceRegistry,SimpleServiceRegistry
A service registry
- Author:
- Pete Muir
-
Method Summary
Modifier and TypeMethodDescription<S extends Service>
voidAdd a servicevoidAdd services<S extends Service>
SaddIfAbsent(Class<S> type, S service) Add a service if no implementation of the given service is registered with the registry yet.voidcleanup()Clear up the services registered, by callingService.cleanup()on each registered servicevoidClean upBootstrapServices by callingBootstrapService.cleanupAfterBoot()on each registeredBootstrapService.<S extends Service>
booleanCheck if a service is registeredentrySet()Returns a set of all service entries<S extends Service>
SRetrieve a service implementationgetOptional(Class<S> type) Retrieve a service implementation wrapped inOptional.<S extends Service>
SgetRequired(Class<S> type) Retrieve a required service implementation.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
add
Add a service- Type Parameters:
S- the service type to add- Parameters:
type- the service type to addservice- the service implementation- See Also:
-
addIfAbsent
Add a service if no implementation of the given service is registered with the registry yet. Returns null if the given service was added. Otherwise, the previous service implementation is returned.- Type Parameters:
S- the service type to add- Parameters:
type- the service type to addservice- the service implementation- Returns:
- null if no service implementation was previously associated with the given service. Otherwise, the previous service implementation is returned.
-
addAll
Add services- Parameters:
services- services to be added
-
entrySet
Returns a set of all service entries- Returns:
- all service entries as a set
-
get
Retrieve a service implementation- Type Parameters:
S- the service type- Parameters:
type- the service type- Returns:
- the service implementation, or null if none is registered
-
getOptional
Retrieve a service implementation wrapped inOptional.- Type Parameters:
S- the service type- Parameters:
type- the service type- Returns:
- the service implementation wrapped within
Optional
-
getRequired
Retrieve a required service implementation. Throws an exception if the service is not available- Type Parameters:
S- the service type- Parameters:
type- the service type- Returns:
- the service implementation
- Throws:
IllegalStateException- if the service is not available
-
contains
Check if a service is registered- Type Parameters:
S- the service type- Parameters:
type- the service type- Returns:
- true if a service is registered, otherwise false
-
cleanup
void cleanup()Clear up the services registered, by callingService.cleanup()on each registered service -
cleanupAfterBoot
void cleanupAfterBoot()Clean upBootstrapServices by callingBootstrapService.cleanupAfterBoot()on each registeredBootstrapService.
-