1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-09 08:52:51 +00:00

Several improvements

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-21 20:19:13 -03:00
parent 6efce6615f
commit ab38e7d5ba
125 changed files with 969 additions and 205 deletions

View File

@@ -29,6 +29,7 @@ import net.sf.ehcache.config.Configuration;
import net.sf.ehcache.config.DiskStoreConfiguration;
import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
import com.google.common.base.Preconditions;
import com.l2jserver.service.AbstractService;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException;
@@ -58,6 +59,9 @@ public class EhCacheService extends AbstractService implements CacheService {
@Override
public <T extends Cacheable> T decorate(final Class<T> interfaceType,
final T instance) {
Preconditions.checkNotNull(interfaceType, "interfaceType");
Preconditions.checkNotNull(instance, "instance");
if (!interfaceType.isInterface())
return null;
@SuppressWarnings("unchecked")
@@ -85,6 +89,9 @@ public class EhCacheService extends AbstractService implements CacheService {
@Override
public Cache createCache(String name, int size) {
Preconditions.checkNotNull(name, "name");
Preconditions.checkArgument(size > 0, "size <= 0");
Cache cache = new Cache(new CacheConfiguration(name, size)
.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
.overflowToDisk(true).eternal(false).timeToLiveSeconds(60)
@@ -96,16 +103,19 @@ public class EhCacheService extends AbstractService implements CacheService {
@Override
public Cache createCache(String name) {
Preconditions.checkNotNull(name, "name");
return createCache(name, 200);
}
@Override
public void register(Cache cache) {
Preconditions.checkNotNull(cache, "cache");
manager.addCache(cache);
}
@Override
public void unregister(Cache cache) {
Preconditions.checkNotNull(cache, "cache");
manager.removeCache(cache.getName());
}