Cache Adapter In ATG
Cache adapter in ATG works in a similar way like EHCache does. We just have to call get(id) method of cache component. Here the passing parameter in get method will work as a key. For implementing cache adapter in ATG we need following components.
XXXCache
$class=atg.service.cache.Cache cacheAdapter=/com/xxx/cache/XXXCacheAdapter
XXXCacheAdapter
$class=com.xxx.cache.XXXCacheAdapter
XXXCacheAdapter.java (Just provide implementation of getCacheElement. Override others will blank implementation)
Click To Check ATG Interview Questions
package com.xxx.cache; import atg.nucleus.GenericService; import atg.service.cache.CacheAdapter; public class XXXCacheAdapter extends GenericService implements CacheAdapter { /* * (non-Javadoc) * * @see atg.service.cache.CacheAdapter#getCacheElement(java.lang.Object) */ @Override public Object getCacheElement(Object uniqueId) throws Exception { if (isLoggingDebug()) { logDebug("getCacheElement method Start "); } . . //Business Logic . . if (isLoggingDebug()) { logDebug("getCacheElement method End "); } return data; } }
XXXFormHandler (Component from where we need to call cache component)
$class=com.xxx.handler.XXXFornhandler $scope=request xxxCache=/com/xxx/cache/XXXCache
XXXFormHandler.java
package com.xxx.handler.XXXFornhandler; import atg.service.cache.Cache; import atg.servlet.DynamoHttpServletRequest; import atg.servlet.DynamoHttpServletResponse; public class XXXFornhandler extends GenericFormHandler { private Cache xxxCache; public boolean handleSubmit(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) { . . data = getXXXCache().get(id); . . } public Cache getXXXCache() { return xxxCache; } public void setXXXCache(Cache xxxCache) { this.xxxCache = xxxCache; } }
ATG Interview Questions and Answers For Exprienced