Package io.csar
Class ConcernRegistryThreadGroup
java.lang.Object
java.lang.ThreadGroup
io.csar.DecoratedConcernedThreadGroup
io.csar.ConcernRegistryThreadGroup
- All Implemented Interfaces:
Concerned
,ConcernRegistry
,Thread.UncaughtExceptionHandler
public class ConcernRegistryThreadGroup
extends DecoratedConcernedThreadGroup
implements ConcernRegistry
A thread group that allows the setting and retrieval of a concern on a per-thread-group basis.
- Author:
- Garret Wilson
- Implementation Specification:
- This implementation decorates an existing concern registry.
- See Also:
-
Constructor Summary
ConstructorDescriptionConcernRegistryThreadGroup
(String name, Concern... concerns) Thread group name constructor.ConcernRegistryThreadGroup
(String name, ConcernRegistry concernRegistry, Concern... concerns) Thread group name constructor.ConcernRegistryThreadGroup
(ThreadGroup parent, String name, Concern... concerns) Thread group parent and thread group name constructor.ConcernRegistryThreadGroup
(ThreadGroup parent, String name, ConcernRegistry concernRegistry, Concern... concerns) Thread group parent and thread group name constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected ConcernRegistry
registerConcern
(C concern) Registers the given concern, associating it with its concern type.registerConcern
(Class<T> concernType, C concern) Registers the given concern.void
registerConcerns
(Concern... concerns) Registers the given concerns, associating them with their respective concern types.void
registerConcerns
(Collection<Concern> concerns) Registers the given concerns, associating them with their respective concern types.void
registerConcerns
(Stream<Concern> concerns) Registers the given concerns, associating them with their respective concern types.unregisterConcern
(Class<T> concernType) Unregisters a concern of the given type.Methods inherited from class io.csar.DecoratedConcernedThreadGroup
findConcern
Methods inherited from class java.lang.ThreadGroup
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend, toString, uncaughtException
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.csar.Concerned
findConcern
-
Constructor Details
-
ConcernRegistryThreadGroup
Thread group name constructor. Creates a thread group using the current thread as the parent. A default concern registry is used.- Parameters:
name
- The name of the new thread group.concerns
- The available concerns to register.- Throws:
SecurityException
- If the current thread cannot create a thread in the specified thread group.- See Also:
-
ConcernRegistryThreadGroup
Thread group parent and thread group name constructor. A default concern registry is used.- Parameters:
parent
- The parent thread group.name
- The name of the new thread group.concerns
- The available concerns to register.- Throws:
NullPointerException
- if the given parent isnull
.SecurityException
- If the current thread cannot create a thread in the specified thread group.- See Also:
-
ConcernRegistryThreadGroup
public ConcernRegistryThreadGroup(String name, ConcernRegistry concernRegistry, Concern... concerns) Thread group name constructor. Creates a thread group using the current thread as the parent.- Parameters:
name
- The name of the new thread group.concernRegistry
- The implementation for registering concerns for this thread group.concerns
- The available concerns to registry.- Throws:
NullPointerException
- if the given concern registry isnull
.SecurityException
- If the current thread cannot create a thread in the specified thread group.- See Also:
-
ConcernRegistryThreadGroup
public ConcernRegistryThreadGroup(ThreadGroup parent, String name, ConcernRegistry concernRegistry, Concern... concerns) Thread group parent and thread group name constructor.- Parameters:
parent
- The parent thread group.name
- The name of the new thread group.concernRegistry
- The implementation for registering concerns for this thread group.concerns
- The available concerns to register.- Throws:
NullPointerException
- if the given parent and/or concern registry isnull
.SecurityException
- If the current thread cannot create a thread in the specified thread group.- See Also:
-
-
Method Details
-
getConcerned
- Overrides:
getConcerned
in classDecoratedConcernedThreadGroup
- Returns:
- The implementation for managing concerns for this thread group.
-
registerConcerns
Description copied from interface:ConcernRegistry
Registers the given concerns, associating them with their respective concern types.- Specified by:
registerConcerns
in interfaceConcernRegistry
- Parameters:
concerns
- The concerns to register.- See Also:
-
registerConcerns
Description copied from interface:ConcernRegistry
Registers the given concerns, associating them with their respective concern types.- Specified by:
registerConcerns
in interfaceConcernRegistry
- Parameters:
concerns
- The concerns to register.- See Also:
-
registerConcerns
Description copied from interface:ConcernRegistry
Registers the given concerns, associating them with their respective concern types.- Specified by:
registerConcerns
in interfaceConcernRegistry
- Parameters:
concerns
- The concerns to register.- See Also:
-
registerConcern
Description copied from interface:ConcernRegistry
Registers the given concern, associating it with its concern type.- Specified by:
registerConcern
in interfaceConcernRegistry
- Type Parameters:
C
- The type of concern being registered.D
- The type of concern previously registered.- Parameters:
concern
- The concern to register.- Returns:
- The concern previously associated with the same concern type.
- See Also:
-
registerConcern
public <T extends Concern,C extends T> Optional<T> registerConcern(Class<T> concernType, C concern) Description copied from interface:ConcernRegistry
Registers the given concern.- Specified by:
registerConcern
in interfaceConcernRegistry
- Type Parameters:
T
- The registration concern type.C
- The type of concern being registered.- Parameters:
concernType
- The class with which to associate the concern.concern
- The concern to register.- Returns:
- The concern previously associated with the given class.
-
unregisterConcern
Description copied from interface:ConcernRegistry
Unregisters a concern of the given type. If no concern is associated with the specified type, no action occurs.- Specified by:
unregisterConcern
in interfaceConcernRegistry
- Type Parameters:
T
- The type of concern being unregistered.- Parameters:
concernType
- The class with which the concern is associated.- Returns:
- The concern previously associated with the given class.
-