1 /* 2 * $Id: ObjectStore.java 21762 2011-05-03 01:29:28Z mike.schilling $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com 5 * 6 * The software in this package is published under the terms of the CPAL v1.0 7 * license, a copy of which has been included with this distribution in the 8 * LICENSE.txt file. 9 */ 10 package org.mule.api.store; 11 12 import java.io.Serializable; 13 14 public interface ObjectStore<T extends Serializable> 15 { 16 /** 17 * Check whether the given Object is already registered with this store. 18 * 19 * @param key the identifier of the object to check 20 * @return <code>true</code> if the key is stored or <code>false</code> no value was stored for 21 * the key. 22 * @throws ObjectStoreException if the given key is <code>null</code>. 23 * @throws ObjectStoreNotAvaliableException if any implementation-specific error occured, e.g. 24 * when the store is not available 25 */ 26 boolean contains(Serializable key) throws ObjectStoreException; 27 28 /** 29 * Store the given Object. 30 * 31 * @param key the identifier for <code>value</code> 32 * @param value the Object to store with <code>key</code> 33 * @throws ObjectStoreException if the given key cannot be stored or is <code>null</code>. 34 * @throws ObjectStoreNotAvaliableException if the store is not available or any other 35 * implementation-specific error occured. 36 * @throws ObjectAlreadyExistsException if an attempt is made to store an object for a key 37 * that already has an object associated. 38 */ 39 void store(Serializable key, T value) throws ObjectStoreException; 40 41 /** 42 * Retrieve the given Object. 43 * 44 * @param key the identifier of the object to retrieve. 45 * @return the object associated with the given key. If no object for the given key was found 46 * this method throws an {@link ObjectDoesNotExistException}. 47 * @throws ObjectStoreException if the given key is <code>null</code>. 48 * @throws ObjectStoreNotAvaliableException if the store is not available or any other 49 * implementation-specific error occured. 50 * @throws ObjectDoesNotExistException if no value for the given key was previously stored. 51 */ 52 T retrieve(Serializable key) throws ObjectStoreException; 53 54 /** 55 * Remove the object with key. 56 * 57 * @param key the identifier of the object to remove. 58 * @return the object that was previously stored for the given key 59 * @throws ObjectStoreException if the given key is <code>null</code> or if the store is not 60 * available or any other implementation-specific error occured 61 * @throws ObjectDoesNotExistException if no value for the given key was previously stored. 62 */ 63 T remove(Serializable key) throws ObjectStoreException; 64 65 /** 66 * Is this store persistent? 67 * 68 * @return true if this store is persistent 69 */ 70 boolean isPersistent(); 71 }