KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > sandesha > storage > dao > ISandeshaDAO


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package org.apache.sandesha.storage.dao;
18
19 import org.apache.sandesha.RMMessageContext;
20
21 import java.util.Set JavaDoc;
22
23 /**
24  * @author Chamikara Jayalath
25  */

26
27 public interface ISandeshaDAO {
28
29     /**
30      * This adds a new entry in the storage to to hold messages of a perticular
31      * sequence that come in to the sandesha server/client
32      */

33     boolean addIncomingSequence(String JavaDoc sequenceId);
34
35
36     /**
37      * This adds a entry in the storage for holding the messages of the given outgoing
38      * sequence.
39      */

40     boolean addOutgoingSequence(String JavaDoc sequenceId);
41
42
43     /**
44      * Adds a priority message (e.g. create seq) to the queue. These will be sent
45      * before other messages like application requests.
46      */

47     boolean addPriorityMessage(RMMessageContext message);
48
49
50     /**
51      * This checks the priority messages to see weather there is any one to
52      * be sent (either for the first time or a retransmission)
53      */

54     RMMessageContext getNextPriorityMessageContextToSend();
55
56
57     /**
58      * This adds a incoming message to a area belonging to the given sequence in the
59      * queue.
60      */

61     boolean addMessageToIncomingSequence(String JavaDoc sequenceId, Long JavaDoc msgNo,
62                                          RMMessageContext rmMessageContext);
63
64
65     /**
66      * This adds the given message to the given sequence.
67      */

68     boolean addMessageToOutgoingSequence(String JavaDoc sequenceId,
69                                          RMMessageContext rmMessageContext);
70
71
72     /**
73      * This checks weather there is a entry for the given incoming sequence in
74      * the queue.
75      */

76     boolean isIncomingSequenceExists(String JavaDoc sequenceId);
77
78
79     /**
80      * Checks weather a entry for the given outgoing sequence exists in
81      * the queue.
82      */

83     boolean isOutgoingSequenceExists(String JavaDoc sequenceId);
84
85
86     /**
87      * This checks in the given incoming sequence to see weather a message of
88      * the given message no exists
89      */

90     boolean isIncomingMessageExists(String JavaDoc sequenceId, Long JavaDoc msgNo);
91
92
93     /**
94      * This tries to get the next message to be sent from the given outgoing sequence
95      * If these is no message to be sent in the given sequence, null will be returned.
96      */

97     RMMessageContext getNextMsgContextToProcess(Object JavaDoc seq);
98
99
100     /**
101      * Gets the next possible message to be sent from the queue.
102      */

103     RMMessageContext getNextOutgoingMsgContextToSend();
104
105     public Object JavaDoc getRandomSeqToProcess();
106
107
108     /**
109      * This reutns a set of message numbers with all the message numbers of
110      * incoming sequence.
111      */

112     Set JavaDoc getAllReceivedMsgNumsOfIncomingSeq(String JavaDoc sequenceId);
113
114
115     /**
116      * This sets the outgoing sequence. Here seqId is the entry in the queue
117      * that we hope to hold the messages of a perticular sequence. outseqid is the
118      * actual sequence id (i.e. uuid). That will be set within the wsrm:sequence field of
119      * this message. (remember that we may not have received this actual outgoing sequence id
120      * by the time we start to store outgoing messages).
121      */

122     void setOutSequence(String JavaDoc sequenceId, String JavaDoc outSequenceId);
123
124
125     /**
126      * This sets a flag in the queue to indicate that the outSequence of the perticular message set
127      * (stored with the id seqId) has been set correctly. The value in outSequence may be wrong
128      * before the sender gets the create seq. response. After getting this and after setting the
129      * out sequence correctly using the previous method, this flag will be set to true. Only then these
130      * messages thould be send to the sender.
131      */

132     void setOutSequenceApproved(String JavaDoc sequenceID, boolean approved);
133
134
135     /**
136      * this gives the seqId which is used to hold the messages of which the
137      * outsequence entry has been set to the value outsequenceId.
138      */

139     String JavaDoc getSequenceOfOutSequence(String JavaDoc outsequenceId);
140
141
142     /**
143      * This checks the priority queue for a message if given messageid and
144      * moves it to the bin
145      */

146     void removeCreateSequenceMsg(String JavaDoc messageId);
147
148     /**
149      * This gives the next message number, outgoing storage of the given sequence
150      * esxpects. Actually this will be used by storage managers to obtain the message
151      * number that should be put to the next application message.
152      */

153     long getNextOutgoingMessageNumber(String JavaDoc sequenceId);
154
155     /**
156      * When the messageId of therequest message (e.g. from relates to) and the sequence id
157      * is given this will give the response message.
158      */

159     public RMMessageContext checkForResponseMessage(String JavaDoc requestId, String JavaDoc seqId);
160
161     /**
162      * Tries to give the sequence id of the outgoing message with the given message id
163      */

164     public String JavaDoc searchForSequenceId(String JavaDoc messageId);
165
166     /**
167      * This outgoing message will be marked as deleted.
168      * i.e. it will not be re-transmitted
169      */

170     public void markOutgoingMessageToDelete(String JavaDoc sequenceId, Long JavaDoc msgNumber);
171
172
173     /**
174      * Tells to the rtorage that the given message of given sequence was acked.
175      */

176     public void setAckReceived(String JavaDoc seqId, long msgNo);
177
178     /**
179      * Adds a low priority message to the storage (e.g. terminate sequence).
180      * These messages are axpected to be sent after sending all the other messages
181      * of the given sequence (but it is not a must)
182      */

183     public void addLowPriorityMessage(RMMessageContext msg);
184
185     /**
186      * Asks the storage for the next low priority message (if there is any)
187      */

188     public RMMessageContext getNextLowPriorityMessageContextToSend();
189
190     /**
191      * The message will be added to a sent list (the list holds the
192      * messages that were sent at least once)
193      */

194     public void addSendMsgNo(String JavaDoc seqId, long msgNo);
195
196     /**
197      * Asks from the storage weather the given message has been sent at
198      * least once
199      */

200     public boolean isSentMsg(String JavaDoc seqId, long msgNo);
201
202
203     /**
204      * Can be used to ckeck weather the last message has been received in the
205      * incoming sequence.
206      */

207     public boolean hasLastIncomingMsgReceived(String JavaDoc seqId);
208
209     /**
210      * Asks for the last message of the incoming sequence (if it has been received)
211      */

212     public long getLastIncomingMsgNo(String JavaDoc seqId);
213
214     /**
215      * When a server or client sends a create sequence, it will be marked from this method.
216      * But the actual resources will be allocated only when the first message arrives.
217      */

218     public void addRequestedSequence(String JavaDoc seqId);
219
220     /**
221      * Check weather the given sequence id is one of the requested once (see 'addRequestedSequence')
222      */

223     public boolean isRequestedSeqPresent(String JavaDoc seqId);
224
225     /**
226      * The client side will not be able to have sequenceId as a key for storing request messages.
227      * Since it may be not known when the user adds first message.
228      * This asks for that key, giving sequence id of incoming messages.
229      */

230     public String JavaDoc getKeyFromIncomingSequenceId(String JavaDoc incomingSeqID);
231
232     /**
233      * This asks for the above key (the key used to hold messages) given the outgoing sequece id.
234      */

235     public String JavaDoc getKeyFromOutgoingSequenceId(String JavaDoc outgoingSeqID);
236
237     /**
238      * Sets this after sending the terminate sequence message.
239      */

240     public void setTerminateSend(String JavaDoc seqId);
241
242     /**
243      * Sets a incoming sequence of messages as terminate received.
244      */

245     public void setTerminateReceived(String JavaDoc seqId);
246
247     /**
248      * Checks weather the terminate message of all out going sequences have been sent.
249      */

250     public boolean isAllOutgoingTerminateSent();
251
252     /**
253      * Use this to check weather the terminate message of all sequences (incoming) has
254      * been received.
255      */

256     public boolean isAllIncommingTerminateReceived();
257
258     /**
259      * Set the acks to of the given sequence.
260      */

261     public void setAcksTo(String JavaDoc seqId, String JavaDoc acksTo);
262
263     /**
264      * gets the acksTo value
265      */

266     public String JavaDoc getAcksTo(String JavaDoc seqId);
267
268     /**
269      * Sets the offered incoming sequence, of a outgoing sequence.
270      */

271     void addOffer(String JavaDoc msgID, String JavaDoc offerID);
272
273     /**
274      * Gets the offered incoming sequence, of outgoing sequence.
275      */

276     public String JavaDoc getOffer(String JavaDoc msgID);
277
278     /**
279      * clears the storage.
280      */

281     void clear();
282
283     public boolean isOutgoingTerminateSent(String JavaDoc seqId);
284
285     public boolean isIncommingTerminateReceived(String JavaDoc seqId);
286
287     public void updateFinalMessageArrivedTime(String JavaDoc sequenceID);
288
289     public void sendAck(String JavaDoc sequenceId);
290
291     public void removeAllAcks(String JavaDoc sequenceID);
292 }
Popular Tags