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>

Generic storage manager implementation based on name mappers. There exists 2 subclasses, AbstractApplicationScopeAwareStorageManager and AbstractRequestScopeAwareStorageManager, that use JSF scopes to store the information.

Since:
x.x.3
Author:
Gerhard Petracek

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 where the cached instances can be found in the JSF Scope.
 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()
          Subclasses need to supply the list of all cached instances.
 
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. Implementation classes for the key (also named storageName), are supplied by registered nameMappers.

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. In the other case, a new instance is created and stored to 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:
Implementation of the storage manager. Could be null if name mapper supplied non existent class name.

resolveStorageMap

protected abstract Map<String,T> resolveStorageMap()
Subclasses need to supply the list of all cached instances.

Returns:
Map of all cached storage Manager implementations keyed on the type of storage.

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 where the cached instances can be found in the JSF Scope.

Returns:
key for finding the cached instances in thre JSF Scope.


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