public class MarkupCache extends Object implements IMarkupCache
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
MarkupSettings
and thus can be replaced with a sub-classed version.
MarkupSettings
,
MarkupFactory
Modifier and Type | Class and Description |
---|---|
static class |
MarkupCache.DefaultCacheImplementation<K,V> |
static interface |
MarkupCache.ICache<K,V>
MarkupCache allows you to implement you own cache implementation.
|
Modifier | Constructor and Description |
---|---|
protected |
MarkupCache()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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 <K,V> MarkupCache.ICache<K,V> |
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() |
public static 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 ignoredprotected 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_MARKUPResourceSettings.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 streamprotected <K,V> MarkupCache.ICache<K,V> newCacheImplementation()
K
- V
- Copyright © 2006–2022 Apache Software Foundation. All rights reserved.