|
|
|
Unit test for streaming token replacement filter
Updated token replacement code that moves the non-channel title logic into an abstract class.
Updated test cases to try chunked filtering and to filter an actual HTML page with multiple tokens.
The UserInstance system block cache mechanism to allow the addition of a new block type CHANNE_TITLE. The new cache block type was not needed, but the refactoring is useful.
To support dynamic titles within cached system blocks (page fragments outside the channel content), A token (UP:CHANNEL_TITLE-{channelSubscribeId}) was created that represents a channel's title. Then the PrintWriter for the response is wrapped with a filter that will replace these tokens. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The CharacterCacheEntry class would be changed from a List<String> of serialized content fragments and a List<String> of channel ids which are interleaved into just a List<CacheEntry> (the CacheEntry class and related classes are outlined below). The each CacheEntry would describe what content should go in its place, cached serialized characters, a channel title, or channel content. For the channel title and content entries the CacheEntry would provide the channel subscribe id to get the content for. For the cached characters entry the serialized String would be part of the entry. The rendering pipeline code that replays the cached List<CacheEntry> would then just take the appropriate action based on the type of entry and either write out cached data or query the channel manager for the channel content or title. This will result in more interleaving that currently exists but there should be no real performance change as retrieving and writing out a channel title is a very cheap operation.
enum CacheType { CHARACTERS; CHANNEL_TITLE; CHANNEL_CONTENT; }
interface CacheEntry { CacheType getCacheType(); }
class StringCacheEntry implements CacheEntry {
CacheType getCacheType() { return CacheType.CHARACTERS; }
String getCachedCharacters(){ return chars; }
}
abstract class BaseChannelCacheEntry implements CacheEntry {
String getChannelId(){ return id; }
}
class ChannelContentCacheEntry extends BaseChannelCacheEntry {
CacheType getCacheType() { return CacheType.CHANNEL_CONTENT; }
}
class ChannelTitleCacheEntry extends BaseChannelCacheEntry {
CacheType getCacheType() { return CacheType.CHANNEL_TITLE; }
String getDefaultTitle() { return defaultTitle; }
}