Class ForwardingServiceRegistry
java.lang.Object
org.jboss.weld.bootstrap.api.helpers.ForwardingServiceRegistry
- All Implemented Interfaces:
Iterable<Service>,ServiceRegistry
An implementation of
ServiceRegistry which forwards all its method calls to another ServiceRegistry
Subclasses should override one or more methods to modify the behavior of the backing ServiceRegistry as
desired per the decorator pattern.-
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 registeredprotected abstract ServiceRegistrydelegate()Returns the delegateentrySet()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.iterator()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ForwardingServiceRegistry
public ForwardingServiceRegistry()
-
-
Method Details
-
delegate
Returns the delegate- Returns:
- delegate
-
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:
-
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
-
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
-
iterator
-
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
-
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
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.
-