Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 59519 invoked from network); 11 Apr 2009 07:15:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Apr 2009 07:15:59 -0000 Received: (qmail 908 invoked by uid 500); 11 Apr 2009 07:15:59 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 852 invoked by uid 500); 11 Apr 2009 07:15:59 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 843 invoked by uid 99); 11 Apr 2009 07:15:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Apr 2009 07:15:59 +0000 X-ASF-Spam-Status: No, hits=-1998.8 required=10.0 tests=ALL_TRUSTED,FS_REPLICA X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Apr 2009 07:15:57 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E70C32388B68; Sat, 11 Apr 2009 07:15:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r764179 - /directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/future/SearchFuture.java Date: Sat, 11 Apr 2009 07:15:35 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090411071535.E70C32388B68@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Sat Apr 11 07:15:35 2009 New Revision: 764179 URL: http://svn.apache.org/viewvc?rev=764179&view=rev Log: Added a SearchFuture class Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/future/SearchFuture.java Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/future/SearchFuture.java URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/future/SearchFuture.java?rev=764179&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/future/SearchFuture.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/future/SearchFuture.java Sat Apr 11 07:15:35 2009 @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages.future; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.apache.directory.shared.ldap.client.api.messages.SearchResponse; + +/** + * A Future to manage SerachRequest + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class SearchFuture implements Future +{ + /** The queue where SearchResponse are stored */ + private BlockingQueue searchResponseQueue; + + + /** + * + * Creates a new instance of SearchFuture. + * + * @param searchResponseQueue The associated SearchResponse queue + */ + public SearchFuture( BlockingQueue searchResponseQueue ) + { + this.searchResponseQueue = searchResponseQueue; + } + + + /** + * {@inheritDoc} + */ + public boolean cancel( boolean mayInterruptIfRunning ) + { + throw new RuntimeException( "Not Yet Implemented" ); + } + + + /** + * Get the SearchResponse, blocking until one is received. + * It can be either a SearchResultEntry, a SearchResultReference + * or a SearchResultDone, the last of all the SearchResponse. + * + * @return The SearchResponse + */ + public SearchResponse get() throws InterruptedException, ExecutionException + { + return searchResponseQueue.poll(); + } + + + /** + * Get the SearchResponse, blocking until one is received, or until the + * given timeout is reached. + * + * @param timeout Number of TimeUnit to wait + * @param unit The TimeUnit + * @return The SearchResponse The SearchResponse found + */ + public SearchResponse get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException, + TimeoutException + { + return searchResponseQueue.poll( timeout, unit ); + } + + + /** + * {@inheritDoc} + */ + public boolean isCancelled() + { + throw new RuntimeException( "Not Yet Implemented" ); + } + + + /** + * {@inheritDoc} + */ + public boolean isDone() + { + throw new RuntimeException( "Not Yet Implemented" ); + } +}