|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.markup.MarkupCache
public class MarkupCache
This is Wicket's default IMarkupCache implementation. It will load the markup and cache it for fast retrieval.
If the application is in development mode and a markup file changes, it'll automatically be removed from the cache and reloaded when needed.
MarkupCache is registered with MarkupFactory
which in turn is registered with
IMarkupSettings
and thus can be replaced with a subclassed version.
IMarkupSettings
,
MarkupFactory
Nested Class Summary | |
---|---|
static class |
MarkupCache.DefaultCacheImplementation<K,V>
|
static interface |
MarkupCache.ICache<K,V>
MarkupCache allows you to implement you own cache implementation. |
Constructor Summary | |
---|---|
protected |
MarkupCache()
Constructor. |
Method Summary | ||
---|---|---|
void |
clear()
Clear markup cache and force reload of all markup data |
|
static IMarkupCache |
get()
A convenient helper to get the markup cache registered with the application. |
|
Markup |
getMarkup(MarkupContainer container,
Class<?> clazz,
boolean enforceReload)
Gets any (immutable) markup resource for the container or any of its parent classes (markup inheritance) |
|
MarkupCache.ICache<String,Markup> |
getMarkupCache()
Get a unmodifiable map which contains the cached data. |
|
IMarkupCacheKeyProvider |
getMarkupCacheKeyProvider(MarkupContainer container)
Get the markup cache key provider to be used |
|
protected Markup |
getMarkupFromCache(String cacheKey,
MarkupContainer container)
Wicket's default implementation just uses the cacheKey to retrieve the markup from the cache. |
|
protected
|
newCacheImplementation()
Allows you to change the map implementation which will hold the cache data. |
|
protected Markup |
onMarkupNotFound(String cacheKey,
MarkupContainer container,
Markup markup)
Will be called if the markup was not in the cache yet and could not be found either. |
|
protected Markup |
putIntoCache(String locationString,
MarkupContainer container,
Markup markup)
Put the markup into the cache if cacheKey is not null and the cache does not yet contain the cacheKey. |
|
IMarkupFragment |
removeMarkup(String cacheKey)
Note that this method will be called from a "cleanup" thread which might not have a thread local application. |
|
void |
shutdown()
Will be called by the application while shutting down. |
|
int |
size()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected MarkupCache()
Method Detail |
---|
public static final IMarkupCache get()
Application
Application#getMarkupSettings()}
,
MarkupFactory#getMarkupCache()}
public void clear()
IMarkupCache
clear
in interface IMarkupCache
public void shutdown()
IMarkupCache
shutdown
in interface IMarkupCache
public final IMarkupFragment removeMarkup(String cacheKey)
removeMarkup
in interface IMarkupCache
MarkupResourceStream.getCacheKey()
public final int size()
size
in interface IMarkupCache
public final MarkupCache.ICache<String,Markup> getMarkupCache()
May be used to debug or iterate the cache content.
public final Markup getMarkup(MarkupContainer container, Class<?> clazz, boolean enforceReload)
IMarkupCache
getMarkup
in interface IMarkupCache
container
- The original requesting markup containerclazz
- The class to get the associated markup for. If null, the container's class is
used, but it can be a parent class of the container as well (markup inheritance)enforceReload
- The cache will be ignored and all, including inherited markup files, will be
reloaded. Whatever is in the cache, it will be ignored
protected Markup onMarkupNotFound(String cacheKey, MarkupContainer container, Markup markup)
Subclasses may change the default implementation. E.g. they might choose not to update the cache to enforce reloading of any markup not found. This might be useful in very dynamic environments. Additionally a non-caching IResourceStreamLocator should be used.
cacheKey
- container
- markup
- Markup.NO_MARKUP
IResourceSettings.setResourceStreamLocator(org.apache.wicket.core.util.resource.locator.IResourceStreamLocator)
protected Markup putIntoCache(String locationString, MarkupContainer container, Markup markup)
locationString
- If null
then ignore the cachecontainer
- The container this markup is for.markup
-
protected Markup getMarkupFromCache(String cacheKey, MarkupContainer container)
cacheKey
- If null, than the cache will be ignoredcontainer
-
public IMarkupCacheKeyProvider getMarkupCacheKeyProvider(MarkupContainer container)
container
- The MarkupContainer requesting the markup resource stream
protected <K,V> MarkupCache.ICache<K,V> newCacheImplementation()
K
- V
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |