Package org.apache.wiki.providers

# Class CachingProvider

java.lang.Object
org.apache.wiki.providers.CachingProvider

All Implemented Interfaces:
  `org.apache.wiki.api.providers.PageProvider`, `org.apache.wiki.api.providers.WikiProvider`

public class CachingProvider extends Object implements org.apache.wiki.api.providers.PageProvider
Provides a caching page provider. This class rests on top of a real provider class and provides a cache to speed things up. Only if the cache copy of the page text has expired, we fetch it from the provider.

This class does not detect if someone has modified the page externally, not through JSPWiki routines.

Heavily based on ideas by Chris Brooking.

Since 2.10 uses the Ehcache library.

Since:
  1.6.4

## Field Summary

### Fields inherited from interface org.apache.wiki.api.providers.WikiProvider

`LATEST_VERSION`

## Constructor Summary

Constructors
Constructor
Description
`CachingProvider()`

## Method Summary

Modifier and Type
Method
Description
`void`
`deletePage(String pageName)`
`void`
`deleteVersion(String pageName, int version)`
`Collection<org.apache.wiki.api.search.SearchResult>`
`findPages(org.apache.wiki.api.search.QueryItem[] query)`
`Collection<org.apache.wiki.api.core.Page>`
`getAllChangedSince(Date date)`
`Collection<org.apache.wiki.api.core.Page>`
`getAllPages()`
`int`
`getPageCount()`
`org.apache.wiki.api.core.Page`
`getPageInfo(String pageName, int version)`
`String`
`getPageText(String pageName, int version)`
`String`
`getProviderInfo()`
Gets the provider class name, and cache statistics (misscount and hitcount of page cache and history cache).
`org.apache.wiki.api.providers.PageProvider`
`getRealProvider()`
Returns the actual used provider.
`List<org.apache.wiki.api.core.Page>`
`getVersionHistory(String pageName)`
`void`
`initialize(org.apache.wiki.api.core.Engine engine, Properties properties)`
`void`
`movePage(String from, String to)`
`boolean`
`pageExists(String pageName)`
`boolean`
`pageExists(String pageName, int version)`
`void`
`putPageText(org.apache.wiki.api.core.Page page, String text)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CachingProvider

public CachingProvider()

## Method Details

### initialize

public void initialize(org.apache.wiki.api.core.Engine engine, Properties properties) throws org.apache.wiki.api.exceptions.NoRequiredPropertyException, IOException

Specified by:
  `initialize` in interface `org.apache.wiki.api.providers.WikiProvider`
Throws:
  `org.apache.wiki.api.exceptions.NoRequiredPropertyException`
  `IOException`

### pageExists

public boolean pageExists(String pageName, int version)

Specified by:
  `pageExists` in interface `org.apache.wiki.api.providers.PageProvider`

### pageExists

public boolean pageExists(String pageName)

Specified by:
  `pageExists` in interface `org.apache.wiki.api.providers.PageProvider`

### getPageText

public String getPageText(String pageName, int version) throws org.apache.wiki.api.exceptions.ProviderException

Specified by:
  `getPageText` in interface `org.apache.wiki.api.providers.PageProvider`
Throws:
  `org.apache.wiki.api.exceptions.ProviderException`

### putPageText

public void putPageText(org.apache.wiki.api.core.Page page, String text) throws org.apache.wiki.api.exceptions.ProviderException

Specified by:
  `putPageText` in interface `org.apache.wiki.api.providers.PageProvider`
Throws:
  `org.apache.wiki.api.exceptions.ProviderException`

### getAllPages

public Collection<org.apache.wiki.api.core.Page> getAllPages() throws org.apache.wiki.api.exceptions.ProviderException

Specified by:
  `getAllPages` in interface `org.apache.wiki.api.providers.PageProvider`
Throws:
  `org.apache.wiki.api.exceptions.ProviderException`

### getAllChangedSince

public Collection<org.apache.wiki.api.core.Page> getAllChangedSince(Date date)

Specified by:
  `getAllChangedSince` in interface `org.apache.wiki.api.providers.PageProvider`

### getPageCount

public int getPageCount() throws org.apache.wiki.api.exceptions.ProviderException

Specified by:
  `getPageCount` in interface `org.apache.wiki.api.providers.PageProvider`
Throws:
  `org.apache.wiki.api.exceptions.ProviderException`

### findPages

public Collection<org.apache.wiki.api.search.SearchResult> findPages(org.apache.wiki.api.search.QueryItem[] query)

Specified by:
  `findPages` in interface `org.apache.wiki.api.providers.PageProvider`

### getPageInfo

public org.apache.wiki.api.core.Page getPageInfo(String pageName, int version) throws org.apache.wiki.api.exceptions.ProviderException

Specified by:
  `getPageInfo` in interface `org.apache.wiki.api.providers.PageProvider`
Throws:
  `org.apache.wiki.api.exceptions.ProviderException`

### getVersionHistory

public List<org.apache.wiki.api.core.Page> getVersionHistory(String pageName) throws org.apache.wiki.api.exceptions.ProviderException

Specified by:
  `getVersionHistory` in interface `org.apache.wiki.api.providers.PageProvider`
Throws:
  `org.apache.wiki.api.exceptions.ProviderException`

### getProviderInfo

public String getProviderInfo()
Gets the provider class name, and cache statistics (misscount and hitcount of page cache and history cache).

Specified by:
  `getProviderInfo` in interface `org.apache.wiki.api.providers.WikiProvider`
Returns:
  A plain string with all the above-mentioned values.

### deleteVersion

public void deleteVersion(String pageName, int version) throws org.apache.wiki.api.exceptions.ProviderException

Specified by:
  `deleteVersion` in interface `org.apache.wiki.api.providers.PageProvider`
Throws:
  `org.apache.wiki.api.exceptions.ProviderException`

### deletePage

public void deletePage(String pageName) throws org.apache.wiki.api.exceptions.ProviderException

Specified by:
  `deletePage` in interface `org.apache.wiki.api.providers.PageProvider`
Throws:
  `org.apache.wiki.api.exceptions.ProviderException`

### movePage

public void movePage(String from, String to) throws org.apache.wiki.api.exceptions.ProviderException

Specified by:
  `movePage` in interface `org.apache.wiki.api.providers.PageProvider`
Throws:
  `org.apache.wiki.api.exceptions.ProviderException`

### getRealProvider

public org.apache.wiki.api.providers.PageProvider getRealProvider()
Returns the actual used provider.

Returns:
  The real provider.
Since:
  2.0