directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r906739 - /directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
Date Thu, 04 Feb 2010 23:51:58 GMT
Author: elecharny
Date: Thu Feb  4 23:51:58 2010
New Revision: 906739

URL: http://svn.apache.org/viewvc?rev=906739&view=rev
Log:
Consolidated some generics constructions

Modified:
    directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java

Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java?rev=906739&r1=906738&r2=906739&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
(original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
Thu Feb  4 23:51:58 2010
@@ -73,6 +73,7 @@
 import org.apache.directory.ldap.client.api.message.ModifyRequest;
 import org.apache.directory.ldap.client.api.message.ModifyResponse;
 import org.apache.directory.ldap.client.api.message.Referral;
+import org.apache.directory.ldap.client.api.message.Response;
 import org.apache.directory.ldap.client.api.message.SearchRequest;
 import org.apache.directory.ldap.client.api.message.SearchResponse;
 import org.apache.directory.ldap.client.api.message.SearchResultDone;
@@ -196,7 +197,8 @@
     private Map<Integer, ResponseFuture> futureMap = new ConcurrentHashMap<Integer,
ResponseFuture>();
 
     /** a map to hold the response queues related to the operations */
-    private Map<Integer, BlockingQueue> respQueueMap = new ConcurrentHashMap<Integer,
BlockingQueue>();
+    private Map<Integer, BlockingQueue<? extends Response>> respQueueMap = 
+        new ConcurrentHashMap<Integer, BlockingQueue<? extends Response>>();
 
     /** list of controls supported by the server */
     private List<String> supportedControls;
@@ -713,10 +715,10 @@
 
         message.setProtocolOP( addReqCodec );
 
-        BlockingQueue<AddResponse> addResponseQueue = new LinkedBlockingQueue<AddResponse>();
+        BlockingQueue<Response> addResponseQueue = new LinkedBlockingQueue<Response>();
         respQueueMap.put( newId, addResponseQueue );
 
-        ResponseFuture addFuture = new ResponseFuture( addResponseQueue );
+        ResponseFuture<Response> addFuture = new ResponseFuture<Response>( addResponseQueue
);
         futureMap.put( newId, addFuture );
 
         // Send the request to the server
@@ -1179,7 +1181,7 @@
         LOG.debug( "-----------------------------------------------------------------" );
         LOG.debug( "Sending request \n{}", bindMessage );
 
-        BlockingQueue<BindResponse> bindResponseQueue = new LinkedBlockingQueue<BindResponse>();
+        BlockingQueue<Response> bindResponseQueue = new LinkedBlockingQueue<Response>();
         respQueueMap.put( newId, bindResponseQueue );
 
         // Create a future for this Bind opeation
@@ -1362,7 +1364,7 @@
         LOG.debug( "-----------------------------------------------------------------" );
         LOG.debug( "Sending request \n{}", searchMessage );
 
-        BlockingQueue<SearchResponse> searchResponseQueue = new LinkedBlockingQueue<SearchResponse>();
+        BlockingQueue<Response> searchResponseQueue = new LinkedBlockingQueue<Response>();
         respQueueMap.put( newId, searchResponseQueue );
 
         ResponseFuture searchFuture = new ResponseFuture( searchResponseQueue );
@@ -1547,14 +1549,17 @@
                 futureMap.remove( addRespCodec.getMessageId() );
                 AddListener addListener = ( AddListener ) listenerMap.remove( addRespCodec.getMessageId()
);
                 AddResponse addResp = convert( addRespCodec );
+                
                 if ( addListener != null )
                 {
                     addListener.entryAdded( this, addResp );
                 }
                 else
                 {
-                    addToRespQueueAndRemoveQueueRef( messageId, addResp );
+                    BlockingQueue<AddResponse> respQueue = (BlockingQueue<AddResponse>)respQueueMap.remove(
messageId );
+                    respQueue.add( addResp );
                 }
+                
                 break;
 
             case LdapConstants.BIND_RESPONSE:
@@ -1588,7 +1593,8 @@
                 }
 
                 // Store the response into the responseQueue
-                addToRespQueueAndRemoveQueueRef( messageId, bindResponse );
+                BlockingQueue<BindResponse> bindResponseQueue = (BlockingQueue<BindResponse>)respQueueMap.remove(
messageId );
+                bindResponseQueue.add( bindResponse );
 
                 break;
 
@@ -1597,18 +1603,20 @@
                 CompareResponseCodec compResCodec = response.getCompareResponse();
                 compResCodec.setMessageId( messageId );
                 compResCodec.addControl( response.getCurrentControl() );
-                CompareResponse compRes = convert( compResCodec );
+                CompareResponse compareResponse = convert( compResCodec );
 
-                futureMap.remove( compRes.getMessageId() );
+                futureMap.remove( compareResponse.getMessageId() );
 
