Package edu.uiuc.ncsa.security.storage
Class AggregateStore<V extends Store>
- java.lang.Object
-
- edu.uiuc.ncsa.security.storage.AggregateStore<V>
-
public class AggregateStore<V extends Store> extends Object implements Store
A store of stores. This implements the store interface and passes through the calls to each underlying store. This allows an application to treat a collection of stores as a one big logical store. Note that this works locally at each stage, so, e.g. if anupdate(edu.uiuc.ncsa.security.core.Identifiable)
is issued, the first store found containing the information is what is updated. Not perfect, but will probably keep information more or less localized...Created by Jeff Gaynor
on 5/24/12 at 9:16 AM
-
-
Field Summary
Fields Modifier and Type Field Description protected List<V>
stores
-
Fields inherited from interface edu.uiuc.ncsa.security.core.Store
VERSION_TAG
-
-
Constructor Summary
Constructors Constructor Description AggregateStore(V... stores)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStore(V store)
Caveat! This does not check if the store has already been added! This is because store comparison is probably too expensive and in some cases almost impossible to do.protected void
checkValid()
void
clear()
Use with extreme caution, since this will clear every store!boolean
containsKey(Object key)
boolean
containsValue(Object value)
Identifiable
create()
Create a new object of the given type.V
defaultStore()
Set
entrySet()
Object
get(Object key)
Returns a null if the object is not found, regardless of the underlying store's policies.List
getAll()
Method to get every element in the store.List
getMostRecent(int n, List attributes)
XMLConverter
getXMLConverter()
boolean
isEmpty()
Set
keySet()
Object
put(Object key, Object value)
void
putAll(Map m)
Expensive method since this must check each value in the map against each store.void
register(Identifiable value)
Almost Identical to put(K,V) but since the object should have an identifier, passing along the key is redundant.Object
remove(Object key)
This removes the object from every store.boolean
remove(List objects)
Removes a list of identifiable object from the store by ID.void
save(Identifiable value)
Saves an object.List<V>
search(String key, String condition, boolean isRegEx)
Allows for searching via a reg ex.List
search(String key, String condition, boolean isRegEx, List attr)
Return a subset of all the attributes.List
search(String key, String condition, boolean isRegEx, List attr, String dateField, Date before, Date after)
int
size()
This is expensive to compute, so use sparingly.int
size(boolean includeVersions)
List<V>
stores()
Gives access to the list of stores.void
update(Identifiable value)
Update an existing object.Collection
values()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
AggregateStore
public AggregateStore(V... stores)
-
-
Method Detail
-
stores
public List<V> stores()
Gives access to the list of stores. Mostly for testing purposes.- Returns:
-
addStore
public void addStore(V store)
Caveat! This does not check if the store has already been added! This is because store comparison is probably too expensive and in some cases almost impossible to do. It is up to the application not to add multiple copies of the same store.- Parameters:
store
-
-
size
public int size(boolean includeVersions)
-
checkValid
protected void checkValid()
-
defaultStore
public V defaultStore()
-
create
public Identifiable create()
Description copied from interface:Store
Create a new object of the given type. This is not in the store until it is registered. Attempts to update the object should throw an exception. Note that this allows for a separation of creation semantics. Some objects require specific initialization before saving
-
update
public void update(Identifiable value)
Description copied from interface:Store
Update an existing object. AnUnregisteredObjectException
is thrown if the object has not been saved first.
-
register
public void register(Identifiable value)
Description copied from interface:Store
Almost Identical to put(K,V) but since the object should have an identifier, passing along the key is redundant. This persists the object in the store. Note that this returns void since the contract assumes that this is not registered. If the object is registered an exception should be thrown. Generally use save(V).
-
save
public void save(Identifiable value)
Description copied from interface:Store
Saves an object. This bridges the gap between SQL stores update and insert commands. Implementations should check if the object already exists in the store and issue an appropriate call.
-
size
public int size()
This is expensive to compute, so use sparingly.
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap
-
get
public Object get(Object key)
Returns a null if the object is not found, regardless of the underlying store's policies.
-
putAll
public void putAll(Map m)
Expensive method since this must check each value in the map against each store.
-
clear
public void clear()
Use with extreme caution, since this will clear every store!
-
values
public Collection values()
-
getAll
public List getAll()
Description copied from interface:Store
Method to get every element in the store. This is useful for command line interfaces. Note that this might be very expensive.
-
getXMLConverter
public XMLConverter getXMLConverter()
- Specified by:
getXMLConverter
in interfaceStore<V extends Store>
-
search
public List<V> search(String key, String condition, boolean isRegEx)
Description copied from interface:Store
Allows for searching via a reg ex. Note that this may be very expensive for certain stores!
-
search
public List search(String key, String condition, boolean isRegEx, List attr)
Description copied from interface:Store
Return a subset of all the attributes. For non-SQL stores performance may be slow.
-
search
public List search(String key, String condition, boolean isRegEx, List attr, String dateField, Date before, Date after)
-
remove
public boolean remove(List objects)
Description copied from interface:Store
Removes a list of identifiable object from the store by ID.
-
-