|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.nucleus.logging.VariableArgumentApplicationLoggingImpl atg.nucleus.GenericService atg.service.collections.filter.CachedCollectionFilter
public abstract class CachedCollectionFilter
This class provides the base implementation and interfaces for creating collection filters with cache management.
The interface provides the ability to write filters based on global and or personalized
variables. Each execution of the filter is provided a profile object that can be used
to vary results based on personal profile information.
When executing the filter, the caller can provide a string key (to uniquely identify the
unfiltered collection).
That key will be included as part of the complete cache key.
Caching is not allowed without the collection identifier key.
Caching can also be disabled using configuration. If cache is disabled, the filter never consults, or updates the cache.
Filter implemenations must also determine if the current context is appropriate to perform its filtering. For instance, a filter that only filters if the user's home state of MA, would not perform filtering if the user's home state was CT. This type of business logic can be implemented in the shouldApplyFilter method, which is called prior to looking up results in the cache or generating a new filtered collection.
The filtered collection results is a mutable collection. If cache is enabled, adding or removing objects from the returned filtered collection will change the results in the cache. Subsequent requests to the filter using the same collection identifier key will result in returning the modified filtered collection.
generateContextKey(java.util.Collection, java.lang.String, atg.repository.RepositoryItem)
,
shouldApplyFilter(java.util.Collection, java.lang.String, atg.repository.RepositoryItem)
,
isCacheEnabled()
,
generateFilteredCollection(java.util.Collection, java.lang.String, atg.repository.RepositoryItem)
Field Summary | |
---|---|
static java.lang.String |
CLASS_VERSION
|
static java.lang.String |
FILTER_CACHE_COMPONENT
|
protected Cache |
mCache
|
protected boolean |
mCacheEnabled
|
Fields inherited from class atg.nucleus.GenericService |
---|
SERVICE_INFO_KEY |
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging |
---|
DEFAULT_LOG_TRACE_STATUS |
Fields inherited from interface atg.nucleus.logging.ApplicationLogging |
---|
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS |
Constructor Summary | |
---|---|
CachedCollectionFilter()
|
Method Summary | |
---|---|
void |
dumpCache()
This method will dump the filter cache to the system console. |
java.util.Collection |
filterCollection(java.util.Collection pUnfilteredCollection,
java.lang.String pCollectionIdentifierKey,
RepositoryItem pProfile)
|
java.util.Collection |
filterCollection(java.util.Collection pUnfilteredCollection,
java.lang.String pCollectionIdentifierKey,
RepositoryItem pProfile,
boolean pConsultCache,
boolean pUpdateCache)
Called to create a filtered version of the unfiltered collection. |
void |
flushCache()
This method will flush the filter cache if there is one configured. |
protected CollectionCacheKey |
generateCacheKey(java.util.Collection pUnfilteredCollection,
java.lang.String pCollectionIdentifierKey,
RepositoryItem pProfile)
This method is called by the filterCollection method to create the CollectionCacheKey object used for cache lookup and update. |
abstract java.lang.Object |
generateContextKey(java.util.Collection pUnfilteredCollection,
java.lang.String pCollectionIdentifierKey,
RepositoryItem pProfile)
Generates a context key object that will be included as part of the cache key. |
protected abstract java.util.Collection |
generateFilteredCollection(java.util.Collection pUnfilteredCollection,
java.lang.String pCollectionIdentifierKey,
RepositoryItem pProfile)
Called by the filterCollection method to generate the filtered collection. |
protected java.util.Collection |
generateNewCollectionObject(java.util.Collection pUnfilteredCollection)
This method creates a new collection object of same base type as the unfiltered collection. |
Cache |
getCache()
Returns the results cache for this filter |
protected RepositoryItem |
getDefaultProfile()
This method is called by the filterCollection method when a profile item is not provided by the caller. |
boolean |
isCacheEnabled()
Returns if caching is enabled. |
void |
setCache(Cache pCache)
Sets the results cache |
void |
setCacheEnabled(boolean pCacheEnabled)
Sets if caching is enabled |
abstract boolean |
shouldApplyFilter(java.util.Collection pUnfilteredCollection,
java.lang.String pCollectionIdentifierKey,
RepositoryItem pProfile)
This method is called by filterCollection prior to looking up the filtered collection in the cache or generating a new filtered collection. |
protected static java.lang.String |
stringIt(java.util.Collection pObject)
|
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl |
---|
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CLASS_VERSION
public static final java.lang.String FILTER_CACHE_COMPONENT
protected Cache mCache
protected boolean mCacheEnabled
Constructor Detail |
---|
public CachedCollectionFilter()
Method Detail |
---|
public Cache getCache()
This will default to the component specified by FILTER_CACHE_COMPONENT.
FILTER_CACHE_COMPONENT
public void setCache(Cache pCache)
public boolean isCacheEnabled()
This method will return false if the filter does not have a cache component configured.
public void setCacheEnabled(boolean pCacheEnabled)
protected java.util.Collection generateNewCollectionObject(java.util.Collection pUnfilteredCollection) throws FilterException
If pUnfilteredCollection is an object of type atg.adapter.gsa.ChangeAwareList an ArrayList is returned.
If pUnfilteredCollection is an object of type atg.adapter.gsa.ChangeAwareSet a HashSet is returned.
pUnfilteredCollection
- the unfiltered collection
FilterException
public abstract java.lang.Object generateContextKey(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile)
For instance, a filter that creates results relative to the current date might return a date object representing today's date. Or a filter that creates results relative to gender, might return a string object of "M" of "F", depending on the current profile's gender.
Objects returned by this method will be included in the key used for cache lookup. Therefore, they should implement a hashCode and equals method when appropriate.
A null value is a valid return value for filters that don't require a specific context.
protected abstract java.util.Collection generateFilteredCollection(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile) throws FilterException
pUnfilteredCollection
- the unfiltered collectionpCollectionIdentifierKey
- the key that was passed to the filterCollection
method.
FilterException
public abstract boolean shouldApplyFilter(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile)
pUnfilteredCollection
- the unfiltered collectionpCollectionIdentifierKey
- the key param as passed to filterCollectionpProfile
- the user profile
filterCollection(java.util.Collection, java.lang.String, atg.repository.RepositoryItem, boolean, boolean)
protected CollectionCacheKey generateCacheKey(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile)
pUnfilteredCollection
- the unfiltered collectionpCollectionIdentifierKey
- the key that is was provided on the call to filterCollectionpProfile
- the profile repository item.
generateContextKey(java.util.Collection, java.lang.String, atg.repository.RepositoryItem)
,
CollectionCacheKey
protected RepositoryItem getDefaultProfile()
public java.util.Collection filterCollection(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile, boolean pConsultCache, boolean pUpdateCache) throws FilterException
pUnfilteredCollection
- the unfiltered collectionpCollectionIdentifierKey
- the string that uniquely identifies the unfilterd collection. This string
will be included as part of the complete key for cache lookup.pProfile
- the profile repository item.pConsultCache
- if true the cache is first consulted for filtered resultspUpdateCache
- if true the cache is updated with the new filtered collection.
FilterException
public java.util.Collection filterCollection(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile) throws FilterException
FilterException
filterCollection(java.util.Collection, java.lang.String, atg.repository.RepositoryItem, boolean, boolean)
protected static java.lang.String stringIt(java.util.Collection pObject)
public void flushCache()
Cache.flush()
public void dumpCache()
Cache.dump(java.io.PrintStream)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |