Inherited by ERXSession.

Classes | |
| class | TransactionRecord |
Public Member Functions | |
| void | _saveCurrentPage () |
| ERXAjaxSession (String sessionID) | |
| ERXAjaxSession () | |
| WOComponent | restorePageForContextID (String contextID) |
| void | savePage (WOComponent page) |
| void | savePageInPermanentCache (WOComponent wocomponent) |
Static Public Attributes | |
| static final String | DONT_STORE_PAGE = "erxsession.dont_store_page" |
| static final String | FORCE_STORE_PAGE = "erxsession.force_store_page" |
| static final String | PAGE_REPLACEMENT_CACHE_LOOKUP_KEY = "page_cache_key" |
Protected Member Functions | |
| NSMutableDictionary | _permanentPageCache () |
| WOComponent | _permanentPageWithContextID (String contextID) |
| boolean | _shouldPutInPermanentCache (WOComponent wocomponent) |
| boolean | cleanPageReplacementCacheIfNecessary (String _cacheKeyToAge) |
| void | cleanPageReplacementCacheIfNecessary () |
Protected Attributes | |
| NSMutableArray | _permanentContextIDArray |
| NSMutableDictionary | _permanentPageCache |
Private Attributes | |
| Logger | logger = Logger.getLogger(ERXAjaxSession.class.getName()) |
Static Private Attributes | |
| static int | MAX_PAGE_REPLACEMENT_CACHE_SIZE = Integer.parseInt(System.getProperty("er.extensions.maxPageReplacementCacheSize", "30")) |
| static final String | ORIGINAL_CONTEXT_ID_KEY = "original_context_id" |
| static boolean | overridePrivateCache = ERXProperties.booleanForKey("er.extensions.overridePrivateCache") |
| static final String | PAGE_REPLACEMENT_CACHE_KEY = "page_replacement_cache" |
| ERXAjaxSession | ( | ) |
| ERXAjaxSession | ( | String | sessionID | ) |
| NSMutableDictionary _permanentPageCache | ( | ) | [protected] |
Returns the permanent page cache. Initializes it if needed.
| WOComponent _permanentPageWithContextID | ( | String | contextID | ) | [protected] |
Returns the page for the given contextID, null if none is present.
| contextID |
| void _saveCurrentPage | ( | ) |
Semi-private method that saves the current page. Overridden to put the page in the permanent page cache if it's already in there.
| boolean _shouldPutInPermanentCache | ( | WOComponent | wocomponent | ) | [protected] |
Reimplementation of the rather wierd super imp which references an interface probably no one has ever heard of...
| wocomponent |
| boolean cleanPageReplacementCacheIfNecessary | ( | String | _cacheKeyToAge | ) | [protected] |
Iterates through the page replacement cache (if there is one) and removes expired records.
| _cacheKeyToAge | optional cache key to age via setOldPage |
| void cleanPageReplacementCacheIfNecessary | ( | ) | [protected] |
Iterates through the page replacement cache (if there is one) and removes expired records.
| WOComponent restorePageForContextID | ( | String | contextID | ) |
Extension of restorePageForContextID that implements the other side of Page Replacement Cache.
| void savePage | ( | WOComponent | page | ) |
Overridden so that Ajax requests are not saved in the page cache. Checks both the response userInfo and the response headers if the DONT_STORE_PAGE key is present. The value doesn't matter.
Page Replacement cache is specifically designed to support component actions in Ajax updates. The problem with component actions in Ajax is that if you let them use the normal page cache, then after only 30 (or whatever your backtrack cache is set to) updates from Ajax, you will fill your backtrack cache. Unfortunately for the user, though, the backtrack cache filled up with background ajax requests, so when the user clicks on a component action on the FOREGROUND page, the foreground page has fallen out of the cache, and the request cannot be fulfilled (because its context is gone). If you simply turn off backtrack cache entirely for a request, then you can't have component actions inside of an Ajax updated area, because the context of the Ajax update that generated the link will never get stored, and so you will ALWAYS get a backtrack error.
Enter page replacement cache. If you look at the behavior of Ajax, it turns out that what you REALLY want is a hybrid page cache. You want to keep the backtrack of just the LAST update for a particular ajax component -- you don't care about its previous 29 states because the user can't use the back button to get to them anyway, but if you have the MOST RECENT cached version of the page then you can click on links in Ajax updated areas. Page Replacement cache implements this logic. For each Ajax component on your page that is updating, it keeps a cache entry of its most recent backtrack state (note the difference between this and the normal page cache. The normal page cache contains one entry per user-backtrackable-request. The replacement cache contains one entry per ajax component*, allowing up to replacement_page_cache_size many components per page). Each time the Ajax area refreshes, the most recent state is replaced*. When a restorePage request comes in, the replacement cache is checked first. If the replacement cache can service the page, then it does so. If the replacement cache doesn't contain the context, then it passes up to the standard page cache. If you are not using Ajax, no replacement cache will exist in your session, and all the code related to it will be skipped, so it should be minimally invasive under those conditions.
* It turns out that we have to keep the last TWO states, because of a race condition in the scenario where the replacement page cache replaces context 2 with the context 3 update, but the user's browser hasn't been updated yet with the HTML from context 3. When the user clicks, they are clicking the context 2 link, which has now been removed from the replacement cache. By keeping the last two states, you allow for the brief period where that transition occurs.
Random note (that I will find useful in 2 weeks when I forget this again): The first time through savePage, the request is saved in the main cache. It's only on a subsequent Ajax update that it uses page replacement cache. So even though the cache is keyed off of context ID, the explanation of the cache being components-per-page-sized works out because each component is requesting in its own thread and generating their own non-overlapping context ids.
Reimplemented in Session.
| void savePageInPermanentCache | ( | WOComponent | wocomponent | ) |
Saves a page in the permanent cache. Overridden to not save in the super implementation's iVars but in our own.
NSMutableArray _permanentContextIDArray [protected] |
The currently active contextIDs for the permanent pages.
NSMutableDictionary _permanentPageCache [protected] |
A dict of contextID/pages
final String DONT_STORE_PAGE = "erxsession.dont_store_page" [static] |
Key that tells the session not to store the current page. Checks both the response userInfo and the response headers if this key is present. The value doesn't matter, but you need to update the corresponding value in AjaxUtils. This is to keep the dependencies between the two frameworks independent.
final String FORCE_STORE_PAGE = "erxsession.force_store_page" [static] |
Logger logger = Logger.getLogger(ERXAjaxSession.class.getName()) [private] |
int MAX_PAGE_REPLACEMENT_CACHE_SIZE = Integer.parseInt(System.getProperty("er.extensions.maxPageReplacementCacheSize", "30")) [static, private] |
final String ORIGINAL_CONTEXT_ID_KEY = "original_context_id" [static, private] |
boolean overridePrivateCache = ERXProperties.booleanForKey("er.extensions.overridePrivateCache") [static, private] |
final String PAGE_REPLACEMENT_CACHE_KEY = "page_replacement_cache" [static, private] |
final String PAGE_REPLACEMENT_CACHE_LOOKUP_KEY = "page_cache_key" [static] |
Key that is used to specify that a page should go in the replacement cache instead of the backtrack cache. This is used for Ajax components that actually generate component actions in their output. The value doesn't matter, but you need to update the corresponding value in AjaxUtils. This is to keep the dependencies between the two frameworks independent.
1.5.8