Package org.jboss.weld.bootstrap.api
Interface ServiceRegistry
-
- All Known Implementing Classes:
ForwardingServiceRegistry
,SimpleServiceRegistry
public interface ServiceRegistry extends Iterable<Service>
A service registry- Author:
- Pete Muir
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <S extends Service>
voidadd(Class<S> type, S service)
Add a servicevoid
addAll(Collection<Map.Entry<Class<? extends Service>,Service>> services)
Add 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.void
cleanup()
Clear up the services registered, by callingService.cleanup()
on each registered servicevoid
cleanupAfterBoot()
Clean upBootstrapService
s by callingBootstrapService.cleanupAfterBoot()
on each registeredBootstrapService
.<S extends Service>
booleancontains(Class<S> type)
Check if a service is registeredSet<Map.Entry<Class<? extends Service>,Service>>
entrySet()
<S extends Service>
Sget(Class<S> type)
Retrieve a service implementation<S extends Service>
Optional<S>getOptional(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 Detail
-
add
<S extends Service> void add(Class<S> type, S service)
Add a service- Type Parameters:
S
- the service type to add- Parameters:
type
- the service type to addservice
- the service implementation- See Also:
Service
-
addIfAbsent
<S extends Service> S addIfAbsent(Class<S> type, S service)
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
void addAll(Collection<Map.Entry<Class<? extends Service>,Service>> services)
Add services- Parameters:
services
- services to be added
-
get
<S extends Service> S get(Class<S> type)
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
<S extends Service> Optional<S> getOptional(Class<S> type)
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
<S extends Service> S getRequired(Class<S> type)
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
<S extends Service> boolean contains(Class<S> type)
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 upBootstrapService
s by callingBootstrapService.cleanupAfterBoot()
on each registeredBootstrapService
.
-
-