001package org.cache2k.impl; 002 003/* 004 * #%L 005 * cache2k core package 006 * %% 007 * Copyright (C) 2000 - 2015 headissue GmbH, Munich 008 * %% 009 * This program is free software: you can redistribute it and/or modify 010 * it under the terms of the GNU General Public License as 011 * published by the Free Software Foundation, either version 3 of the 012 * License, or (at your option) any later version. 013 * 014 * This program is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 017 * GNU General Public License for more details. 018 * 019 * You should have received a copy of the GNU General Public 020 * License along with this program. If not, see 021 * <http://www.gnu.org/licenses/gpl-3.0.html>. 022 * #L% 023 */ 024 025import org.cache2k.ClosableIterator; 026import org.cache2k.impl.threading.Futures; 027import org.cache2k.storage.StorageEntry; 028 029import java.util.concurrent.Future; 030 031/** 032 * @author Jens Wilke; created: 2014-06-02 033 */ 034public class NoopStorageAdapter extends StorageAdapter { 035 036 BaseCache cache; 037 038 public NoopStorageAdapter(BaseCache cache) { 039 this.cache = cache; 040 } 041 042 @Override 043 public void open() { 044 } 045 046 @Override 047 public Future<Void> cancelTimerJobs() { 048 return null; 049 } 050 051 @Override 052 public Future<Void> shutdown() { 053 return new Futures.FinishedFuture<Void>(); 054 } 055 056 @Override 057 public void flush() { } 058 059 @Override 060 public void purge() { } 061 062 @Override 063 public boolean checkStorageStillDisconnectedForClear() { 064 return true; 065 } 066 067 @Override 068 public void disconnectStorageForClear() { 069 070 } 071 072 @Override 073 public Future<Void> clearAndReconnect() { 074 return new Futures.FinishedFuture<Void>(null); 075 } 076 077 @Override 078 public void put(Entry e, long _nextRefreshTime) { } 079 080 @Override 081 public StorageEntry get(Object key) { 082 return null; 083 } 084 085 @Override 086 public boolean remove(Object key) { return false; } 087 088 @Override 089 public void evict(Entry e) { } 090 091 @Override 092 public void expire(Entry e) { } 093 094 @Override 095 public void disable(Throwable t) { } 096 097 @SuppressWarnings("unchecked") 098 @Override 099 public ClosableIterator<Entry> iterateAll() { 100 return new EmptyClosableIterator<Entry>(); 101 } 102 103 @Override 104 public int getTotalEntryCount() { 105 synchronized (cache.lock) { 106 return cache.getLocalSize(); 107 } 108 } 109 110 @Override 111 public int getAlert() { 112 return 0; 113 } 114 115 static class EmptyClosableIterator<E> implements ClosableIterator<E> { 116 117 @Override 118 public void close() { } 119 120 @Override 121 public boolean hasNext() { return false; } 122 123 @Override 124 public E next() { return null; } 125 126 @Override 127 public void remove() { } 128 129 } 130 131}