Initial import from https://bitbucket.org/opensymphony/oscache/
This commit is contained in:
commit
bd8f23d7d6
268 changed files with 34908 additions and 0 deletions
96
docs/wiki/Hibernate 2.1 Cache Provider.html
Normal file
96
docs/wiki/Hibernate 2.1 Cache Provider.html
Normal file
|
@ -0,0 +1,96 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>OSCache -
|
||||
Hibernate 2.1 Cache Provider
|
||||
</title>
|
||||
<link rel="stylesheet" href="styles/site.css" type="text/css" />
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
|
||||
<tr>
|
||||
<td valign="top" class="pagebody">
|
||||
<p>Patched version of OSCacheProvider.java originally created by Mathias Bogaert.</p>
|
||||
|
||||
<div class="code" style="border-style: solid; "><div class="codeHeader" style="border-bottom-style: solid; "><b>OSCacheProvider.java</b></div><div class="codeContent">
|
||||
<pre class="code-java"><span class="code-keyword">import</span> java.util.Properties;
|
||||
|
||||
<span class="code-keyword">import</span> net.sf.hibernate.cache.Cache;
|
||||
<span class="code-keyword">import</span> net.sf.hibernate.cache.CacheException;
|
||||
<span class="code-keyword">import</span> net.sf.hibernate.cache.CacheProvider;
|
||||
<span class="code-keyword">import</span> net.sf.hibernate.cache.Timestamper;
|
||||
<span class="code-keyword">import</span> net.sf.hibernate.util.PropertiesHelper;
|
||||
<span class="code-keyword">import</span> net.sf.hibernate.util.StringHelper;
|
||||
|
||||
<span class="code-keyword">import</span> com.opensymphony.oscache.base.CacheEntry;
|
||||
<span class="code-keyword">import</span> com.opensymphony.oscache.base.Config;
|
||||
|
||||
/**
|
||||
* Support <span class="code-keyword">for</span> OpenSymphony OSCache. This implementation assumes
|
||||
* that identifiers have well-behaved <tt>toString()</tt> methods.
|
||||
*/
|
||||
<span class="code-keyword">public</span> class OSCacheProvider <span class="code-keyword">implements</span> CacheProvider {
|
||||
|
||||
/**
|
||||
* The <tt>OSCache</tt> refresh period property suffix.
|
||||
*/
|
||||
<span class="code-keyword">public</span> <span class="code-keyword">static</span> <span class="code-keyword">final</span> <span class="code-object">String</span> OSCACHE_REFRESH_PERIOD = <span class="code-quote">"refresh.period"</span>;
|
||||
/**
|
||||
* The <tt>OSCache</tt> CRON expression property suffix.
|
||||
*/
|
||||
<span class="code-keyword">public</span> <span class="code-keyword">static</span> <span class="code-keyword">final</span> <span class="code-object">String</span> OSCACHE_CRON = <span class="code-quote">"cron"</span>;
|
||||
|
||||
<span class="code-keyword">private</span> <span class="code-keyword">static</span> <span class="code-keyword">final</span> Properties OSCACHE_PROPERTIES = <span class="code-keyword">new</span> Config().getProperties();
|
||||
|
||||
/**
|
||||
* Builds a <span class="code-keyword">new</span> {@link Cache} instance, and gets it's properties from the OSCache {@link Config}
|
||||
* which reads the properties file (<code>oscache.properties</code>) from the classpath.
|
||||
* If the file cannot be found or loaded, an the defaults are used.
|
||||
*
|
||||
* @param region
|
||||
* @param properties
|
||||
* @<span class="code-keyword">return</span>
|
||||
* @<span class="code-keyword">throws</span> CacheException
|
||||
*/
|
||||
<span class="code-keyword">public</span> Cache buildCache(<span class="code-object">String</span> region, Properties properties) <span class="code-keyword">throws</span> CacheException {
|
||||
|
||||
<span class="code-object">int</span> refreshPeriod = PropertiesHelper.getInt(
|
||||
StringHelper.qualify(region, OSCACHE_REFRESH_PERIOD),
|
||||
OSCACHE_PROPERTIES,
|
||||
CacheEntry.INDEFINITE_EXPIRY
|
||||
);
|
||||
<span class="code-object">String</span> cron = OSCACHE_PROPERTIES.getProperty( StringHelper.qualify(region, OSCACHE_CRON) );
|
||||
|
||||
<span class="code-comment">// construct the cache
|
||||
</span> <span class="code-keyword">return</span> <span class="code-keyword">new</span> OSCache(refreshPeriod, cron, region);
|
||||
}
|
||||
|
||||
<span class="code-keyword">public</span> <span class="code-object">long</span> nextTimestamp() {
|
||||
<span class="code-keyword">return</span> Timestamper.next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to perform any necessary initialization of the underlying cache implementation
|
||||
* during SessionFactory construction.
|
||||
*
|
||||
* @param properties current configuration settings.
|
||||
*/
|
||||
<span class="code-keyword">public</span> void start(Properties properties) <span class="code-keyword">throws</span> CacheException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to perform any necessary cleanup of the underlying cache implementation
|
||||
* during SessionFactory.close().
|
||||
*/
|
||||
<span class="code-keyword">public</span> void stop() {
|
||||
}
|
||||
|
||||
}</pre>
|
||||
</div></div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue