Class SimpleServiceRegistry
- java.lang.Object
-
- org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry
-
- All Implemented Interfaces:
Iterable<Service>,ServiceRegistry
public class SimpleServiceRegistry extends Object implements ServiceRegistry
A registry for services- Author:
- Pete Muir, Matej Novotny
-
-
Constructor Summary
Constructors Constructor Description SimpleServiceRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <S extends Service>
voidadd(Class<S> type, S service)Add a servicevoidaddAll(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.voidcleanup()Clear up the services registered, by callingService.cleanup()on each registered servicevoidcleanupAfterBoot()Clean upBootstrapServices 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()booleanequals(Object obj)protected Map<Class<? extends Service>,Service>get()<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.inthashCode()Iterator<Service>iterator()StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
add
public <S extends Service> void add(Class<S> type, S service)
Description copied from interface:ServiceRegistryAdd a service- Specified by:
addin interfaceServiceRegistry- Type Parameters:
S- the service type to add- Parameters:
type- the service type to addservice- the service implementation- See Also:
Service
-
addAll
public void addAll(Collection<Map.Entry<Class<? extends Service>,Service>> services)
Description copied from interface:ServiceRegistryAdd services- Specified by:
addAllin interfaceServiceRegistry- Parameters:
services- services to be added
-
entrySet
public Set<Map.Entry<Class<? extends Service>,Service>> entrySet()
- Specified by:
entrySetin interfaceServiceRegistry
-
get
public <S extends Service> S get(Class<S> type)
Description copied from interface:ServiceRegistryRetrieve a service implementation- Specified by:
getin interfaceServiceRegistry- Type Parameters:
S- the service type- Parameters:
type- the service type- Returns:
- the service implementation, or null if none is registered
-
getOptional
public <S extends Service> Optional<S> getOptional(Class<S> type)
Description copied from interface:ServiceRegistryRetrieve a service implementation wrapped inOptional.- Specified by:
getOptionalin interfaceServiceRegistry- Type Parameters:
S- the service type- Parameters:
type- the service type- Returns:
- the service implementation wrapped within
Optional
-
contains
public <S extends Service> boolean contains(Class<S> type)
Description copied from interface:ServiceRegistryCheck if a service is registered- Specified by:
containsin interfaceServiceRegistry- Type Parameters:
S- the service type- Parameters:
type- the service type- Returns:
- true if a service is registered, otherwise false
-
cleanup
public void cleanup()
Description copied from interface:ServiceRegistryClear up the services registered, by callingService.cleanup()on each registered service- Specified by:
cleanupin interfaceServiceRegistry
-
cleanupAfterBoot
public void cleanupAfterBoot()
Description copied from interface:ServiceRegistryClean upBootstrapServices by callingBootstrapService.cleanupAfterBoot()on each registeredBootstrapService.- Specified by:
cleanupAfterBootin interfaceServiceRegistry
-
getRequired
public <S extends Service> S getRequired(Class<S> type)
Description copied from interface:ServiceRegistryRetrieve a required service implementation. Throws an exception if the service is not available- Specified by:
getRequiredin interfaceServiceRegistry- Type Parameters:
S- the service type- Parameters:
type- the service type- Returns:
- the service implementation
-
addIfAbsent
public <S extends Service> S addIfAbsent(Class<S> type, S service)
Description copied from interface:ServiceRegistryAdd 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.- Specified by:
addIfAbsentin interfaceServiceRegistry- 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.
-
-