1 package org.xvsm.interfaces.container;
2
3 import java.net.URI;
4 import java.util.List;
5 import java.util.Properties;
6
7 import org.xvsm.core.ContainerRef;
8 import org.xvsm.core.Entry;
9 import org.xvsm.core.aspect.IAspect;
10 import org.xvsm.core.aspect.IPoint;
11 import org.xvsm.interfaces.ICoordinator;
12 import org.xvsm.internal.exceptions.AspectNotOkException;
13 import org.xvsm.internal.exceptions.AspectRescheduleException;
14 import org.xvsm.internal.exceptions.ContainerFullException;
15 import org.xvsm.internal.exceptions.CountNotMetException;
16 import org.xvsm.internal.exceptions.InvalidTransactionException;
17 import org.xvsm.internal.exceptions.NoSuchCoordinationTypeException;
18 import org.xvsm.internal.exceptions.TransactionLockException;
19 import org.xvsm.selectors.Selector;
20 import org.xvsm.transactions.Transaction;
21
22 /***
23 *
24 * @author Christian Schreiber, Michael Proestler
25 *
26 */
27 public interface ITransactionLayer {
28
29 /***
30 *
31 * {@inheritDoc}.
32 */
33 void commit(Transaction tx) throws TransactionLockException,
34 InvalidTransactionException, AspectRescheduleException,
35 AspectNotOkException;
36
37 /***
38 *
39 * {@inheritDoc}.
40 */
41 ICoordinator getCoordTypefromSelector(Class<? extends Selector> s)
42 throws NoSuchCoordinationTypeException;
43
44 /***
45 *
46 * {@inheritDoc}.
47 */
48 int getSize();
49
50 /***
51 * Returns the current size of the container.
52 *
53 * @return the number of entries currently in the container.
54 */
55 int currentSize();
56
57 /***
58 *
59 * {@inheritDoc}.
60 */
61 List<Entry> read(Transaction tx, List<Selector> selectors, int retrycount,
62 Properties aspectContext) throws NoSuchCoordinationTypeException,
63 CountNotMetException, InvalidTransactionException,
64 TransactionLockException, AspectRescheduleException,
65 AspectNotOkException;
66
67 /***
68 *
69 * {@inheritDoc}.
70 */
71 void rollback(Transaction tx) throws InvalidTransactionException,
72 TransactionLockException, AspectRescheduleException,
73 AspectNotOkException;
74
75 /***
76 *
77 * {@inheritDoc}.
78 */
79 List<Entry> shift(List<Entry> entries, Transaction tx,
80 Properties aspectContext) throws NoSuchCoordinationTypeException,
81 InvalidTransactionException, TransactionLockException,
82 AspectRescheduleException, AspectNotOkException;
83
84 /***
85 *
86 * {@inheritDoc}.
87 */
88 List<Entry> take(boolean isDelete, Transaction tx,
89 List<Selector> selectors, int retrycount, Properties aspectContext)
90 throws NoSuchCoordinationTypeException, CountNotMetException,
91 InvalidTransactionException, TransactionLockException,
92 AspectRescheduleException, AspectNotOkException;
93
94 /***
95 *
96 * {@inheritDoc}.
97 */
98 void write(List<Entry> entries, Transaction tx, int retrycount,
99 Properties aspectContext) throws ContainerFullException,
100 NoSuchCoordinationTypeException, InvalidTransactionException,
101 TransactionLockException, AspectRescheduleException,
102 AspectNotOkException;
103
104 /***
105 * Get the ContainerRef.
106 *
107 * @return the ContainerRef of the underlying Container.
108 */
109 ContainerRef getCref();
110
111 /***
112 * Method to set the ContainerRef to the underlying Container.
113 *
114 * @param cref
115 * the ContainerRef.
116 */
117 void setCref(ContainerRef cref);
118
119 /***
120 * Adds an Aspect to the Container.
121 *
122 * @param p
123 * the IPoint were the Aspect should be called.
124 * @param aspect
125 * the Aspect that should be called.
126 * @param aspectProperties
127 * possible properties that the aspect retreives, when it is
128 * called.
129 * @return the identifier of the aspect
130 */
131 String addAspects(List<IPoint> p, IAspect aspect,
132 Properties aspectProperties);
133
134 /***
135 * Removes an Aspect from the Container.
136 *
137 * @param p
138 * the IPoint were the Aspect should be removed.
139 * @param the
140 * uri of the aspect which shall be removed.
141 * @param aspectProperties
142 * possible properties that the aspect retrieves, when it is
143 * called.
144 */
145 void removeAspect(IPoint p, URI uri, Properties aspectProperties);
146
147 /***
148 * Adds a coordinator to the engine. If a coordinator has been added with
149 * the same selector class the old coordinator will be replaced by the new
150 * one.
151 *
152 * @param s
153 * the class of the selector to register the coordinator with.
154 * @param c
155 * the new coordinator.
156 */
157 void addCoordinator(Class<? extends Selector> s, ICoordinator c);
158
159 /***
160 * Get a List of all Coordinators supported by this Container.
161 *
162 * @return a List of all Coordinators supported by this Container.
163 */
164 List<ICoordinator> getCoordinators();
165 }