View Javadoc

1   /*
2    * $Id: QueuePersistenceStrategy.java 19191 2010-08-25 21:05:23Z tcarlson $
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  
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      /**
33       * Stores an object and returns its generated id.
34       * 
35       * @param obj the object to be stored
36       * @return the id of the stored object
37       * @throws IOException
38       */
39      Object store(String queue, Object obj) throws IOException;
40  
41      /**
42       * Loads an object specified by the given id.
43       * 
44       * @param id the id of the stored object
45       * @return the object
46       * @throws IOException
47       */
48      Object load(String queue, Object id) throws IOException;
49  
50      /**
51       * Removes the object specified by the given id from the store.
52       * 
53       * @param id the id of the stored object
54       * @throws IOException
55       */
56      void remove(String queue, Object id) throws IOException;
57  
58      /**
59       * Retrieves the ids of the stored objects.
60       * 
61       * @return the list of ids
62       * @throws IOException
63       */
64      List restore() throws IOException;
65  
66      /**
67       * Open the store.
68       * 
69       * @throws IOException
70       */
71      void open() throws IOException;
72  
73      /**
74       * Closes the store.
75       * 
76       * @throws IOException
77       */
78      void close() throws IOException;
79  
80      boolean isTransient();
81  
82  }