Class ConcurrentApplicationContextImpl
-
- All Implemented Interfaces:
-
io.github.funofprograming.context.ApplicationContext,io.github.funofprograming.context.ConcurrentApplicationContext
public class ConcurrentApplicationContextImpl extends ApplicationContextImpl implements ConcurrentApplicationContext
-
-
Constructor Summary
Constructors Constructor Description ConcurrentApplicationContextImpl(String name, Set<Key<?>> permittedKeys, ApplicationContext initialCopy)ConcurrentApplicationContextImpl(String name, Set<Key<?>> permittedKeys)
-
Method Summary
Modifier and Type Method Description <T extends Any> UnitaddIfNotPresent(Key<T> key, T value)Add value for given key if not already present. <T extends Any> UnitaddIfNotPresent(Key<T> key, T value, Long timeout)Same as addIfNotPresent in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method <T extends Any> ObjectaddWithOverwrite(Key<T> key, T value)Add value for given key even if already present. <T extends Any> ObjectaddWithOverwrite(Key<T> key, T value, Long timeout)Same as addWithOverwrite in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method <T extends Any> Unitadd(Key<T> key, T value)Add value for given key. <T extends Any> Unitadd(Key<T> key, T value, Long timeout)Same as add in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method <T extends Any> Booleanexists(Key<T> key)Check if any value or null associated with give key <T extends Any> Booleanexists(Key<T> key, Long timeout)Same as exists in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method <T extends Any> Tfetch(Key<T> key)Fetch value associated with key or null <T extends Any> Tfetch(Key<T> key, Long timeout)Same as fetch in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method <T extends Any> Terase(Key<T> key)Erase value associated with key if any <T extends Any> Terase(Key<T> key, Long timeout)Same as erase in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method Unitclear()Clear the entire context Unitclear(Long timeout)Same as clear in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method Unitmerge(ApplicationContext other, ApplicationContextMergeStrategy mergeStrategy)Merge other context with this using the given merge strategy Unitmerge(ApplicationContext other, ApplicationContextMergeStrategy mergeStrategy, Long timeout)Same as merge in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method ApplicationContextclone(String cloneName, Set<Key<?>> clonePermittedKeys)Creates a clone of this context with passed cloneName and clonePermittedKeys. -
-
Method Detail
-
addIfNotPresent
<T extends Any> Unit addIfNotPresent(Key<T> key, T value)
Add value for given key if not already present.
This is semmantically same as
if(!exists(key)) add(key, value)*- Parameters:
value- </T>
-
addIfNotPresent
<T extends Any> Unit addIfNotPresent(Key<T> key, T value, Long timeout)
Same as addIfNotPresent in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method
- Parameters:
timeout- in millis </T>
-
addWithOverwrite
<T extends Any> Object addWithOverwrite(Key<T> key, T value)
Add value for given key even if already present.
- Returns:
Previous value associated with key if any or null </T>
-
addWithOverwrite
<T extends Any> Object addWithOverwrite(Key<T> key, T value, Long timeout)
Same as addWithOverwrite in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method
- Parameters:
timeout- in millis- Returns:
- </T>
-
add
<T extends Any> Unit add(Key<T> key, T value, Long timeout)
Same as add in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method
- Parameters:
timeout- in millis </T>
-
exists
<T extends Any> Boolean exists(Key<T> key)
Check if any value or null associated with give key
- Returns:
true if value or null associated with give key otherwise false </T>
-
exists
<T extends Any> Boolean exists(Key<T> key, Long timeout)
Same as exists in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method
- Parameters:
timeout- in millis- Returns:
- </T>
-
fetch
<T extends Any> T fetch(Key<T> key)
Fetch value associated with key or null
- Returns:
value associated with key or null </T>
-
fetch
<T extends Any> T fetch(Key<T> key, Long timeout)
Same as fetch in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method
- Parameters:
timeout- in millis- Returns:
- </T>
-
erase
<T extends Any> T erase(Key<T> key)
Erase value associated with key if any
- Returns:
value associate with key or null </T>
-
erase
<T extends Any> T erase(Key<T> key, Long timeout)
Same as erase in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method
- Parameters:
timeout- in millis- Returns:
- </T>
-
clear
Unit clear(Long timeout)
Same as clear in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method
- Parameters:
timeout- in millis
-
merge
Unit merge(ApplicationContext other, ApplicationContextMergeStrategy mergeStrategy)
Merge other context with this using the given merge strategy
- Parameters:
other- other context.
-
merge
Unit merge(ApplicationContext other, ApplicationContextMergeStrategy mergeStrategy, Long timeout)
Same as merge in ApplicationContext with additional timeout parameter for wait time in case of multiple threads blocking on this method
- Parameters:
timeout- in millis
-
clone
ApplicationContext clone(String cloneName, Set<Key<?>> clonePermittedKeys)
Creates a clone of this context with passed cloneName and clonePermittedKeys. While cloning only the permittedKeys will be added
- Parameters:
cloneName- name of the cloned ApplicationContextclonePermittedKeys- permittedKeys of the cloned ApplicationContext
-
-
-
-