-                CompareListener listener = ( CompareListener ) listenerMap.remove( compRes.getMessageId()
);
+                CompareListener listener = ( CompareListener ) listenerMap.remove( compareResponse.getMessageId()
);
+                
                 if ( listener != null )
                 {
-                    listener.attributeCompared( this, compRes );
+                    listener.attributeCompared( this, compareResponse );
                 }
                 else
                 {
-                    addToRespQueueAndRemoveQueueRef( messageId, compRes );
+                    BlockingQueue<CompareResponse> compareResponseQueue = (BlockingQueue<CompareResponse>)respQueueMap.remove(
messageId );
+                    compareResponseQueue.add( compareResponse );
                 }
 
                 break;
@@ -1618,18 +1626,19 @@
                 DelResponseCodec delRespCodec = response.getDelResponse();
                 delRespCodec.setMessageId( messageId );
                 delRespCodec.addControl( response.getCurrentControl() );
-                DeleteResponse delResp = convert( delRespCodec );
+                DeleteResponse delResponse = convert( delRespCodec );
 
-                futureMap.remove( delResp.getMessageId() );
-                DeleteListener delListener = ( DeleteListener ) listenerMap.remove( delResp.getMessageId()
);
+                futureMap.remove( delResponse.getMessageId() );
+                DeleteListener delListener = ( DeleteListener ) listenerMap.remove( delResponse.getMessageId()
);
                 
                 if ( delListener != null )
                 {
-                    delListener.entryDeleted( this, delResp );
+                    delListener.entryDeleted( this, delResponse );
                 }
                 else
                 {
-                    addToRespQueueAndRemoveQueueRef( messageId, delResp );
+                    BlockingQueue<DeleteResponse> delResponseQueue = (BlockingQueue<DeleteResponse>)respQueueMap.remove(
messageId );
+                    delResponseQueue.add( delResponse );
                 }
                 
                 break;
@@ -1649,7 +1658,8 @@
                 else
                 {
                     // Store the response into the responseQueue
-                    addToRespQueueAndRemoveQueueRef( messageId, extResponse );
+                    BlockingQueue<ExtendedResponse> extendedResponseQueue = (BlockingQueue<ExtendedResponse>)respQueueMap.remove(
messageId );
+                    extendedResponseQueue.add( extResponse );
                 }
 
                 break;
@@ -1664,6 +1674,7 @@
                 IntermediateResponse intrmResp = convert( intermediateResponseCodec );
                 IntermediateResponseListener intrmListener = ( IntermediateResponseListener
) listenerMap
                     .get( intermediateResponseCodec.getMessageId() );
+                
                 if ( intrmListener != null )
                 {
                     intrmListener.responseReceived( this, intrmResp );
@@ -1671,7 +1682,8 @@
                 else
                 {
                     // Store the response into the responseQueue
-                    addToRespQueueAndRemoveQueueRef( messageId, intrmResp );
+                    BlockingQueue<IntermediateResponse> intermediateResponseQueue =
(BlockingQueue<IntermediateResponse>)respQueueMap.remove( messageId );
+                    intermediateResponseQueue.add( intrmResp );
                 }
 
                 break;
@@ -1691,8 +1703,10 @@
                 }
                 else
                 {
-                    addToRespQueueAndRemoveQueueRef( messageId, modResp );
+                    BlockingQueue<ModifyResponse> modifyResponseQueue = (BlockingQueue<ModifyResponse>)respQueueMap.remove(
messageId );
+                    modifyResponseQueue.add( modResp );
                 }
+
                 break;
 
             case LdapConstants.MODIFYDN_RESPONSE:
