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.util.queue; 8 9 import java.io.IOException; 10 import java.util.List; 11 12 /** 13 * <code>QueuePersistenceStrategy</code> defines the The api to a persistent queue 14 * store. A persistence strategy can be transient (in memory or non-restorable) or 15 * non-transient such as File system or DB. 16 */ 17 public interface QueuePersistenceStrategy 18 { 19 20 public interface Holder 21 { 22 Object getId(); 23 24 String getQueue(); 25 } 26 27 28 /** 29 * Stores an object and returns its generated id. 30 * 31 * @param obj the object to be stored 32 * @return the id of the stored object 33 * @throws IOException 34 */ 35 Object store(String queue, Object obj) throws IOException; 36 37 /** 38 * Loads an object specified by the given id. 39 * 40 * @param id the id of the stored object 41 * @return the object 42 * @throws IOException 43 */ 44 Object load(String queue, Object id) throws IOException; 45 46 /** 47 * Removes the object specified by the given id from the store. 48 * 49 * @param id the id of the stored object 50 * @throws IOException 51 */ 52 void remove(String queue, Object id) throws IOException; 53 54 /** 55 * Retrieves the ids of the stored objects. 56 * 57 * @return the list of ids 58 * @throws IOException 59 */ 60 List restore() throws IOException; 61 62 /** 63 * Open the store. 64 * 65 * @throws IOException 66 */ 67 void open() throws IOException; 68 69 /** 70 * Closes the store. 71 * 72 * @throws IOException 73 */ 74 void close() throws IOException; 75 76 boolean isTransient(); 77 78 }