Class SimpleServiceRegistry
java.lang.Object
org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry
- All Implemented Interfaces:
Iterable<Service>,ServiceRegistry
A registry for services
- Author:
- Pete Muir, Matej Novotny
-
Constructor Summary
Constructors -
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 entriesbooleanget()Returns a map containing all registered services<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.inthashCode()iterator()toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SimpleServiceRegistry
public SimpleServiceRegistry()Initialize a new instance ofSimpleServiceRegistry
-
-
Method Details
-
add
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:
-
addAll
Description copied from interface:ServiceRegistryAdd services- Specified by:
addAllin interfaceServiceRegistry- Parameters:
services- services to be added
-
entrySet
Description copied from interface:ServiceRegistryReturns a set of all service entries- Specified by:
entrySetin interfaceServiceRegistry- Returns:
- all service entries as a set
-
get
Returns a map containing all registered services- Returns:
- map with all services
-
get
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
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
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
-
toString
-
hashCode
public int hashCode() -
equals
-
iterator
-
getRequired
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
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.
-