1 25 26 package org.jrobin.core; 27 28 import java.io.IOException ; 29 import java.util.HashMap ; 30 31 41 public class RrdMemoryBackendFactory extends RrdBackendFactory { 42 43 public static final String NAME = "MEMORY"; 44 private HashMap backends = new HashMap (); 45 46 55 protected synchronized RrdBackend open(String id, boolean readOnly, int lockMode) 56 throws IOException { 57 RrdMemoryBackend backend; 58 if(backends.containsKey(id)) { 59 backend = (RrdMemoryBackend) backends.get(id); 60 } 61 else { 62 backend = new RrdMemoryBackend(id); 63 backends.put(id, backend); 64 } 65 return backend; 66 } 67 68 73 protected synchronized boolean exists(String id) { 74 return backends.containsKey(id); 75 } 76 77 82 public boolean delete(String id) { 83 if(backends.containsKey(id)) { 84 backends.remove(id); 85 return true; 86 } 87 else { 88 return false; 89 } 90 } 91 92 96 public String getFactoryName() { 97 return NAME; 98 } 99 } 100 | Popular Tags |