Debian Codegraph @

java-sdk/ietfldap/org/ietf/ldap/LDAPMessageQueue.java

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is mozilla.org code.
17 *
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 2001
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38 package org.ietf.ldap;
39
40 /**
41 * A queue of response messsages from the server. Multiple requests
42 * can be multiplexed on the same queue. For synchronous LDAPConnection
43 * requests, there will be only one request per queue. For asynchronous
44 * LDAPConnection requests, the user can add multiple request to the
45 * same queue.
46 *
47 */
48 public interface LDAPMessageQueue {
49
50 /**
51 * Returns the count of queued messages
52 * @return message count
53 */
54 public int getMessageCount();
55
56 /**
57 * Returns a list of message IDs for all outstanding requests
58 * @return message ID array.
59 */
60 public int[] getMessageIDs();
61
62 /**
63 * Blocks until a response is available or until all operations
64 * associated with the object have completed or been canceled
65 *
66 * @return LDAP message or null if there are no more outstanding requests.
67 * @exception LDAPException Network error exception
68 * @exception LDAPInterruptedException The invoking thread was interrupted
69 */
70 public LDAPMessage getResponse() throws LDAPException;
71
72 /**
73 * Blocks until a response is available for a particular message ID, or
74 * until all operations associated with the message ID have completed or
75 * been canceled, and returns the response. If there is no outstanding
76 * operation for the message ID (or if it is zero or a negative number),
77 * IllegalArgumentException is thrown.
78 *
79 * @param msgid A particular message to query for responses available
80 * @return a response for an LDAP operation or null if there are no
81 * more outstanding requests.
82 * @exception LDAPException Network error exception
83 * @exception LDAPInterruptedException The invoking thread was interrupted
84 */
85
86 public LDAPMessage getResponse( int msgid )
87 throws LDAPException;
88
89 /**
90 * Checks if a response message has been received
91 *
92 * @return true or false.
93 */
94 public boolean isResponseReceived();
95
96 /**
97 * Reports true if a response has been received from the server for a
98 * particular message ID. If there is no outstanding operation for the
99 * message ID (or if it is zero or a negative number),
100 * IllegalArgumentException is thrown.
101 *
102 * @param msgid A particular message to query for responses available
103 * @return a flag indicating whether the response message queue is empty
104 */
105 public boolean isResponseReceived( int msgid );
106
107 /**
108 * Merge two message queues.
109 * Move/append the content from another message queue to this one.
110 *
111 * To be used for synchronization of asynchronous LDAP operations where
112 * requests are sent by one thread but processed by another one
113 *
114 * A client may be implemented in such a way that one thread makes LDAP
115 * requests and calls l.getMessageIDs(), while another thread is
116 * responsible for
117 * processing of responses (call l.getResponse()). Both threads are using
118 * the same queue objects. In such a case, a race
119 * condition may occur, where a LDAP response message is retrieved and
120 * the request terminated (request ID removed) before the first thread
121 * has a chance to execute l.getMessageIDs().
122 * The proper way to handle this scenario is to create a separate queue
123 * for each new request, and after l.getMessageIDs() has been invoked,
124 * merge the
125 * new request with the existing one.
126 * @param mq2 message queue to merge with this one
127 */
128 public void merge( LDAPMessageQueue mq2 );
129 }