org.opensaml.util.storage
Class MapBasedStorageService<KeyType,ValueType>

java.lang.Object
  extended by org.opensaml.util.storage.MapBasedStorageService<KeyType,ValueType>
Type Parameters:
KeyType - object type of the keys
ValueType - object type of the values
All Implemented Interfaces:
StorageService<KeyType,ValueType>

public class MapBasedStorageService<KeyType,ValueType>
extends Object
implements StorageService<KeyType,ValueType>

A simple Map based StorageService implementation.


Constructor Summary
  MapBasedStorageService()
          Constructor.
protected MapBasedStorageService(Map<String,Map<KeyType,ValueType>> serviceStore)
          Constructor.
 
Method Summary
 boolean contains(String partition, KeyType key)
          Checks if a given key exists.
 ValueType get(String partition, KeyType key)
          Gets the value stored under a particular key.
 Iterator<KeyType> getKeys(String partition)
          Gets the keys for entries in the storage service.
 Iterator<String> getPartitions()
          Gets the partitions within the service.
 ValueType put(String partition, KeyType key, ValueType value)
          Adds a value, indexed by a key, in to storage.
 ValueType remove(String partition, KeyType key)
          Removes an item from storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapBasedStorageService

public MapBasedStorageService()
Constructor.


MapBasedStorageService

protected MapBasedStorageService(Map<String,Map<KeyType,ValueType>> serviceStore)
Constructor.

Parameters:
serviceStore - the map to use as storage
Method Detail

getPartitions

public Iterator<String> getPartitions()
Gets the partitions within the service. Removal of a partition identifier from the iterator removes the partition from the storage service.

Specified by:
getPartitions in interface StorageService<KeyType,ValueType>
Returns:
partitions within the service

getKeys

public Iterator<KeyType> getKeys(String partition)
Gets the keys for entries in the storage service. Removal of a key from the iterator removes the the key and associated value from the store. Note: this operation may be very expensive

Specified by:
getKeys in interface StorageService<KeyType,ValueType>
Parameters:
partition - partition on which to operate
Returns:
list of keys currently within the store

contains

public boolean contains(String partition,
                        KeyType key)
Checks if a given key exists.

Specified by:
contains in interface StorageService<KeyType,ValueType>
Parameters:
partition - partition on which to operate
key - the key to check
Returns:
true of the given key exists, false if not

get

public ValueType get(String partition,
                     KeyType key)
Gets the value stored under a particular key.

Specified by:
get in interface StorageService<KeyType,ValueType>
Parameters:
partition - partition on which to operate
key - the key
Returns:
the value for that key, or null if there is no value for the given key

put

public ValueType put(String partition,
                     KeyType key,
                     ValueType value)
Adds a value, indexed by a key, in to storage. Note that implementations of this service may determine, on its own, when to evict items from storage, the expiration time given here is meant only as a system provided hint.

Specified by:
put in interface StorageService<KeyType,ValueType>
Parameters:
partition - partition on which to operate
key - the key
value - the value
Returns:
the value that was registered under that key previously, if there was a previous value

remove

public ValueType remove(String partition,
                        KeyType key)
Removes an item from storage.

Specified by:
remove in interface StorageService<KeyType,ValueType>
Parameters:
partition - partition on which to operate
key - the key to the value to remove
Returns:
the value that was removed


Copyright © 2006-2013 Internet2. All Rights Reserved.