@@ -1704,6 +1718,7 @@
 
                 futureMap.remove( modDnCodec.getMessageId() );
                 ModifyDnListener modDnListener = ( ModifyDnListener ) listenerMap.remove(
modDnCodec.getMessageId() );
+
                 if ( modDnListener != null )
                 {
                     modDnListener.modifyDnCompleted( this, modDnResp );
@@ -1711,8 +1726,10 @@
                 else
                 {
                     // Store the response into the responseQueue
-                    addToRespQueueAndRemoveQueueRef( messageId, modDnResp );
+                    BlockingQueue<ModifyDnResponse> modDnResponseQueue = (BlockingQueue<ModifyDnResponse>)respQueueMap.remove(
messageId );
+                    modDnResponseQueue.add( modDnResp );
                 }
+
                 break;
 
             case LdapConstants.SEARCH_RESULT_DONE:
@@ -1725,13 +1742,15 @@
                 futureMap.remove( searchResultDoneCodec.getMessageId() );
                 // search listener has to be removed from listener map only here
                 searchListener = ( SearchListener ) listenerMap.remove( searchResultDoneCodec.getMessageId()
);
+                
                 if ( searchListener != null )
                 {
                     searchListener.searchDone( this, srchDone );
                 }
                 else
                 {
-                    addToRespQueueAndRemoveQueueRef( messageId, srchDone );
+                    BlockingQueue<SearchResultDone> searchDoneResponseQueue = (BlockingQueue<SearchResultDone>)respQueueMap.remove(
messageId );
+                    searchDoneResponseQueue.add( srchDone );
                 }
 
                 break;
@@ -1752,7 +1771,8 @@
                 else
                 {
                     // shouldn't call addToRespQueueAndRemoveQueueRef
-                    respQueueMap.get( messageId ).add( srchEntry );
+                    BlockingQueue<SearchResponse> searchResponsequeue = (BlockingQueue<SearchResponse>)respQueueMap.get(
messageId );
+                    searchResponsequeue.add( srchEntry );
                 }
 
                 break;
@@ -1765,6 +1785,7 @@
 
                 SearchResultReference srchRef = convert( searchResultReferenceCodec );
                 searchListener = ( SearchListener ) listenerMap.get( searchResultReferenceCodec.getMessageId()
);
+                
                 if ( searchListener != null )
                 {
                     searchListener.referralFound( this, srchRef );
@@ -1772,7 +1793,8 @@
                 else
                 {
                     // shouldn't call addToRespQueueAndRemoveQueueRef
-                    respQueueMap.get( messageId ).add( srchRef );
+                    BlockingQueue<SearchResponse> searchResponsequeue = (BlockingQueue<SearchResponse>)respQueueMap.get(
messageId );
+                    searchResponsequeue.add( srchRef );
                 }
 
                 break;
@@ -1839,7 +1861,7 @@
         modifyMessage.setProtocolOP( modReqCodec );
         setControls( modRequest.getControls(), modifyMessage );
 
-        BlockingQueue<ModifyResponse> modifyResponseQueue = new LinkedBlockingQueue<ModifyResponse>();
+        BlockingQueue<Response> modifyResponseQueue = new LinkedBlockingQueue<Response>();
         respQueueMap.put( newId, modifyResponseQueue );
 
         ResponseFuture modifyFuture = new ResponseFuture( modifyResponseQueue );
@@ -2023,7 +2045,7 @@
         modifyDnMessage.setProtocolOP( modDnCodec );
         setControls( modDnRequest.getControls(), modifyDnMessage );
 
-        BlockingQueue<ModifyDnResponse> modifyDNResponseQueue = new LinkedBlockingQueue<ModifyDnResponse>();
+        BlockingQueue<Response> modifyDNResponseQueue = new LinkedBlockingQueue<Response>();
         respQueueMap.put( newId, modifyDNResponseQueue );
 
         ResponseFuture modifyDNFuture = new ResponseFuture( modifyDNResponseQueue );
@@ -2314,7 +2336,7 @@
         deleteMessage.setProtocolOP( delCodec );
         setControls( delRequest.getControls(), deleteMessage );
 
-        BlockingQueue<DeleteResponse> deleteResponseQueue = new LinkedBlockingQueue<DeleteResponse>();
+        BlockingQueue<Response> deleteResponseQueue = new LinkedBlockingQueue<Response>();
         respQueueMap.put( newId, deleteResponseQueue );
 
         ResponseFuture deleteFuture = new ResponseFuture( deleteResponseQueue );
@@ -2551,7 +2573,7 @@
 
         message.setProtocolOP( compareReqCodec );
 
-        BlockingQueue<CompareResponse> compareResponseQueue = new LinkedBlockingQueue<CompareResponse>();
+        BlockingQueue<Response> compareResponseQueue = new LinkedBlockingQueue<Response>();
         respQueueMap.put( newId, compareResponseQueue );
 
         ResponseFuture compareFuture = new ResponseFuture( compareResponseQueue );
@@ -2712,7 +2734,7 @@
 
         message.setProtocolOP( extReqCodec );
 
-        BlockingQueue<ExtendedResponse> extendedResponseQueue = new LinkedBlockingQueue<ExtendedResponse>();
+        BlockingQueue<Response> extendedResponseQueue = new LinkedBlockingQueue<Response>();
         respQueueMap.put( newId, extendedResponseQueue );
 
         ResponseFuture extendedFuture = new ResponseFuture( extendedResponseQueue );
@@ -2992,18 +3014,4 @@
         futureMap.remove( msgId );
         respQueueMap.remove( msgId );
     }
-
-
-    /**
-     * removes the blocking queue present in the
-     * respQueueMap and adds the given message to the blocking queue
-     *  
-     * @param msgId id of the message
-     * @param message the received response message to be added
-     */
-    private void addToRespQueueAndRemoveQueueRef( int msgId, AbstractMessage message )
-    {
-        BlockingQueue respQueue = respQueueMap.remove( msgId );
-        respQueue.add( message );
-    }
 }



Mime
View raw message