org.apache.myfaces.extensions.validator.core.storage
Class AbstractStorageManager<T>

java.lang.Object
  extended by org.apache.myfaces.extensions.validator.core.factory.AbstractNameMapperAwareFactory<String>
      extended by org.apache.myfaces.extensions.validator.core.storage.AbstractStorageManager<T>
All Implemented Interfaces:
NameMapperAwareFactory<NameMapper<String>>, StorageManager<T>
Direct Known Subclasses:
AbstractApplicationScopeAwareStorageManager, AbstractRequestScopeAwareStorageManager

public abstract class AbstractStorageManager<T>
extends AbstractNameMapperAwareFactory<String>
implements StorageManager<T>

An implementation of AbstractStorageManager is responsible to manage storages (create(java.lang.String) and reset(java.lang.String)) in the context of a specific scope (e.g. the application scope of JSF).

Since:
x.x.3

Field Summary
protected  Logger logger
           
 
Constructor Summary
AbstractStorageManager()
           
 
Method Summary
 T create(String storageName)
          Creates and scope or retrieve a previously created instance, of the storage for the given key.
protected  List<NameMapper<String>> getNameMapperList()
           
abstract  String getStorageManagerKey()
          Returns the key which will be used to find the storages scoped by the storage-manager instance.
 void reset(String storageKey)
          Resets the storage linked to the given key.
protected  T resolveStorage(String storageKey, String storageClassName)
          Retrieves the storage Manager from the cached instances, if already created previously.
protected abstract  Map<String,T> resolveStorageMap()
          Returns a Map of all scoped storages stored by the current manager instance.
 
Methods inherited from class org.apache.myfaces.extensions.validator.core.factory.AbstractNameMapperAwareFactory
deny, deregister, getComparator, register
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Logger logger
Constructor Detail

AbstractStorageManager

public AbstractStorageManager()
Method Detail

create

public T create(String storageName)
Creates and scope or retrieve a previously created instance, of the storage for the given key. A storage is resolved via the registered name mappers.

Specified by:
create in interface StorageManager<T>
Parameters:
storageName - The key for a storage that needs to be created
Returns:
The storage associated with the key or null if the key is unknown to the storageManager.

resolveStorage

protected T resolveStorage(String storageKey,
                           String storageClassName)
Retrieves the storage Manager from the cached instances, if already created previously. Otherwise a new instance is created and stored in the cache.

Parameters:
storageKey - The type of storage that needs to be created
storageClassName - The class name of the implementation of the storage manager.
Returns:
storage instance for the given parameters or null in case of invalid parameters.

resolveStorageMap

protected abstract Map<String,T> resolveStorageMap()
Returns a Map of all scoped storages stored by the current manager instance.

Returns:
Map of all cached storages managed by the current storage manager.

reset

public void reset(String storageKey)
Description copied from interface: StorageManager
Resets the storage linked to the given key. If the storage isn't created yet or the key is unknown for the storageManager, nothing is performed and no exception is thrown.

Specified by:
reset in interface StorageManager<T>
Parameters:
storageKey - The key for a storage that needs to be resetted

getNameMapperList

protected List<NameMapper<String>> getNameMapperList()
Specified by:
getNameMapperList in class AbstractNameMapperAwareFactory<String>

getStorageManagerKey

public abstract String getStorageManagerKey()
Returns the key which will be used to find the storages scoped by the storage-manager instance.

Returns:
key for finding the storage scoped by the storage-manager instance


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.