1
2
3
4
5
6
7
8
9
10
11 package org.mule.util.store;
12
13 import org.mule.api.store.ListableObjectStore;
14 import org.mule.api.store.ObjectStoreException;
15 import org.mule.api.store.PartitionableObjectStore;
16
17 import java.io.Serializable;
18 import java.util.List;
19
20 public class ObjectStorePartition<T extends Serializable> implements ListableObjectStore<T>
21 {
22
23 final String partitionName;
24 final PartitionableObjectStore<T> partitionedObjectStore;
25
26 public ObjectStorePartition(String partitionName, PartitionableObjectStore<T> partitionedObjectStore)
27 {
28 this.partitionName = partitionName;
29 this.partitionedObjectStore = partitionedObjectStore;
30 }
31
32 @Override
33 public boolean contains(Serializable key) throws ObjectStoreException
34 {
35 return partitionedObjectStore.contains(key, partitionName);
36 }
37
38 @Override
39 public void store(Serializable key, T value) throws ObjectStoreException
40 {
41 partitionedObjectStore.store(key, value, partitionName);
42 }
43
44 @Override
45 public T retrieve(Serializable key) throws ObjectStoreException
46 {
47 return partitionedObjectStore.retrieve(key, partitionName);
48 }
49
50 @Override
51 public T remove(Serializable key) throws ObjectStoreException
52 {
53 return partitionedObjectStore.remove(key, partitionName);
54 }
55
56 @Override
57 public boolean isPersistent()
58 {
59 return partitionedObjectStore.isPersistent();
60 }
61
62 @Override
63 public void open() throws ObjectStoreException
64 {
65 partitionedObjectStore.open(partitionName);
66 }
67
68 @Override
69 public void close() throws ObjectStoreException
70 {
71 partitionedObjectStore.close(partitionName);
72 }
73
74 @Override
75 public List<Serializable> allKeys() throws ObjectStoreException
76 {
77 return partitionedObjectStore.allKeys(partitionName);
78 }
79
80 public PartitionableObjectStore<T> getBaseStore()
81 {
82 return partitionedObjectStore;
83 }
84
85 public String getPartitionName()
86 {
87 return partitionName;
88 }
89
90 }