此内容没有您所选择的语言版本。
Chapter 19. Custom Interceptors
Custom interceptors are deprecated in Data Grid and will be removed in a future version.
Custom interceptors are a way of extending Data Grid by being able to influence or respond to any modifications to cache. Example of such modifications are: elements are added/removed/updated or transactions are committed.
19.1. Adding custom interceptors declaratively 复制链接链接已复制到粘贴板!
Custom interceptors can be added on a per named cache basis. This is because each named cache have its own interceptor stack. Following xml snippet depicts the ways in which a custom interceptor can be added.
19.2. Adding custom interceptors programatically 复制链接链接已复制到粘贴板!
In order to do that one needs to obtain a reference to the AdvancedCache
. This can be done as follows:
CacheManager cm = getCacheManager();//magic Cache aCache = cm.getCache("aName"); AdvancedCache advCache = aCache.getAdvancedCache();
CacheManager cm = getCacheManager();//magic
Cache aCache = cm.getCache("aName");
AdvancedCache advCache = aCache.getAdvancedCache();
Then one of the addInterceptor() methods should be used to add the actual interceptor. For further documentation refer to AdvancedCache
javadoc.
19.3. Custom interceptor design 复制链接链接已复制到粘贴板!
When writing a custom interceptor, you need to abide by the following rules.
- Custom interceptors must declare a public, empty constructor to enable construction.
- Custom interceptors will have setters for any property defined through property tags used in the XML configuration.