public interface SubjectManager extends SubjectRegistry
SubjectRegistry
with functionality for mutating (managing) the registered entries.Modifier and Type | Interface and Description |
---|---|
static class |
SubjectManager.Implementation
A simple
SubjectManager default implementation that uses a shared synchronization lock and a
LockedMap implementation to allow locking-supervised access to the registry entries. |
Modifier and Type | Method and Description |
---|---|
static SubjectManager |
New()
Creates a new
SubjectManager instance with no entries and an exclusive locking instance. |
static SubjectManager |
New(Map<String,Subject> map)
Creates a new
SubjectManager instance with the passed map used as its internal entries datastructure
and an exclusive locking instance. |
static SubjectManager |
New(Object registryLock)
Creates a new
SubjectManager instance with no entries and the passed instance as a shared locking instance. |
static SubjectManager |
New(Object registryLock,
Map<String,Subject> map)
Creates a new
SubjectManager instance with the passed map used as its internal entries datastructure
and the passed instance as a shared locking instance. |
Map<String,Subject> |
subjects()
Provides access to the registry entries to be used in a thread safe way according to the internal
logic.
|
lockSubjectRegistry, New, New, New, subject
Map<String,Subject> subjects()
LockedMap
.
Rationale for this approach: The obvious (and naive) concept would be to implement a registerSubject() method. But as a consequence, that would also require a removeSubject() method, then a subjectSize() and iterateSubjects() methods and then it becomes clear that managing subjects (in an efficient, comfortable way) requires a complete collection logic. So instead of reimplementing a complete collection in every managing type, the managing type might as well provide mutating access to its internal collection, however in a safe way (e.g. wrapped in locking logic and/or via a relay instance with hooked-in logic).
subjects
in interface SubjectRegistry
static SubjectManager New()
SubjectManager
instance with no entries and an exclusive locking instance.SubjectManager
instancestatic SubjectManager New(Object registryLock)
SubjectManager
instance with no entries and the passed instance as a shared locking instance.registryLock
- the shared locking instance to be used.SubjectManager
instancestatic SubjectManager New(Map<String,Subject> map)
SubjectManager
instance with the passed map used as its internal entries datastructure
and an exclusive locking instance.New
in interface SubjectRegistry
map
- the entries datastructure to be used internally.SubjectManager
instance.static SubjectManager New(Object registryLock, Map<String,Subject> map)
SubjectManager
instance with the passed map used as its internal entries datastructure
and the passed instance as a shared locking instance.registryLock
- the shared locking instance to be used.map
- the entries datastructure to be used internally.SubjectManager
instance.