Class AggregateStore<V extends Store>

  • All Implemented Interfaces:
    Store, Map

    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 an update(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 Detail

    • 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)
        Specified by:
        size in interface Store<V extends Store>
      • 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
        Specified by:
        create in interface Store<V extends Store>
        Returns:
      • 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).
        Specified by:
        register in interface Store<V extends Store>
      • 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.
        Specified by:
        save in interface Store<V extends Store>
      • size

        public int size()
        This is expensive to compute, so use sparingly.
        Specified by:
        size in interface Map
        Returns:
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Map
      • containsKey

        public boolean containsKey​(Object key)
        Specified by:
        containsKey in interface Map
      • containsValue

        public boolean containsValue​(Object value)
        Specified by:
        containsValue in interface Map
      • get

        public Object get​(Object key)
        Returns a null if the object is not found, regardless of the underlying store's policies.
        Specified by:
        get in interface Map
        Parameters:
        key -
        Returns:
      • remove

        public Object remove​(Object key)
        This removes the object from every store.
        Specified by:
        remove in interface Map
        Parameters:
        key -
        Returns:
      • putAll

        public void putAll​(Map m)
        Expensive method since this must check each value in the map against each store.
        Specified by:
        putAll in interface Map
        Parameters:
        m -
      • clear

        public void clear()
        Use with extreme caution, since this will clear every store!
        Specified by:
        clear in interface Map
      • keySet

        public Set keySet()
        Specified by:
        keySet in interface Map
      • entrySet

        public Set entrySet()
        Specified by:
        entrySet in interface Map
      • 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.
        Specified by:
        getAll in interface Store<V extends Store>
        Returns:
      • 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!
        Specified by:
        search in interface Store<V extends Store>
        Returns:
      • 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.
        Specified by:
        search in interface Store<V extends Store>
        Returns:
      • remove

        public boolean remove​(List objects)
        Description copied from interface: Store
        Removes a list of identifiable object from the store by ID.
        Specified by:
        remove in interface Store<V extends Store>
        Returns: