directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r987607 [2/3] - in /directory/clients/ldap/trunk: ./ ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/ ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/ ldap-client-api/src/main/java/org/apache/dir...
Date Fri, 20 Aug 2010 19:25:19 GMT
Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=987607&r1=987606&r2=987607&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Fri Aug 20 19:25:18 2010
@@ -24,14 +24,12 @@ import java.io.File;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
@@ -51,68 +49,13 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.ldap.client.api.future.ResponseFuture;
 import org.apache.directory.ldap.client.api.future.SearchFuture;
 import org.apache.directory.ldap.client.api.listener.DeleteListener;
-import org.apache.directory.ldap.client.api.message.AbandonRequest;
-import org.apache.directory.ldap.client.api.message.AbstractMessage;
-import org.apache.directory.ldap.client.api.message.AddRequest;
-import org.apache.directory.ldap.client.api.message.AddResponse;
-import org.apache.directory.ldap.client.api.message.BindRequest;
-import org.apache.directory.ldap.client.api.message.BindResponse;
-import org.apache.directory.ldap.client.api.message.CompareRequest;
-import org.apache.directory.ldap.client.api.message.CompareResponse;
-import org.apache.directory.ldap.client.api.message.DeleteRequest;
-import org.apache.directory.ldap.client.api.message.DeleteResponse;
-import org.apache.directory.ldap.client.api.message.ExtendedIntermediateResponse;
-import org.apache.directory.ldap.client.api.message.ExtendedRequest;
-import org.apache.directory.ldap.client.api.message.ExtendedResponse;
-import org.apache.directory.ldap.client.api.message.IntermediateResponse;
-import org.apache.directory.ldap.client.api.message.LdapResult;
-import org.apache.directory.ldap.client.api.message.ModifyDnRequest;
-import org.apache.directory.ldap.client.api.message.ModifyDnResponse;
-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.SearchIntermediateResponse;
-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;
-import org.apache.directory.ldap.client.api.message.SearchResultEntry;
-import org.apache.directory.ldap.client.api.message.SearchResultReference;
 import org.apache.directory.ldap.client.api.protocol.LdapProtocolCodecFactory;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.primitives.OID;
-import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
-import org.apache.directory.shared.ldap.codec.LdapResultCodec;
-import org.apache.directory.shared.ldap.codec.LdapTransformer;
 import org.apache.directory.shared.ldap.codec.MessageEncoderException;
-import org.apache.directory.shared.ldap.codec.abandon.AbandonRequestCodec;
-import org.apache.directory.shared.ldap.codec.add.AddRequestCodec;
-import org.apache.directory.shared.ldap.codec.add.AddResponseCodec;
-import org.apache.directory.shared.ldap.codec.bind.BindRequestCodec;
-import org.apache.directory.shared.ldap.codec.bind.BindResponseCodec;
-import org.apache.directory.shared.ldap.codec.bind.LdapAuthentication;
-import org.apache.directory.shared.ldap.codec.bind.SaslCredentials;
-import org.apache.directory.shared.ldap.codec.bind.SimpleAuthentication;
-import org.apache.directory.shared.ldap.codec.compare.CompareRequestCodec;
-import org.apache.directory.shared.ldap.codec.compare.CompareResponseCodec;
 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
-import org.apache.directory.shared.ldap.codec.del.DelRequestCodec;
-import org.apache.directory.shared.ldap.codec.del.DelResponseCodec;
-import org.apache.directory.shared.ldap.codec.extended.ExtendedRequestCodec;
-import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
-import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
-import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
-import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
-import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequestCodec;
-import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
-import org.apache.directory.shared.ldap.codec.search.Filter;
-import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
-import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
-import org.apache.directory.shared.ldap.codec.search.SearchResultEntryCodec;
-import org.apache.directory.shared.ldap.codec.search.SearchResultReferenceCodec;
-import org.apache.directory.shared.ldap.codec.unbind.UnBindRequestCodec;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.Cursor;
 import org.apache.directory.shared.ldap.entry.DefaultEntry;
@@ -123,11 +66,43 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
-import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AbandonRequest;
+import org.apache.directory.shared.ldap.message.AbandonRequestImpl;
+import org.apache.directory.shared.ldap.message.AddRequest;
+import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.message.AddResponse;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.BindRequest;
+import org.apache.directory.shared.ldap.message.BindRequestImpl;
+import org.apache.directory.shared.ldap.message.BindResponse;
+import org.apache.directory.shared.ldap.message.CompareRequest;
+import org.apache.directory.shared.ldap.message.CompareRequestImpl;
+import org.apache.directory.shared.ldap.message.CompareResponse;
+import org.apache.directory.shared.ldap.message.DeleteRequest;
+import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
+import org.apache.directory.shared.ldap.message.DeleteResponse;
+import org.apache.directory.shared.ldap.message.ExtendedRequest;
+import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
+import org.apache.directory.shared.ldap.message.ExtendedResponse;
+import org.apache.directory.shared.ldap.message.IntermediateResponse;
+import org.apache.directory.shared.ldap.message.IntermediateResponseImpl;
+import org.apache.directory.shared.ldap.message.Message;
+import org.apache.directory.shared.ldap.message.ModifyDnRequest;
+import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
+import org.apache.directory.shared.ldap.message.ModifyDnResponse;
+import org.apache.directory.shared.ldap.message.ModifyRequest;
+import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
+import org.apache.directory.shared.ldap.message.ModifyResponse;
+import org.apache.directory.shared.ldap.message.Response;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.SearchRequest;
+import org.apache.directory.shared.ldap.message.SearchRequestImpl;
+import org.apache.directory.shared.ldap.message.SearchResultDone;
+import org.apache.directory.shared.ldap.message.SearchResultEntry;
+import org.apache.directory.shared.ldap.message.SearchResultReference;
+import org.apache.directory.shared.ldap.message.UnbindRequest;
+import org.apache.directory.shared.ldap.message.UnbindRequestImpl;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
@@ -140,7 +115,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.ObjectClassRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Schema;
-import org.apache.directory.shared.ldap.util.LdapURL;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.mina.core.filterchain.IoFilter;
 import org.apache.mina.core.future.CloseFuture;
@@ -175,7 +149,7 @@ public class LdapNetworkConnection exten
     private static final String LDAP_RESPONSE = "LdapReponse";
 
     /** The timeout used for response we are waiting for */
-    private long timeOut = LdapConnectionConfig.DEFAULT_TIMEOUT;
+    private long timeout = LdapConnectionConfig.DEFAULT_TIMEOUT;
 
     /** configuration object for the connection */
     private LdapConnectionConfig config = new LdapConnectionConfig();
@@ -296,7 +270,7 @@ public class LdapNetworkConnection exten
         ResponseFuture<? extends Response> future = futureMap.get( messageId );
 
         // future can be null if there was a abandon operation on that messageId
-        if( future != null )
+        if ( future != null )
         {
             LOG.debug( "Getting <" + messageId + ", " + future.getClass().getName() + ">" );
         }
@@ -306,192 +280,23 @@ public class LdapNetworkConnection exten
 
 
     /**
-     * Return the response stored into the current session.
-     *
-     * @return The last request response
-     */
-    public LdapMessageCodec getResponse()
-    {
-        return ( LdapMessageCodec ) ldapSession.getAttribute( LDAP_RESPONSE );
-    }
-
-
-    /**
-     * Inject the client Controls into the message
-     */
-    private void setControls( Map<String, Control> controls, LdapMessageCodec message )
-    {
-        // Add the controls
-        if ( controls != null )
-        {
-            for ( Control control : controls.values() )
-            {
-                ControlImpl ctrl = new ControlImpl( control.getOid() );
-
-                ctrl.setValue( control.getValue() );
-
-                message.addControl( ctrl );
-            }
-        }
-    }
-
-
-    /**
      * Get the smallest timeout from the client timeout and the connection
      * timeout.
      */
-    private long getTimeout( long clientTimeOut )
-    {
-        if ( clientTimeOut <= 0 )
-        {
-            return ( timeOut <= 0 ) ? Long.MAX_VALUE : timeOut;
-        }
-        else if ( timeOut <= 0 )
-        {
-            return clientTimeOut;
-        }
-        else
-        {
-            return timeOut < clientTimeOut ? timeOut : clientTimeOut;
-        }
-    }
-
-
-    /**
-     * Convert a BindResponseCodec to a BindResponse message
-     */
-    private BindResponse convert( BindResponseCodec bindResponseCodec )
-    {
-        BindResponse bindResponse = new BindResponse();
-
-        bindResponse.setMessageId( bindResponseCodec.getMessageId() );
-        bindResponse.setServerSaslCreds( bindResponseCodec.getServerSaslCreds() );
-        bindResponse.setLdapResult( convert( bindResponseCodec.getLdapResult() ) );
-        addControls( bindResponseCodec, bindResponse );
-
-        return bindResponse;
-    }
-
-
-    /**
-     * Convert a IntermediateResponseCodec to a IntermediateResponse message based on the ResponseFuture's type
-     */
-    private void setIResponse( IntermediateResponseCodec intermediateResponseCodec, ResponseFuture responseFuture ) throws Exception
+    private long getTimeout( long clientTimeout )
     {
-        IntermediateResponse intermediateResponse = null;
-
-        if( responseFuture instanceof SearchFuture )
+        if ( clientTimeout <= 0 )
         {
-            intermediateResponse = new SearchIntermediateResponse();
-            addControls( intermediateResponseCodec, ( SearchIntermediateResponse ) intermediateResponse );
+            return ( timeout <= 0 ) ? Long.MAX_VALUE : timeout;
         }
-        else if( responseFuture instanceof ExtendedFuture )
+        else if ( timeout <= 0 )
         {
-            intermediateResponse = new ExtendedIntermediateResponse();
-            addControls( intermediateResponseCodec, ( ExtendedIntermediateResponse ) intermediateResponse );
+            return clientTimeout;
         }
         else
         {
-            // currently we only support IR for search and extended operations
-            throw new UnsupportedOperationException( "Unknown ResponseFuture type " + responseFuture.getClass().getName() );
+            return timeout < clientTimeout ? timeout : clientTimeout;
         }
-
-        intermediateResponse.setResponseName( intermediateResponseCodec.getResponseName() );
-        intermediateResponse.setResponseValue( intermediateResponseCodec.getResponseValue() );
-
-        responseFuture.set( intermediateResponse );
-    }
-
-
-    /**
-     * Convert a LdapResultCodec to a LdapResult message
-     */
-    private LdapResult convert( LdapResultCodec ldapResultCodec )
-    {
-        LdapResult ldapResult = new LdapResult();
-
-        ldapResult.setErrorMessage( ldapResultCodec.getErrorMessage() );
-        ldapResult.setMatchedDn( ldapResultCodec.getMatchedDN() );
-
-        // Loop on the referrals
-        Referral referral = new Referral();
-
-        if ( ldapResultCodec.getReferrals() != null )
-        {
-            for ( LdapURL url : ldapResultCodec.getReferrals() )
-            {
-                referral.addLdapUrls( url );
-            }
-        }
-
-        ldapResult.setReferral( referral );
-        ldapResult.setResultCode( ldapResultCodec.getResultCode() );
-
-        return ldapResult;
-    }
-
-
-    /**
-     * Convert a SearchResultEntryCodec to a SearchResultEntry message
-     */
-    private SearchResultEntry convert( SearchResultEntryCodec searchEntryResultCodec )
-    {
-        SearchResultEntry searchResultEntry = new SearchResultEntry();
-
-        searchResultEntry.setMessageId( searchEntryResultCodec.getMessageId() );
-        if( schemaManager != null )
-        {
-            searchResultEntry.setEntry( new DefaultEntry( schemaManager, searchEntryResultCodec.getEntry() ) );
-        }
-        else
-        {
-            searchResultEntry.setEntry( searchEntryResultCodec.getEntry() );
-        }
-        addControls( searchEntryResultCodec, searchResultEntry );
-
-        return searchResultEntry;
-    }
-
-
-    /**
-     * Convert a SearchResultDoneCodec to a SearchResultDone message
-     */
-    private SearchResultDone convert( SearchResultDoneCodec searchResultDoneCodec )
-    {
-        SearchResultDone searchResultDone = new SearchResultDone();
-
-        searchResultDone.setMessageId( searchResultDoneCodec.getMessageId() );
-        searchResultDone.setLdapResult( convert( searchResultDoneCodec.getLdapResult() ) );
-        addControls( searchResultDoneCodec, searchResultDone );
-
-        return searchResultDone;
-    }
-
-
-    /**
-     * Convert a SearchResultReferenceCodec to a SearchResultReference message
-     */
-    private SearchResultReference convert( SearchResultReferenceCodec searchEntryReferenceCodec )
-    {
-        SearchResultReference searchResultReference = new SearchResultReference();
-
-        searchResultReference.setMessageId( searchEntryReferenceCodec.getMessageId() );
-
-        // Loop on the referrals
-        Referral referral = new Referral();
-
-        if ( searchEntryReferenceCodec.getSearchResultReferences() != null )
-        {
-            for ( LdapURL url : searchEntryReferenceCodec.getSearchResultReferences() )
-            {
-                referral.addLdapUrls( url );
-            }
-        }
-
-        searchResultReference.setReferral( referral );
-        addControls( searchEntryReferenceCodec, searchResultReference );
-
-        return searchResultReference;
     }
 
 
@@ -736,7 +541,10 @@ public class LdapNetworkConnection exten
             throw new IllegalArgumentException( msg );
         }
 
-        return add( new AddRequest( entry ) );
+        AddRequest addRequest = new AddRequestImpl();
+        addRequest.setEntry( entry );
+
+        return add( addRequest );
     }
 
 
@@ -752,7 +560,10 @@ public class LdapNetworkConnection exten
             throw new IllegalArgumentException( msg );
         }
 
-        return addAsync( new AddRequest( entry ) );
+        AddRequest addRequest = new AddRequestImpl();
+        addRequest.setEntry( entry );
+
+        return addAsync( addRequest );
     }
 
 
@@ -767,8 +578,6 @@ public class LdapNetworkConnection exten
         try
         {
             // Read the response, waiting for it if not available immediately
-            long timeout = getTimeout( addRequest.getTimeout() );
-
             // Get the response, blocking
             AddResponse addResponse = addFuture.get( timeout, TimeUnit.MILLISECONDS );
 
@@ -829,22 +638,14 @@ public class LdapNetworkConnection exten
     {
         checkSession();
 
-        AddRequestCodec addReqCodec = new AddRequestCodec();
-
         int newId = messageId.incrementAndGet();
 
         addRequest.setMessageId( newId );
-        addReqCodec.setMessageId( newId );
-
-        addReqCodec.setEntry( addRequest.getEntry() );
-        addReqCodec.setEntryDn( addRequest.getEntry().getDn() );
-        setControls( addRequest.getControls(), addReqCodec );
-
         AddFuture addFuture = new AddFuture( this, newId );
         addToFutureMap( newId, addFuture );
 
         // Send the request to the server
-        WriteFuture writeFuture = ldapSession.write( addReqCodec );
+        WriteFuture writeFuture = ldapSession.write( addRequest );
 
         // Wait for the message to be sent to the server
         if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
@@ -860,21 +661,6 @@ public class LdapNetworkConnection exten
     }
 
 
-    /**
-     * converts the AddResponseCodec to AddResponse.
-     */
-    private AddResponse convert( AddResponseCodec addRespCodec )
-    {
-        AddResponse addResponse = new AddResponse();
-
-        addResponse.setMessageId( addRespCodec.getMessageId() );
-        addResponse.setLdapResult( convert( addRespCodec.getLdapResult() ) );
-        addControls( addRespCodec, addResponse );
-
-        return addResponse;
-    }
-
-
     //------------------------ The LDAP operations ------------------------//
 
     /**
@@ -882,8 +668,8 @@ public class LdapNetworkConnection exten
      */
     public void abandon( int messageId )
     {
-        AbandonRequest abandonRequest = new AbandonRequest();
-        abandonRequest.setAbandonedMessageId( messageId );
+        AbandonRequest abandonRequest = new AbandonRequestImpl();
+        abandonRequest.setAbandoned( messageId );
 
         abandonInternal( abandonRequest );
     }
@@ -903,28 +689,17 @@ public class LdapNetworkConnection exten
      */
     private void abandonInternal( AbandonRequest abandonRequest )
     {
-        // Create the inner abandonRequest
-        AbandonRequestCodec request = new AbandonRequestCodec();
+        LOG.debug( "-----------------------------------------------------------------" );
+        LOG.debug( "Sending request \n{}", abandonRequest );
 
-        // Todo : The Abandon messageID is always 0
         int newId = messageId.incrementAndGet();
         abandonRequest.setMessageId( newId );
-        request.setMessageId( newId );
-
-        // Inject the data into the request
-        request.setAbandonedMessageId( abandonRequest.getAbandonedMessageId() );
-
-        // Inject the controls
-        setControls( abandonRequest.getControls(), request );
-
-        LOG.debug( "-----------------------------------------------------------------" );
-        LOG.debug( "Sending request \n{}", request );
 
         // Send the request to the server
-        ldapSession.write( request );
+        ldapSession.write( abandonRequest );
 
         // remove the associated listener if any
-        int abandonId = abandonRequest.getAbandonedMessageId();
+        int abandonId = abandonRequest.getAbandoned();
 
         ResponseFuture<? extends Response> rf = getFromFutureMap( abandonId );
 
@@ -955,9 +730,7 @@ public class LdapNetworkConnection exten
         LOG.debug( "Anonymous Bind request" );
 
         // Create the BindRequest
-        BindRequest bindRequest = new BindRequest();
-        bindRequest.setName( StringTools.EMPTY );
-        bindRequest.setCredentials( StringTools.EMPTY_BYTES );
+        BindRequest bindRequest = createBindRequest( StringTools.EMPTY, StringTools.EMPTY_BYTES );
 
         return bind( bindRequest );
     }
@@ -971,9 +744,7 @@ public class LdapNetworkConnection exten
         LOG.debug( "Anonymous Bind request" );
 
         // Create the BindRequest
-        BindRequest bindRequest = new BindRequest();
-        bindRequest.setName( StringTools.EMPTY );
-        bindRequest.setCredentials( StringTools.EMPTY_BYTES );
+        BindRequest bindRequest = createBindRequest( StringTools.EMPTY, StringTools.EMPTY_BYTES );
 
         return bindAsync( bindRequest );
     }
@@ -987,9 +758,7 @@ public class LdapNetworkConnection exten
         LOG.debug( "Bind request : {}", name );
 
         // Create the BindRequest
-        BindRequest bindRequest = new BindRequest();
-        bindRequest.setName( name );
-        bindRequest.setCredentials( StringTools.getBytesUtf8( credentials ) );
+        BindRequest bindRequest = createBindRequest( name, StringTools.getBytesUtf8( credentials ) );
 
         return bind( bindRequest );
     }
@@ -1003,9 +772,7 @@ public class LdapNetworkConnection exten
         LOG.debug( "Bind request : {}", name );
 
         // Create the BindRequest
-        BindRequest bindRequest = new BindRequest();
-        bindRequest.setName( name );
-        bindRequest.setCredentials( StringTools.getBytesUtf8( credentials ) );
+        BindRequest bindRequest = createBindRequest( name, StringTools.getBytesUtf8( credentials ) );
 
         return bindAsync( bindRequest );
     }
@@ -1019,17 +786,8 @@ public class LdapNetworkConnection exten
         LOG.debug( "Bind request : {}", name );
 
         // Create the BindRequest
-        BindRequest bindRequest = new BindRequest();
-        bindRequest.setCredentials( StringTools.getBytesUtf8( credentials ) );
-
-        if ( name == null )
-        {
-            bindRequest.setName( StringTools.EMPTY );
-        }
-        else
-        {
-            bindRequest.setName( name.getName() );
-        }
+        BindRequest bindRequest = createBindRequest( name, StringTools.getBytesUtf8( credentials ), null,
+            ( Control ) null );
 
         return bind( bindRequest );
     }
@@ -1043,17 +801,7 @@ public class LdapNetworkConnection exten
         LOG.debug( "Bind request : {}", name );
 
         // Create the BindRequest
-        BindRequest bindRequest = new BindRequest();
-        bindRequest.setCredentials( StringTools.getBytesUtf8( credentials ) );
-
-        if ( name == null )
-        {
-            bindRequest.setName( StringTools.EMPTY );
-        }
-        else
-        {
-            bindRequest.setName( name.getName() );
-        }
+        BindRequest bindRequest = createBindRequest( name, StringTools.getBytesUtf8( credentials ) );
 
         return bindAsync( bindRequest );
     }
@@ -1070,8 +818,6 @@ public class LdapNetworkConnection exten
         try
         {
             // Read the response, waiting for it if not available immediately
-            long timeout = getTimeout( bindRequest.getTimeout() );
-
             // Get the response, blocking
             BindResponse bindResponse = bindFuture.get( timeout, TimeUnit.MILLISECONDS );
 
@@ -1129,7 +875,7 @@ public class LdapNetworkConnection exten
 
     /**
      * Create a SearchRequestCodec ready to be sent.
-     */
+     *
     private SearchRequestCodec createSearchMessage( SearchRequest searchRequest ) throws LdapException
     {
         // Create a new codec SearchRequest object
@@ -1212,64 +958,126 @@ public class LdapNetworkConnection exten
 
 
     /**
-     * Create a BindRequest ready to be sent.
+     * Create a Simple BindRequest ready to be sent.
      */
-    private BindRequestCodec createBindMessage( BindRequest bindRequest ) throws LdapException
+    private BindRequest createBindRequest( String name, byte[] credentials ) throws LdapException
     {
-        // Create a new codec BindRequest object
-        BindRequestCodec bindRequestCodec = new BindRequestCodec();
+        return createBindRequest( name, credentials, null, ( Control[] ) null );
+    }
 
-        // clear the mappings if any (in case of a second call to bind() without calling unBind())
-        //clearMaps();
 
-        // Set the new messageId
-        int newId = messageId.incrementAndGet();
-        bindRequest.setMessageId( newId );
-        bindRequestCodec.setMessageId( newId );
+    /**
+     * Create a Simple BindRequest ready to be sent.
+     */
+    private BindRequest createBindRequest( DN name, byte[] credentials ) throws LdapException
+    {
+        return createBindRequest( name, credentials, null, ( Control[] ) null );
+    }
 
-        // Set the version
-        bindRequestCodec.setVersion( LdapConnectionConfig.LDAP_V3 );
 
+    /**
+     * Create a Simple BindRequest with controls ready to be sent.
+     */
+    private BindRequest createBindRequest( String name, byte[] credentials, Control[] controls )
+        throws LdapException
+    {
+        return createBindRequest( name, credentials, null, controls );
+    }
+
+
+    /**
+     * Create a Simple BindRequest with controls ready to be sent.
+     */
+    private BindRequest createBindRequest( DN name, byte[] credentials, Control[] controls )
+        throws LdapException
+    {
+        return createBindRequest( name, credentials, null, controls );
+    }
+
+
+    /**
+     * Create a SASL BindRequest ready to be sent.
+     */
+    private BindRequest createBindRequest( String name, byte[] credentials, String mechanism )
+        throws LdapException
+    {
+        return createBindRequest( name, credentials, mechanism, ( Control[] ) null );
+    }
+
+
+    /**
+     * Create a SASL BindRequest ready to be sent.
+     */
+    private BindRequest createBindRequest( DN name, byte[] credentials, String mechanism ) throws LdapException
+    {
+        return createBindRequest( name, credentials, mechanism, ( Control ) null );
+    }
+
+
+    /**
+     * Create a complete BindRequest ready to be sent.
+     */
+    private BindRequest createBindRequest( String name, byte[] credentials, String saslMechanism,
+        Control... controls ) throws LdapException
+    {
         // Set the name
         try
         {
-            DN dn = new DN( bindRequest.getName() );
-            bindRequestCodec.setName( dn );
+            DN dn = new DN( name );
+            return createBindRequest( dn, credentials, saslMechanism, controls );
         }
         catch ( LdapInvalidDnException ine )
         {
-            String msg = "The given dn '" + bindRequest.getName() + "' is not valid";
+            String msg = "The given dn '" + name + "' is not valid";
             LOG.error( msg );
             LdapException ldapException = new LdapException( msg );
             ldapException.initCause( ine );
 
             throw ldapException;
         }
+    }
 
-        // Set the credentials
-        LdapAuthentication authentication = null;
 
-        if ( bindRequest.isSimple() )
+    /**
+     * Create a complete BindRequest ready to be sent.
+     */
+    private BindRequest createBindRequest( DN name, byte[] credentials, String saslMechanism,
+        Control... controls ) throws LdapException
+    {
+        // clear the mappings if any (in case of a second call to bind() without calling unBind())
+        //clearMaps();
+
+        // Set the new messageId
+        BindRequest bindRequest = new BindRequestImpl();
+
+        // Set the version
+        bindRequest.setVersion3( true );
+
+        // Set the name
+        bindRequest.setName( name );
+
+        // Set the credentials
+        if ( StringTools.isEmpty( saslMechanism ) )
         {
             // Simple bind
-            authentication = new SimpleAuthentication();
-            ( ( SimpleAuthentication ) authentication ).setSimple( bindRequest.getCredentials() );
+            bindRequest.setSimple( true );
+            bindRequest.setCredentials( credentials );
         }
         else
         {
             // SASL bind
-            authentication = new SaslCredentials();
-            ( ( SaslCredentials ) authentication ).setCredentials( bindRequest.getCredentials() );
-            ( ( SaslCredentials ) authentication ).setMechanism( bindRequest.getSaslMechanism() );
+            bindRequest.setSimple( false );
+            bindRequest.setCredentials( credentials );
+            bindRequest.setSaslMechanism( saslMechanism );
         }
 
-        // The authentication
-        bindRequestCodec.setAuthentication( authentication );
-
         // Add the controls
-        setControls( bindRequest.getControls(), bindRequestCodec );
+        if ( ( controls != null ) && ( controls.length != 0 ) )
+        {
+            bindRequest.addAllControls( controls );
+        }
 
-        return bindRequestCodec;
+        return bindRequest;
     }
 
 
@@ -1287,13 +1095,12 @@ public class LdapNetworkConnection exten
         // If the session has not been establish, or is closed, we get out immediately
         checkSession();
 
-        // Create the new message and update the messageId
-        LdapMessageCodec bindMessage = createBindMessage( bindRequest );
-
-        int newId = bindMessage.getMessageId();
+        // Update the messageId
+        int newId = messageId.incrementAndGet();
+        bindRequest.setMessageId( newId );
 
         LOG.debug( "-----------------------------------------------------------------" );
-        LOG.debug( "Sending request \n{}", bindMessage );
+        LOG.debug( "Sending request \n{}", bindRequest );
 
         // Create a future for this Bind operation
         BindFuture bindFuture = new BindFuture( this, newId );
@@ -1301,7 +1108,7 @@ public class LdapNetworkConnection exten
         addToFutureMap( newId, bindFuture );
 
         // Send the request to the server
-        WriteFuture writeFuture = ldapSession.write( bindMessage );
+        WriteFuture writeFuture = ldapSession.write( bindRequest );
 
         // Wait for the message to be sent to the server
         if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
@@ -1320,7 +1127,7 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
-    public Cursor<SearchResponse> search( DN baseDn, String filter, SearchScope scope, String... attributes )
+    public Cursor<Response> search( DN baseDn, String filter, SearchScope scope, String... attributes )
         throws LdapException
     {
         if ( baseDn == null )
@@ -1330,9 +1137,9 @@ public class LdapNetworkConnection exten
         }
 
         // Create a new SearchRequest object
-        SearchRequest searchRequest = new SearchRequest();
+        SearchRequest searchRequest = new SearchRequestImpl();
 
-        searchRequest.setBaseDn( baseDn );
+        searchRequest.setBase( baseDn );
         searchRequest.setFilter( filter );
         searchRequest.setScope( scope );
         searchRequest.addAttributes( attributes );
@@ -1346,7 +1153,7 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
-    public Cursor<SearchResponse> search( String baseDn, String filter, SearchScope scope, String... attributes )
+    public Cursor<Response> search( String baseDn, String filter, SearchScope scope, String... attributes )
         throws LdapException
     {
         return search( new DN( baseDn ), filter, scope, attributes );
@@ -1360,9 +1167,9 @@ public class LdapNetworkConnection exten
         throws LdapException
     {
         // Create a new SearchRequest object
-        SearchRequest searchRequest = new SearchRequest();
+        SearchRequest searchRequest = new SearchRequestImpl();
 
-        searchRequest.setBaseDn( baseDn );
+        searchRequest.setBase( baseDn );
         searchRequest.setFilter( filter );
         searchRequest.setScope( scope );
         searchRequest.addAttributes( attributes );
@@ -1391,17 +1198,17 @@ public class LdapNetworkConnection exten
         // If the session has not been establish, or is closed, we get out immediately
         checkSession();
 
-        // Create the server request
-        SearchRequestCodec request = createSearchMessage( searchRequest );
+        int newId = messageId.incrementAndGet();
+        searchRequest.setMessageId( newId );
 
         LOG.debug( "-----------------------------------------------------------------" );
-        LOG.debug( "Sending request \n{}", request );
+        LOG.debug( "Sending request \n{}", searchRequest );
 
-        SearchFuture searchFuture = new SearchFuture( this, request.getMessageId() );
-        addToFutureMap( request.getMessageId(), searchFuture );
+        SearchFuture searchFuture = new SearchFuture( this, searchRequest.getMessageId() );
+        addToFutureMap( searchRequest.getMessageId(), searchFuture );
 
         // Send the request to the server
-        WriteFuture writeFuture = ldapSession.write( request );
+        WriteFuture writeFuture = ldapSession.write( searchRequest );
 
         // Wait for the message to be sent to the server
         if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
@@ -1421,18 +1228,17 @@ public class LdapNetworkConnection exten
 
         // Ok, done return the future
         return searchFuture;
-
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public Cursor<SearchResponse> search( SearchRequest searchRequest ) throws LdapException
+    public Cursor<Response> search( SearchRequest searchRequest ) throws LdapException
     {
         SearchFuture searchFuture = searchAsync( searchRequest );
 
-        long timeout = getTimeout( searchRequest.getTimeout() );
+        long timeout = getTimeout( searchRequest.getTimeLimit() );
 
         return new SearchCursor( searchFuture, timeout, TimeUnit.MILLISECONDS );
     }
@@ -1449,13 +1255,12 @@ public class LdapNetworkConnection exten
         // If the session has not been establish, or is closed, we get out immediately
         checkSession();
 
-        // Create the UnbindRequest
-        UnBindRequestCodec unbindRequest = new UnBindRequestCodec();
-
         // Creates the messageID and stores it into the
         // initial message and the transmitted message.
         int newId = messageId.incrementAndGet();
-        unbindRequest.setMessageId( newId );
+
+        // Create the UnbindRequest
+        UnbindRequest unbindRequest = new UnbindRequestImpl( newId );
 
         LOG.debug( "-----------------------------------------------------------------" );
         LOG.debug( "Sending Unbind request \n{}", unbindRequest );
@@ -1484,7 +1289,7 @@ public class LdapNetworkConnection exten
         }
 
         // Last, not least, reset the MessageId value
-        messageId.set(0);
+        messageId.set( 0 );
 
         // And get out
         LOG.debug( "Unbind successful" );
@@ -1505,9 +1310,9 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
-    public void setTimeOut( long timeOut )
+    public void setTimeOut( long timeout )
     {
-        this.timeOut = timeOut;
+        this.timeout = timeout;
     }
 
 
@@ -1518,11 +1323,11 @@ public class LdapNetworkConnection exten
     {
         if ( cause instanceof ProtocolEncoderException )
         {
-            Throwable realCause = ((ProtocolEncoderException)cause).getCause();
+            Throwable realCause = ( ( ProtocolEncoderException ) cause ).getCause();
 
             if ( realCause instanceof MessageEncoderException )
             {
-                int messageId = ((MessageEncoderException)realCause).getMessageId();
+                int messageId = ( ( MessageEncoderException ) realCause ).getMessageId();
 
                 ResponseFuture<?> response = futureMap.get( messageId );
                 response.cancel( true );
@@ -1539,39 +1344,32 @@ public class LdapNetworkConnection exten
     public void messageReceived( IoSession session, Object message ) throws Exception
     {
         // Feed the response and store it into the session
-        LdapMessageCodec response = ( LdapMessageCodec ) message;
-
+        Message response = ( Message ) message;
         LOG.debug( "-------> {} Message received <-------", response );
+        int messageId = response.getMessageId();
 
         // this check is necessary to prevent adding an abandoned operation's
         // result(s) to corresponding queue
-        ResponseFuture<? extends Response> responseFuture = peekFromFutureMap( response.getMessageId() );
+        ResponseFuture<? extends Response> responseFuture = peekFromFutureMap( messageId );
 
         if ( responseFuture == null )
         {
-            LOG.info( "There is no future associated with the messageId {}, ignoring the message", response
-                .getMessageId() );
+            LOG.info( "There is no future associated with the messageId {}, ignoring the message", messageId );
             return;
         }
 
-        int messageId = response.getMessageId();
-
-        switch ( response.getMessageType() )
+        switch ( response.getType() )
         {
             case ADD_RESPONSE:
                 // Transform the response
-                AddResponseCodec addRespCodec = (AddResponseCodec)response;
-                addRespCodec.addControls( response.getControls() );
-                addRespCodec.setMessageId( messageId );
+                AddResponse addResponse = ( AddResponse ) response;
 
-                AddResponse addResponse = convert( addRespCodec );
-
-                AddFuture addFuture = (AddFuture)responseFuture;
+                AddFuture addFuture = ( AddFuture ) responseFuture;
 
                 if ( addFuture == null )
                 {
                     LOG.error( "AddFuture is null" );
-                    throw new LdapException( "AddFuture is null"  );
+                    throw new LdapException( "AddFuture is null" );
                 }
 
                 // remove the listener from the listener map
@@ -1599,17 +1397,14 @@ public class LdapNetworkConnection exten
 
             case BIND_RESPONSE:
                 // Transform the response
-                BindResponseCodec bindResponseCodec = (BindResponseCodec)response;
-                bindResponseCodec.setMessageId( messageId );
-                bindResponseCodec.addControls( response.getControls() );
-                BindResponse bindResponse = convert( bindResponseCodec );
+                BindResponse bindResponse = ( BindResponse ) response;
 
-                BindFuture bindFuture = (BindFuture)responseFuture;
+                BindFuture bindFuture = ( BindFuture ) responseFuture;
 
                 if ( bindFuture == null )
                 {
                     LOG.error( "BindFuture is null" );
-                    throw new LdapException( "BindFuture is null"  );
+                    throw new LdapException( "BindFuture is null" );
                 }
 
                 // remove the listener from the listener map
@@ -1636,18 +1431,14 @@ public class LdapNetworkConnection exten
 
             case COMPARE_RESPONSE:
                 // Transform the response
-                CompareResponseCodec compResCodec = (CompareResponseCodec)response;
-                compResCodec.setMessageId( messageId );
-                compResCodec.addControls( response.getControls() );
-
-                CompareResponse compareResponse = convert( compResCodec );
+                CompareResponse compareResponse = ( CompareResponse ) response;
 
-                CompareFuture compareFuture = (CompareFuture)responseFuture;
+                CompareFuture compareFuture = ( CompareFuture ) responseFuture;
 
                 if ( compareFuture == null )
                 {
                     LOG.error( "CompareFuture is null" );
-                    throw new LdapException( "CompareFuture is null"  );
+                    throw new LdapException( "CompareFuture is null" );
                 }
 
                 // remove the listener from the listener map
@@ -1675,18 +1466,14 @@ public class LdapNetworkConnection exten
 
             case DEL_RESPONSE:
                 // Transform the response
-                DelResponseCodec delRespCodec = (DelResponseCodec)response;
-                delRespCodec.addControls( response.getControls() );
-                delRespCodec.setMessageId( messageId );
-
-                DeleteResponse deleteResponse = convert( delRespCodec );
+                DeleteResponse deleteResponse = ( DeleteResponse ) response;
 
-                DeleteFuture deleteFuture = (DeleteFuture)responseFuture;
+                DeleteFuture deleteFuture = ( DeleteFuture ) responseFuture;
 
                 if ( deleteFuture == null )
                 {
                     LOG.error( "DeleteFuture is null" );
-                    throw new LdapException( "DeleteFuture is null"  );
+                    throw new LdapException( "DeleteFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
@@ -1713,18 +1500,14 @@ public class LdapNetworkConnection exten
 
             case EXTENDED_RESPONSE:
                 // Transform the response
-                ExtendedResponseCodec extResCodec = (ExtendedResponseCodec)response;
-                extResCodec.setMessageId( messageId );
-                extResCodec.addControls( response.getControls() );
+                ExtendedResponse extendedResponse = ( ExtendedResponse ) response;
 
-                ExtendedResponse extendedResponse = convert( extResCodec );
-
-                ExtendedFuture extendedFuture = (ExtendedFuture)responseFuture;
+                ExtendedFuture extendedFuture = ( ExtendedFuture ) responseFuture;
 
                 if ( extendedFuture == null )
                 {
                     LOG.error( "ExtendedFuture is null" );
-                    throw new LdapException( "extendedFuture is null"  );
+                    throw new LdapException( "extendedFuture is null" );
                 }
 
                 // remove the listener from the listener map
@@ -1751,46 +1534,60 @@ public class LdapNetworkConnection exten
                 break;
 
             case INTERMEDIATE_RESPONSE:
-                IntermediateResponseCodec intermediateResponseCodec = (IntermediateResponseCodec)response;
-                intermediateResponseCodec.setMessageId( messageId );
-                intermediateResponseCodec.addControls( response.getControls() );
+                IntermediateResponse intermediateResponse = null;
 
-                setIResponse( intermediateResponseCodec, responseFuture );
+                if ( responseFuture instanceof SearchFuture )
+                {
+                    intermediateResponse = new IntermediateResponseImpl( messageId );
+                    addControls( intermediateResponse, ( IntermediateResponse ) response );
+                    ( ( SearchFuture ) responseFuture ).set( intermediateResponse );
+                }
+                else if ( responseFuture instanceof ExtendedFuture )
+                {
+                    intermediateResponse = new IntermediateResponseImpl( messageId );
+                    addControls( intermediateResponse, ( IntermediateResponse ) response );
+                    ( ( ExtendedFuture ) responseFuture ).set( intermediateResponse );
+                }
+                else
+                {
+                    // currently we only support IR for search and extended operations
+                    throw new UnsupportedOperationException( "Unknown ResponseFuture type "
+                        + responseFuture.getClass().getName() );
+                }
+
+                intermediateResponse.setResponseName( ( ( IntermediateResponse ) response ).getResponseName() );
+                intermediateResponse.setResponseValue( ( ( IntermediateResponse ) response ).getResponseValue() );
 
                 break;
 
             case MODIFY_RESPONSE:
                 // Transform the response
-                ModifyResponseCodec modRespCodec = (ModifyResponseCodec)response;
-                modRespCodec.setMessageId( messageId );
-                modRespCodec.addControls( response.getControls() );
-
-                ModifyResponse modifyResp = convert( modRespCodec );
+                ModifyResponse modifyResponse = ( ModifyResponse ) response;
 
-                ModifyFuture modifyFuture = (ModifyFuture)responseFuture;
+                ModifyFuture modifyFuture = ( ModifyFuture ) responseFuture;
 
                 if ( modifyFuture == null )
                 {
                     LOG.error( "ModifyFuture is null" );
-                    throw new LdapException( "ModifyFuture is null"  );
+                    throw new LdapException( "ModifyFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
                 {
-                    if ( modifyResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+                    if ( modifyResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                     {
                         // Everything is fine, return the response
-                        LOG.debug( "ModifyFuture successful : {}", modifyResp );
+                        LOG.debug( "ModifyFuture successful : {}", modifyResponse );
                     }
                     else
                     {
                         // We have had an error
-                        LOG.debug( "ModifyFuture failed : {}", modifyResp );
+                        LOG.debug( "ModifyFuture failed : {}", modifyResponse );
                     }
                 }
 
                 // Store the response into the future
-                modifyFuture.set( modifyResp );
+                modifyFuture.set( modifyResponse );
 
                 // Remove the future from the map
                 removeFromFutureMaps( messageId );
@@ -1799,36 +1596,32 @@ public class LdapNetworkConnection exten
 
             case MODIFYDN_RESPONSE:
                 // Transform the response
-                ModifyDNResponseCodec modDnRespCodec = (ModifyDNResponseCodec)response;
-                modDnRespCodec.setMessageId( messageId );
-                modDnRespCodec.addControls( response.getControls() );
+                ModifyDnResponse modifyDnResponse = ( ModifyDnResponse ) response;
 
-                ModifyDnResponse modifyDnResp = convert( modDnRespCodec );
-
-                ModifyDnFuture modifyDnFuture = (ModifyDnFuture)responseFuture;
+                ModifyDnFuture modifyDnFuture = ( ModifyDnFuture ) responseFuture;
 
                 if ( modifyDnFuture == null )
                 {
                     LOG.error( "ModifyDNFuture is null" );
-                    throw new LdapException( "ModifyDNFuture is null"  );
+                    throw new LdapException( "ModifyDNFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
                 {
-                    if ( modifyDnResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+                    if ( modifyDnResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                     {
                         // Everything is fine, return the response
-                        LOG.debug( "ModifyDN successful : {}", modifyDnResp );
+                        LOG.debug( "ModifyDN successful : {}", modifyDnResponse );
                     }
                     else
                     {
                         // We have had an error
-                        LOG.debug( "ModifyDN failed : {}", modifyDnResp );
+                        LOG.debug( "ModifyDN failed : {}", modifyDnResponse );
                     }
                 }
 
                 // Store the response into the future
-                modifyDnFuture.set( modifyDnResp );
+                modifyDnFuture.set( modifyDnResponse );
 
                 // Remove the future from the map
                 removeFromFutureMaps( messageId );
@@ -1837,17 +1630,14 @@ public class LdapNetworkConnection exten
 
             case SEARCH_RESULT_DONE:
                 // Store the response into the responseQueue
-                SearchResultDoneCodec searchResultDoneCodec = (SearchResultDoneCodec)response;
-                searchResultDoneCodec.setMessageId( messageId );
-                searchResultDoneCodec.addControls( response.getControls() );
-                SearchResultDone searchResultDone = convert( searchResultDoneCodec );
+                SearchResultDone searchResultDone = ( SearchResultDone ) response;
 
-                SearchFuture searchFuture = (SearchFuture)responseFuture;
+                SearchFuture searchFuture = ( SearchFuture ) responseFuture;
 
                 if ( searchFuture == null )
                 {
                     LOG.error( "SearchFuture is null" );
-                    throw new LdapException( "SearchFuture is null"  );
+                    throw new LdapException( "SearchFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
@@ -1874,44 +1664,41 @@ public class LdapNetworkConnection exten
 
             case SEARCH_RESULT_ENTRY:
                 // Store the response into the responseQueue
-                SearchResultEntryCodec searchResultEntryCodec = (SearchResultEntryCodec)response;
-                searchResultEntryCodec.setMessageId( messageId );
-                searchResultEntryCodec.addControls( response.getControls() );
+                SearchResultEntry searchResultEntry = ( SearchResultEntry ) response;
 
-                SearchResultEntry srchEntry = convert( searchResultEntryCodec );
+                if ( schemaManager != null )
+                {
+                    searchResultEntry.setEntry( new DefaultEntry( schemaManager, searchResultEntry.getEntry() ) );
+                }
 
-                searchFuture = (SearchFuture)responseFuture;
+                searchFuture = ( SearchFuture ) responseFuture;
 
                 if ( searchFuture == null )
                 {
                     LOG.error( "SearchFuture is null" );
-                    throw new LdapException( "SearchFuture is null"  );
+                    throw new LdapException( "SearchFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
                 {
-                    LOG.debug( "Search entry found : {}", srchEntry );
+                    LOG.debug( "Search entry found : {}", searchResultEntry );
                 }
 
                 // Store the response into the future
-                searchFuture.set( srchEntry );
+                searchFuture.set( searchResultEntry );
 
                 break;
 
             case SEARCH_RESULT_REFERENCE:
                 // Store the response into the responseQueue
-                SearchResultReferenceCodec searchResultReferenceCodec = (SearchResultReferenceCodec)response;
-                searchResultReferenceCodec.setMessageId( messageId );
-                searchResultReferenceCodec.addControls( response.getControls() );
-
-                SearchResultReference searchResultReference = convert( searchResultReferenceCodec );
+                SearchResultReference searchResultReference = ( SearchResultReference ) response;
 
-                searchFuture = (SearchFuture)responseFuture;
+                searchFuture = ( SearchFuture ) responseFuture;
 
                 if ( searchFuture == null )
                 {
                     LOG.error( "SearchFuture is null" );
-                    throw new LdapException( "SearchFuture is null"  );
+                    throw new LdapException( "SearchFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
@@ -1924,9 +1711,6 @@ public class LdapNetworkConnection exten
 
                 break;
 
-            default:
-                LOG.error( "~~~~~~~~~~~~~~~~~~~~~ Unknown message type {} ~~~~~~~~~~~~~~~~~~~~~", response
-                    .getMessageTypeName() );
         }
     }
 
@@ -1942,7 +1726,8 @@ public class LdapNetworkConnection exten
             throw new IllegalArgumentException( "Entry to be modified cannot be null" );
         }
 
-        ModifyRequest modReq = new ModifyRequest( entry.getDn() );
+        ModifyRequest modReq = new ModifyRequestImpl();
+        modReq.setName( entry.getDn() );
 
         Iterator<EntryAttribute> itr = entry.iterator();
         while ( itr.hasNext() )
@@ -1965,8 +1750,13 @@ public class LdapNetworkConnection exten
             throw new IllegalArgumentException( "The DN to be modified cannot be null" );
         }
 
-        ModifyRequest modReq = new ModifyRequest( dn );
-        modReq.addModification( modifications );
+        ModifyRequest modReq = new ModifyRequestImpl();
+        modReq.setName( dn );
+
+        for ( Modification modification : modifications )
+        {
+            modReq.addModification( modification );
+        }
 
         return modify( modReq );
     }
@@ -1977,7 +1767,7 @@ public class LdapNetworkConnection exten
      */
     public ModifyResponse modify( String dn, Modification... modifications ) throws LdapException
     {
-        return modify ( new DN( dn ), modifications );
+        return modify( new DN( dn ), modifications );
     }
 
 
@@ -1992,8 +1782,6 @@ public class LdapNetworkConnection exten
         try
         {
             // Read the response, waiting for it if not available immediately
-            long timeout = getTimeout( modRequest.getTimeout() );
-
             // Get the response, blocking
             ModifyResponse modifyResponse = modifyFuture.get( timeout, TimeUnit.MILLISECONDS );
 
@@ -2054,22 +1842,14 @@ public class LdapNetworkConnection exten
     {
         checkSession();
 
-        ModifyRequestCodec modReqCodec = new ModifyRequestCodec();
-
         int newId = messageId.incrementAndGet();
         modRequest.setMessageId( newId );
-        modReqCodec.setMessageId( newId );
-
-        modReqCodec.setModifications( modRequest.getMods() );
-        modReqCodec.setObject( modRequest.getDn() );
-
-        setControls( modRequest.getControls(), modReqCodec );
 
         ModifyFuture modifyFuture = new ModifyFuture( this, newId );
         addToFutureMap( newId, modifyFuture );
 
         // Send the request to the server
-        WriteFuture writeFuture = ldapSession.write( modReqCodec );
+        WriteFuture writeFuture = ldapSession.write( modRequest );
 
         // Wait for the message to be sent to the server
         if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
@@ -2086,21 +1866,6 @@ public class LdapNetworkConnection exten
 
 
     /**
-     * converts the ModifyResponseCodec to ModifyResponse.
-     */
-    private ModifyResponse convert( ModifyResponseCodec modRespCodec )
-    {
-        ModifyResponse modResponse = new ModifyResponse();
-
-        modResponse.setMessageId( modRespCodec.getMessageId() );
-        modResponse.setLdapResult( convert( modRespCodec.getLdapResult() ) );
-        addControls( modRespCodec, modResponse );
-
-        return modResponse;
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public ModifyDnResponse rename( String entryDn, String newRdn ) throws LdapException
@@ -2140,8 +1905,8 @@ public class LdapNetworkConnection exten
      */
     public ModifyDnResponse rename( DN entryDn, RDN newRdn, boolean deleteOldRdn ) throws LdapException
     {
-        ModifyDnRequest modDnRequest = new ModifyDnRequest();
-        modDnRequest.setEntryDn( entryDn );
+        ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
+        modDnRequest.setName( entryDn );
         modDnRequest.setNewRdn( newRdn );
         modDnRequest.setDeleteOldRdn( deleteOldRdn );
 
@@ -2171,8 +1936,8 @@ public class LdapNetworkConnection exten
      */
     public ModifyDnResponse move( DN entryDn, DN newSuperiorDn ) throws LdapException
     {
-        ModifyDnRequest modDnRequest = new ModifyDnRequest();
-        modDnRequest.setEntryDn( entryDn );
+        ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
+        modDnRequest.setName( entryDn );
         modDnRequest.setNewSuperior( newSuperiorDn );
 
         //TODO not setting the below value is resulting in error
@@ -2235,8 +2000,8 @@ public class LdapNetworkConnection exten
         }
 
         // Create the request
-        ModifyDnRequest modDnRequest = new ModifyDnRequest();
-        modDnRequest.setEntryDn( entryDn );
+        ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
+        modDnRequest.setName( entryDn );
         modDnRequest.setNewRdn( newDn.getRdn() );
         modDnRequest.setNewSuperior( newDn.getParent() );
         modDnRequest.setDeleteOldRdn( deleteOldRdn );
@@ -2269,8 +2034,6 @@ public class LdapNetworkConnection exten
         try
         {
             // Read the response, waiting for it if not available immediately
-            long timeout = getTimeout( modDnRequest.getTimeout() );
-
             // Get the response, blocking
             ModifyDnResponse modifyDnResponse = modifyDnFuture.get( timeout, TimeUnit.MILLISECONDS );
 
@@ -2331,24 +2094,14 @@ public class LdapNetworkConnection exten
     {
         checkSession();
 
-        ModifyDNRequestCodec modDnCodec = new ModifyDNRequestCodec();
-
         int newId = messageId.incrementAndGet();
         modDnRequest.setMessageId( newId );
-        modDnCodec.setMessageId( newId );
-
-        modDnCodec.setEntry( modDnRequest.getEntryDn() );
-        modDnCodec.setNewRDN( modDnRequest.getNewRdn() );
-        modDnCodec.setDeleteOldRDN( modDnRequest.isDeleteOldRdn() );
-        modDnCodec.setNewSuperior( modDnRequest.getNewSuperior() );
-
-        setControls( modDnRequest.getControls(), modDnCodec );
 
         ModifyDnFuture modifyDnFuture = new ModifyDnFuture( this, newId );
         addToFutureMap( newId, modifyDnFuture );
 
         // Send the request to the server
-        WriteFuture writeFuture = ldapSession.write( modDnCodec );
+        WriteFuture writeFuture = ldapSession.write( modDnRequest );
 
         // Wait for the message to be sent to the server
         if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
@@ -2365,21 +2118,6 @@ public class LdapNetworkConnection exten
 
 
     /**
-     * converts the ModifyDnResponseCodec to ModifyResponse.
-     */
-    private ModifyDnResponse convert( ModifyDNResponseCodec modDnRespCodec )
-    {
-        ModifyDnResponse modDnResponse = new ModifyDnResponse();
-
-        modDnResponse.setMessageId( modDnRespCodec.getMessageId() );
-        modDnResponse.setLdapResult( convert( modDnRespCodec.getLdapResult() ) );
-        addControls( modDnRespCodec, modDnResponse );
-
-        return modDnResponse;
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public DeleteResponse delete( String dn ) throws LdapException
@@ -2393,7 +2131,8 @@ public class LdapNetworkConnection exten
      */
     public DeleteResponse delete( DN dn ) throws LdapException
     {
-        DeleteRequest deleteRequest = new DeleteRequest( dn );
+        DeleteRequest deleteRequest = new DeleteRequestImpl();
+        deleteRequest.setName( dn );
 
         return delete( deleteRequest );
     }
@@ -2412,14 +2151,15 @@ public class LdapNetworkConnection exten
 
         if ( isControlSupported( treeDeleteOid ) )
         {
-            DeleteRequest delRequest = new DeleteRequest( dn );
-            delRequest.add( new ControlImpl( treeDeleteOid ) );
-            return delete( delRequest );
+            DeleteRequest deleteRequest = new DeleteRequestImpl();
+            deleteRequest.setName( dn );
+            deleteRequest.addControl( new ControlImpl( treeDeleteOid ) );
+            return delete( deleteRequest );
         }
         else
         {
-            String msg = "The subtreeDelete control (1.2.840.113556.1.4.805) is not supported by the server\n" +
-                " The deletion has been aborted";
+            String msg = "The subtreeDelete control (1.2.840.113556.1.4.805) is not supported by the server\n"
+                + " The deletion has been aborted";
             LOG.error( msg );
             throw new LdapException( msg );
         }
@@ -2442,14 +2182,15 @@ public class LdapNetworkConnection exten
 
             if ( isControlSupported( treeDeleteOid ) )
             {
-                DeleteRequest delRequest = new DeleteRequest( newDn );
-                delRequest.add( new ControlImpl( treeDeleteOid ) );
-                return delete( delRequest );
+                DeleteRequest deleteRequest = new DeleteRequestImpl();
+                deleteRequest.setName( newDn );
+                deleteRequest.addControl( new ControlImpl( treeDeleteOid ) );
+                return delete( deleteRequest );
             }
             else
             {
-                String msg = "The subtreeDelete control (1.2.840.113556.1.4.805) is not supported by the server\n" +
-                    " The deletion has been aborted";
+                String msg = "The subtreeDelete control (1.2.840.113556.1.4.805) is not supported by the server\n"
+                    + " The deletion has been aborted";
                 LOG.error( msg );
                 throw new LdapException( msg );
             }
@@ -2493,18 +2234,18 @@ public class LdapNetworkConnection exten
      * @param listener  the delete operation response listener
      * @throws LdapException If the DN is not valid or if the deletion failed
      */
-    private DeleteResponse deleteRecursive( DN dn, Map<DN, Cursor<SearchResponse>> cursorMap,
-        DeleteListener listener ) throws LdapException
+    private DeleteResponse deleteRecursive( DN dn, Map<DN, Cursor<Response>> cursorMap, DeleteListener listener )
+        throws LdapException
     {
         LOG.debug( "searching for {}", dn.getName() );
         DeleteResponse delResponse = null;
-        Cursor<SearchResponse> cursor = null;
+        Cursor<Response> cursor = null;
 
         try
         {
             if ( cursorMap == null )
             {
-                cursorMap = new HashMap<DN, Cursor<SearchResponse>>();
+                cursorMap = new HashMap<DN, Cursor<Response>>();
             }
 
             cursor = cursorMap.get( dn );
@@ -2521,13 +2262,15 @@ public class LdapNetworkConnection exten
                 LOG.debug( "deleting {}", dn.getName() );
                 cursorMap.remove( dn );
                 cursor.close();
-                delResponse = delete( new DeleteRequest( dn ) );
+                DeleteRequest deleteRequest = new DeleteRequestImpl();
+                deleteRequest.setName( dn );
+                delResponse = delete( deleteRequest );
             }
             else
             {
                 do
                 {
-                    SearchResponse searchResp = cursor.get();
+                    Response searchResp = cursor.get();
 
                     if ( searchResp instanceof SearchResultEntry )
                     {
@@ -2540,7 +2283,9 @@ public class LdapNetworkConnection exten
                 cursorMap.remove( dn );
                 cursor.close();
                 LOG.debug( "deleting {}", dn.getName() );
-                delResponse = delete( new DeleteRequest( dn ) );
+                DeleteRequest deleteRequest = new DeleteRequestImpl();
+                deleteRequest.setName( dn );
+                delResponse = delete( deleteRequest );
             }
         }
         catch ( Exception e )
@@ -2565,8 +2310,6 @@ public class LdapNetworkConnection exten
         try
         {
             // Read the response, waiting for it if not available immediately
-            long timeout = getTimeout( deleteRequest.getTimeout() );
-
             // Get the response, blocking
             DeleteResponse delResponse = deleteFuture.get( timeout, TimeUnit.MILLISECONDS );
 
@@ -2627,21 +2370,15 @@ public class LdapNetworkConnection exten
     {
         checkSession();
 
-        DelRequestCodec delReqCodec = new DelRequestCodec();
-
         int newId = messageId.incrementAndGet();
 
         delRequest.setMessageId( newId );
-        delReqCodec.setMessageId( newId );
-
-        delReqCodec.setEntry( delRequest.getTargetDn() );
-        setControls( delRequest.getControls(), delReqCodec );
 
         DeleteFuture deleteFuture = new DeleteFuture( this, newId );
         addToFutureMap( newId, deleteFuture );
 
         // Send the request to the server
-        WriteFuture writeFuture = ldapSession.write( delReqCodec );
+        WriteFuture writeFuture = ldapSession.write( delRequest );
 
         // Wait for the message to be sent to the server
         if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
@@ -2689,10 +2426,10 @@ public class LdapNetworkConnection exten
      */
     public CompareResponse compare( DN dn, String attributeName, String value ) throws LdapException
     {
-        CompareRequest compareRequest = new CompareRequest();
-        compareRequest.setEntryDn( dn );
-        compareRequest.setAttrName( attributeName );
-        compareRequest.setValue( value );
+        CompareRequest compareRequest = new CompareRequestImpl();
+        compareRequest.setName( dn );
+        compareRequest.setAttributeId( attributeName );
+        compareRequest.setAssertionValue( value );
 
         return compare( compareRequest );
     }
@@ -2703,10 +2440,10 @@ public class LdapNetworkConnection exten
      */
     public CompareResponse compare( DN dn, String attributeName, byte[] value ) throws LdapException
     {
-        CompareRequest compareRequest = new CompareRequest();
-        compareRequest.setEntryDn( dn );
-        compareRequest.setAttrName( attributeName );
-        compareRequest.setValue( value );
+        CompareRequest compareRequest = new CompareRequestImpl();
+        compareRequest.setName( dn );
+        compareRequest.setAttributeId( attributeName );
+        compareRequest.setAssertionValue( value );
 
         return compare( compareRequest );
     }
@@ -2717,10 +2454,18 @@ public class LdapNetworkConnection exten
      */
     public CompareResponse compare( DN dn, String attributeName, Value<?> value ) throws LdapException
     {
-        CompareRequest compareRequest = new CompareRequest();
-        compareRequest.setEntryDn( dn );
-        compareRequest.setAttrName( attributeName );
-        compareRequest.setValue( value.get() );
+        CompareRequest compareRequest = new CompareRequestImpl();
+        compareRequest.setName( dn );
+        compareRequest.setAttributeId( attributeName );
+
+        if ( value.isBinary() )
+        {
+            compareRequest.setAssertionValue( value.getBytes() );
+        }
+        else
+        {
+            compareRequest.setAssertionValue( value.getString() );
+        }
 
         return compare( compareRequest );
     }
@@ -2737,8 +2482,6 @@ public class LdapNetworkConnection exten
         try
         {
             // Read the response, waiting for it if not available immediately
-            long timeout = getTimeout( compareRequest.getTimeout() );
-
             // Get the response, blocking
             CompareResponse compareResponse = compareFuture.get( timeout, TimeUnit.MILLISECONDS );
 
@@ -2799,23 +2542,15 @@ public class LdapNetworkConnection exten
     {
         checkSession();
 
-        CompareRequestCodec compareReqCodec = new CompareRequestCodec();
-
         int newId = messageId.incrementAndGet();
 
         compareRequest.setMessageId( newId );
-        compareReqCodec.setMessageId( newId );
-
-        compareReqCodec.setEntry( compareRequest.getEntryDn() );
-        compareReqCodec.setAttributeDesc( compareRequest.getAttrName() );
-        compareReqCodec.setAssertionValue( compareRequest.getValue() );
-        setControls( compareRequest.getControls(), compareReqCodec );
 
         CompareFuture compareFuture = new CompareFuture( this, newId );
         addToFutureMap( newId, compareFuture );
 
         // Send the request to the server
-        WriteFuture writeFuture = ldapSession.write( compareReqCodec );
+        WriteFuture writeFuture = ldapSession.write( compareRequest );
 
         // Wait for the message to be sent to the server
         if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
@@ -2832,36 +2567,6 @@ public class LdapNetworkConnection exten
 
 
     /**
-     * converts the CompareResponseCodec to CompareResponse.
-     */
-    private CompareResponse convert( CompareResponseCodec compareRespCodec )
-    {
-        CompareResponse compareResponse = new CompareResponse();
-
-        compareResponse.setMessageId( compareRespCodec.getMessageId() );
-        compareResponse.setLdapResult( convert( compareRespCodec.getLdapResult() ) );
-        addControls( compareRespCodec, compareResponse );
-
-        return compareResponse;
-    }
-
-
-    /**
-     * converts the DeleteResponseCodec to DeleteResponse object.
-     */
-    private DeleteResponse convert( DelResponseCodec delRespCodec )
-    {
-        DeleteResponse response = new DeleteResponse();
-
-        response.setMessageId( delRespCodec.getMessageId() );
-        response.setLdapResult( convert( delRespCodec.getLdapResult() ) );
-        addControls( delRespCodec, response );
-
-        return response;
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public ExtendedResponse extended( String oid ) throws LdapException
@@ -2902,10 +2607,11 @@ public class LdapNetworkConnection exten
      */
     public ExtendedResponse extended( OID oid, byte[] value ) throws LdapException
     {
-        ExtendedRequest extRequest = new ExtendedRequest( oid );
-        extRequest.setValue( value );
+        ExtendedRequest extendedRequest = new ExtendedRequestImpl();
+        extendedRequest.setRequestName( oid.toString() );
+        extendedRequest.setRequestValue( value );
 
-        return extended( extRequest );
+        return extended( extendedRequest );
     }
 
 
@@ -2920,10 +2626,9 @@ public class LdapNetworkConnection exten
         try
         {
             // Read the response, waiting for it if not available immediately
-            long timeout = getTimeout( extendedRequest.getTimeout() );
-
             // Get the response, blocking
-            ExtendedResponse extendedResponse = extendedFuture.get( timeout, TimeUnit.MILLISECONDS );
+            ExtendedResponse extendedResponse = ( ExtendedResponse ) extendedFuture
+                .get( timeout, TimeUnit.MILLISECONDS );
 
             if ( extendedResponse == null )
             {
@@ -2982,22 +2687,14 @@ public class LdapNetworkConnection exten
     {
         checkSession();
 
-        ExtendedRequestCodec extReqCodec = new ExtendedRequestCodec();
-
         int newId = messageId.incrementAndGet();
 
-        extReqCodec.setMessageId( newId );
-        extReqCodec.setMessageId( newId );
-
-        extReqCodec.setRequestName( extendedRequest.getOid() );
-        extReqCodec.setRequestValue( extendedRequest.getValue() );
-        setControls( extendedRequest.getControls(), extReqCodec );
-
+        extendedRequest.setMessageId( newId );
         ExtendedFuture extendedFuture = new ExtendedFuture( this, newId );
         addToFutureMap( newId, extendedFuture );
 
         // Send the request to the server
-        WriteFuture writeFuture = ldapSession.write( extReqCodec );
+        WriteFuture writeFuture = ldapSession.write( extendedRequest );
 
         // Wait for the message to be sent to the server
         if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
@@ -3016,7 +2713,7 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
-    public SearchResponse lookup( DN dn ) throws LdapException
+    public Response lookup( DN dn ) throws LdapException
     {
         return lookup( dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
     }
@@ -3025,7 +2722,7 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
-    public SearchResponse lookup( String dn ) throws LdapException
+    public Response lookup( String dn ) throws LdapException
     {
         return lookup( dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
     }
@@ -3034,13 +2731,13 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
-    public SearchResponse lookup( DN dn, String... attributes ) throws LdapException
+    public Response lookup( DN dn, String... attributes ) throws LdapException
     {
-        SearchResponse resp = null;
+        Response resp = null;
 
         try
         {
-            Cursor<SearchResponse> cursor = search( dn, "(objectClass=*)", SearchScope.OBJECT, attributes );
+            Cursor<Response> cursor = search( dn, "(objectClass=*)", SearchScope.OBJECT, attributes );
 
             // Read the response
             if ( cursor.next() )
@@ -3055,7 +2752,7 @@ public class LdapNetworkConnection exten
             // And close the cursor
             cursor.close();
         }
-        catch( Exception e )
+        catch ( Exception e )
         {
             throw new LdapException( e );
         }
@@ -3067,45 +2764,13 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
-    public SearchResponse lookup( String dn, String... attributes ) throws LdapException
+    public Response lookup( String dn, String... attributes ) throws LdapException
     {
         return lookup( new DN( dn ), attributes );
     }
 
 
     /**
-     * converts the ExtendedResponseCodec to ExtendedResponse.
-     */
-    private ExtendedResponse convert( ExtendedResponseCodec extRespCodec )
-    {
-        ExtendedResponse extResponse = new ExtendedResponse();
-
-        OID oid = null;
-        try
-        {
-            if ( extRespCodec.getResponseName() != null )
-            {
-                oid = new OID( extRespCodec.getResponseName() );
-            }
-        }
-        catch ( DecoderException e )
-        {
-            // can happen in case of a PROTOCOL_ERROR result, ignore
-            //LOG.error( "invalid response name {}", extRespCodec.getResponseName() );
-        }
-
-        extResponse.setOid( oid );
-        extResponse.setValue( extRespCodec.getResponse() );
-        extResponse.setMessageId( extRespCodec.getMessageId() );
-        extResponse.setLdapResult( convert( extRespCodec.getLdapResult() ) );
-
-        addControls( extRespCodec, extResponse );
-
-        return extResponse;
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public boolean isControlSupported( String controlOID ) throws LdapException
@@ -3133,7 +2798,7 @@ public class LdapNetworkConnection exten
 
         EntryAttribute attr = rootDSE.get( SchemaConstants.SUPPORTED_CONTROL_AT );
 
-        for (Value<?> value:attr)
+        for ( Value<?> value : attr )
         {
             supportedControls.add( value.getString() );
         }
@@ -3155,25 +2820,25 @@ public class LdapNetworkConnection exten
 
             // we enale all the schemas so that need not check with server for enabled schemas
             Collection<Schema> schemas = schemaManager.getLoader().getAllSchemas();
-            for( Schema s : schemas )
+            for ( Schema s : schemas )
             {
                 s.enable();
             }
 
             schemaManager.loadAllEnabled();
 
-            if( ! schemaManager.getErrors().isEmpty() )
+            if ( !schemaManager.getErrors().isEmpty() )
             {
                 String msg = "there are errors while loading the schema";
                 LOG.error( msg + " {}", schemaManager.getErrors() );
                 throw new LdapException( msg );
             }
         }
-        catch( LdapException le )
+        catch ( LdapException le )
         {
             throw le;
         }
-        catch( Exception e )
+        catch ( Exception e )
         {
             LOG.error( "failed to load the schema", e );
             throw new LdapException( e );
@@ -3192,7 +2857,7 @@ public class LdapNetworkConnection exten
     {
         try
         {
-            if( schemaManager == null )
+            if ( schemaManager == null )
             {
                 loadSchema();
             }
@@ -3203,21 +2868,21 @@ public class LdapNetworkConnection exten
 
             List<AttributeType> atList = olsp.getAttributeTypes();
             AttributeTypeRegistry atRegistry = schemaManager.getRegistries().getAttributeTypeRegistry();
-            for( AttributeType atType : atList )
+            for ( AttributeType atType : atList )
             {
                 atRegistry.addMappingFor( atType );
             }
 
             List<ObjectClass> ocList = olsp.getObjectClassTypes();
             ObjectClassRegistry ocRegistry = schemaManager.getRegistries().getObjectClassRegistry();
-            for( ObjectClass oc : ocList )
+            for ( ObjectClass oc : ocList )
             {
                 ocRegistry.register( oc );
             }
 
             LOG.info( "successfully loaded the schema from file {}", schemaFile.getAbsolutePath() );
         }
-        catch( Exception e )
+        catch ( Exception e )
         {
             LOG.error( "failed to load the schema from file {}", schemaFile.getAbsolutePath() );
             throw new LdapException( e );
@@ -3249,7 +2914,7 @@ public class LdapNetworkConnection exten
      */
     private void fetchRootDSE() throws LdapException
     {
-        Cursor<SearchResponse> cursor = null;
+        Cursor<Response> cursor = null;
         try
         {
             cursor = search( "", "(objectClass=*)", SearchScope.OBJECT, "*", "+" );
@@ -3292,12 +2957,13 @@ public class LdapNetworkConnection exten
     }
 
 
-    private void addControls( LdapMessageCodec codec, AbstractMessage message )
+    private void addControls( Message codec, Message message )
     {
-        List<Control> ccList = codec.getControls();
-        if ( ccList != null )
+        Map<String, Control> controls = codec.getControls();
+
+        if ( controls != null )
         {
-            for ( Control cc : ccList )
+            for ( Control cc : controls.values() )
             {
                 // FIXME why the cc is coming as null!?
                 if ( cc == null )
@@ -3309,7 +2975,7 @@ public class LdapNetworkConnection exten
                 control.setValue( cc.getValue() );
                 control.setCritical( cc.isCritical() );
 
-                message.add( control );
+                message.addControl( control );
             }
         }
     }
@@ -3341,13 +3007,14 @@ public class LdapNetworkConnection exten
      */
     public boolean doesFutureExistFor( Integer messageId )
     {
-        return futureMap.get( messageId ) != null;
+        ResponseFuture<?> responseFuture = futureMap.get( messageId );
+        return responseFuture != null;
     }
 
 
     public void addConnectionClosedEventListener( ConnectionClosedEventListener ccListenr )
     {
-        if( conCloseListeners == null )
+        if ( conCloseListeners == null )
         {
             conCloseListeners = new ArrayList<ConnectionClosedEventListener>();
         }
@@ -3360,7 +3027,7 @@ public class LdapNetworkConnection exten
     public void sessionClosed( IoSession session ) throws Exception
     {
         // no need to handle if this session was closed by the user
-        if( !connected.get() )
+        if ( !connected.get() )
         {
             return;
         }
@@ -3378,10 +3045,10 @@ public class LdapNetworkConnection exten
 
         clearMaps();
 
-        if( conCloseListeners != null )
+        if ( conCloseListeners != null )
         {
             LOG.debug( "notifying the registered ConnectionClosedEventListeners.." );
-            for( ConnectionClosedEventListener listener : conCloseListeners )
+            for ( ConnectionClosedEventListener listener : conCloseListeners )
             {
                 listener.connectionClosed();
             }

Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/SearchCursor.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/SearchCursor.java?rev=987607&r1=987606&r2=987607&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/SearchCursor.java (original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/SearchCursor.java Fri Aug 20 19:25:18 2010
@@ -24,11 +24,11 @@ package org.apache.directory.ldap.client
 import java.util.concurrent.TimeUnit;
 
 import org.apache.directory.ldap.client.api.future.SearchFuture;
-import org.apache.directory.ldap.client.api.message.SearchResponse;
-import org.apache.directory.ldap.client.api.message.SearchResultDone;
 import org.apache.directory.shared.ldap.cursor.AbstractCursor;
 import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException;
 import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.message.Response;
+import org.apache.directory.shared.ldap.message.SearchResultDone;
 
 
 /**
@@ -51,13 +51,14 @@ public class SearchCursor extends Abstra
     private TimeUnit timeUnit;
 
     /** a reference to hold the retrieved SearchResponse object from SearchFuture */
-    private SearchResponse response;
+    private Response response;
 
     private boolean done;
 
     /** a reference to hold the SearchResultDone response */
     private SearchResultDone searchDoneResp;
-    
+
+
     public SearchCursor( SearchFuture future, long timeout, TimeUnit timeUnit )
     {
         this.future = future;
@@ -72,7 +73,7 @@ public class SearchCursor extends Abstra
         {
             return false;
         }
-        
+
         try
         {
             if ( future.isCancelled() )
@@ -81,7 +82,7 @@ public class SearchCursor extends Abstra
                 done = true;
                 return false;
             }
-            
+
             response = future.get( timeout, timeUnit );
         }
         catch ( Exception e )
@@ -97,7 +98,7 @@ public class SearchCursor extends Abstra
 
             // close the cursor
             close( ldapException );
-            
+
             throw ldapException;
         }
 
@@ -120,7 +121,7 @@ public class SearchCursor extends Abstra
     }
 
 
-    public SearchResponse get() throws Exception
+    public Response get() throws Exception
     {
         if ( !available() )
         {
@@ -140,8 +141,8 @@ public class SearchCursor extends Abstra
     {
         return searchDoneResp;
     }
-    
-    
+
+
     public boolean isElementReused()
     {
         return true;
@@ -169,7 +170,7 @@ public class SearchCursor extends Abstra
             super.close();
             return;
         }
-        
+
         if ( !future.isCancelled() )
         {
             future.cancel( true );

Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/AddFuture.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/AddFuture.java?rev=987607&r1=987606&r2=987607&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/AddFuture.java (original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/AddFuture.java Fri Aug 20 19:25:18 2010
@@ -19,12 +19,14 @@
  */
 package org.apache.directory.ldap.client.api.future;
 
+
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.ldap.client.api.message.AddResponse;
+import org.apache.directory.shared.ldap.message.AddResponse;
+
 
 /**
  * A Future to manage AddRequests
@@ -44,8 +46,8 @@ public class AddFuture extends ResponseF
     {
         super( connection, messageId );
     }
-    
-    
+
+
     /**
      * Get the AddResponse, blocking until one is received.
      * 
@@ -56,7 +58,7 @@ public class AddFuture extends ResponseF
         return super.get();
     }
 
-    
+
     /**
      * Get the AddResponse, blocking until one is received, or until the
      * given timeout is reached.
@@ -70,17 +72,17 @@ public class AddFuture extends ResponseF
     {
         return super.get( timeout, unit );
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     public String toString()
     {
         StringBuilder sb = new StringBuilder();
-        
+
         sb.append( "AddFuture" ).append( super.toString() );
-        
+
         return sb.toString();
     }
 }

Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/BindFuture.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/BindFuture.java?rev=987607&r1=987606&r2=987607&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/BindFuture.java (original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/BindFuture.java Fri Aug 20 19:25:18 2010
@@ -19,12 +19,14 @@
  */
 package org.apache.directory.ldap.client.api.future;
 
+
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.ldap.client.api.message.BindResponse;
+import org.apache.directory.shared.ldap.message.BindResponse;
+
 
 /**
  * A Future to manage BindRequests
@@ -44,8 +46,8 @@ public class BindFuture extends Response
     {
         super( connection, messageId );
     }
-    
-    
+
+
     /**
      * Get the BindResponse, blocking until one is received.
      * 
@@ -56,7 +58,7 @@ public class BindFuture extends Response
         return super.get();
     }
 
-    
+
     /**
      * Get the BindResponse, blocking until one is received, or until the
      * given timeout is reached.
@@ -70,17 +72,17 @@ public class BindFuture extends Response
     {
         return super.get( timeout, unit );
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     public String toString()
     {
         StringBuilder sb = new StringBuilder();
-        
+
         sb.append( "BindFuture" ).append( super.toString() );
-        
+
         return sb.toString();
     }
 }



Mime
View raw message