1 23 package org.apache.slide.store.mem; 24 25 import org.apache.slide.common.ServiceAccessException; 26 import org.apache.slide.common.Uri; 27 import org.apache.slide.store.NodeStore; 28 import org.apache.slide.structure.ObjectAlreadyExistsException; 29 import org.apache.slide.structure.ObjectNode; 30 import org.apache.slide.structure.ObjectNotFoundException; 31 32 33 37 public class TransientNodeStore extends AbstractTransientStore implements 38 NodeStore 39 { 40 42 public ObjectNode retrieveObject(Uri uri) throws ServiceAccessException, 43 ObjectNotFoundException 44 { 45 debug("retrieveObject {0}", uri); 46 ObjectNode node = (ObjectNode)get(uri.toString()); 47 if (node != null) { 48 return node; 49 } else { 50 throw new ObjectNotFoundException(uri); 51 } 52 } 53 54 public void storeObject(Uri uri, ObjectNode object) 55 throws ServiceAccessException, ObjectNotFoundException 56 { 57 debug("storeObejct {0}", uri); 58 ObjectNode node = (ObjectNode)get(uri.toString()); 59 if (node != null) { 60 put(uri.toString(), object); 61 } else { 62 throw new ObjectNotFoundException(uri); 63 } 64 } 65 66 public void createObject(Uri uri, ObjectNode object) 67 throws ServiceAccessException, ObjectAlreadyExistsException 68 { 69 debug("createObject {0}", uri); 70 ObjectNode node = (ObjectNode)get(uri.toString()); 71 if (node == null) { 72 put(uri.toString(), object); 73 } else { 74 throw new ObjectAlreadyExistsException(uri.toString()); 75 } 76 } 77 78 public void removeObject(Uri uri, ObjectNode object) 79 throws ServiceAccessException, ObjectNotFoundException 80 { 81 debug("removeObject {0}", uri); 82 ObjectNode node = (ObjectNode)get(uri.toString()); 83 if (node != null) { 84 remove(uri.toString()); 85 } else { 86 throw new ObjectNotFoundException(uri); 87 } 88 } 89 } 90 | Popular Tags |