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