View Javadoc

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