directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r910150 [5/11] - in /directory: apacheds/trunk/ apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/ apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/co...
Date Mon, 15 Feb 2010 01:37:47 GMT
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=910150&r1=910149&r2=910150&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java Mon Feb 15 01:37:34 2010
@@ -182,12 +182,6 @@
                         throw new DecoderException( "The LdapMessage should not be empty" );
                     }
 
-                    // First, create a empty LdapMessage Object
-                    LdapMessageCodec ldapMessage = new LdapMessageCodec();
-
-                    // Then stores it into the container
-                    ldapMessageContainer.setLdapMessage( ldapMessage );
-
                     return;
                 }
             } );
@@ -211,9 +205,7 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // The current TLV should be a integer
                     // We get it and store it in MessageId
@@ -234,7 +226,6 @@
                     {
                         int messageId = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
 
-                        ldapMessage.setMessageId( messageId );
                         ldapMessageContainer.setMessageId( messageId );
 
                         if ( IS_DEBUG )
@@ -295,7 +286,11 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
+                    
+                    // Create the  UnbindRequest LdapMessage instance and store it in the container
+                    UnBindRequestCodec unbindRequest = new UnBindRequestCodec();
+                    unbindRequest.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( unbindRequest );
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
                     int expectedLength = tlv.getLength();
@@ -310,13 +305,7 @@
                         throw new DecoderException( "The length of a UnBindRequest must be null" );
                     }
 
-                    UnBindRequestCodec unBindRequest = new UnBindRequestCodec();
-
-                    unBindRequest.setParent( ldapMessage );
-
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( unBindRequest );
-
+                    
                     // We can quit now
                     ldapMessageContainer.grammarEndAllowed( true );
 
@@ -348,12 +337,12 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
-                    // We can allocate the DelRequest Object
+                    // Create the DeleteRequest LdapMessage instance and store it in the container
                     DelRequestCodec delRequest = new DelRequestCodec();
+                    delRequest.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( delRequest );
 
                     // And store the DN into it
                     // Get the Value and store it in the DelRequest
@@ -383,7 +372,7 @@
                                 + StringTools.dumpBytes( dnBytes ) + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            DeleteResponseImpl response = new DeleteResponseImpl( ldapMessage.getMessageId() );
+                            DeleteResponseImpl response = new DeleteResponseImpl( delRequest.getMessageId() );
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                 LdapDN.EMPTY_LDAPDN, ine );
                         }
@@ -391,9 +380,6 @@
                         delRequest.setEntry( entry );
                     }
 
-                    // then we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( delRequest );
-
                     // We can have an END transition
                     ldapMessageContainer.grammarEndAllowed( true );
 
@@ -428,9 +414,12 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
+
+                    // Create the AbandonRequest LdapMessage instance and store it in the container
+                    AbandonRequestCodec abandonRequest = new AbandonRequestCodec();
+                    abandonRequest.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( abandonRequest );
 
                     // The current TLV should be a integer
                     // We get it and store it in MessageId
@@ -451,11 +440,7 @@
                     {
                         int abandonnedMessageId = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
 
-                        // Ok, the Message ID is correct. We have to store it
-                        // in the AbandonRequest Object
-                        AbandonRequestCodec abandonRequest = new AbandonRequestCodec();
                         abandonRequest.setAbandonedMessageId( abandonnedMessageId );
-                        ldapMessage.setProtocolOP( abandonRequest );
 
                         if ( IS_DEBUG )
                         {
@@ -465,6 +450,7 @@
                         }
 
                         ldapMessageContainer.grammarEndAllowed( true );
+
                         return;
                     }
                     catch ( IntegerDecoderException ide )
@@ -504,7 +490,11 @@
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
+
+                    // Create the BindRequest LdapMessage instance and store it in the container
+                    BindRequestCodec bindRequest = new BindRequestCodec();
+                    bindRequest.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( bindRequest );
 
                     // We will check that the request is not null
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -517,9 +507,6 @@
                         // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( msg );
                     }
-
-                    // Now, we can allocate the BindRequest Object
-                    ldapMessage.setProtocolOP( new BindRequestCodec() );
                 }
             } );
 
@@ -539,7 +526,7 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    BindRequestCodec bindRequestMessage = ldapMessageContainer.getLdapMessage().getBindRequest();
+                    BindRequestCodec bindRequestMessage = ldapMessageContainer.getBindRequest();
 
                     // The current TLV should be a integer between 1 and 127
                     // We get it and store it in Version
@@ -587,8 +574,7 @@
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    BindRequestCodec bindRequestMessage = ldapMessage.getBindRequest();
+                    BindRequestCodec bindRequestMessage = ldapMessageContainer.getBindRequest();
 
                     // Get the Value and store it in the BindRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -614,7 +600,7 @@
                                 + StringTools.dumpBytes( dnBytes ) + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            BindResponseImpl response = new BindResponseImpl( ldapMessage.getMessageId() );
+                            BindResponseImpl response = new BindResponseImpl( bindRequestMessage.getMessageId() );
 
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                 LdapDN.EMPTY_LDAPDN, ine );
@@ -650,7 +636,7 @@
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
-                    BindRequestCodec bindRequestMessage = ldapMessageContainer.getLdapMessage().getBindRequest();
+                    BindRequestCodec bindRequestMessage = ldapMessageContainer.getBindRequest();
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                     // Allocate the Authentication Object
@@ -713,8 +699,7 @@
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    BindRequestCodec bindRequestMessage = ldapMessage.getBindRequest();
+                    BindRequestCodec bindRequestMessage = ldapMessageContainer.getBindRequest();
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                     // We will check that the sasl is not null
@@ -723,7 +708,7 @@
                         String msg = "The SaslCredential must not be null";
                         log.error( msg );
 
-                        BindResponseImpl response = new BindResponseImpl( ldapMessage.getMessageId() );
+                        BindResponseImpl response = new BindResponseImpl( bindRequestMessage.getMessageId() );
 
                         throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_CREDENTIALS,
                             bindRequestMessage.getName(), null );
@@ -760,8 +745,7 @@
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    BindRequestCodec bindRequestMessage = ldapMessage.getBindRequest();
+                    BindRequestCodec bindRequestMessage = ldapMessageContainer.getBindRequest();
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                     // Get the SaslCredentials Object
@@ -806,7 +790,7 @@
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
-                    BindRequestCodec bindRequestMessage = ldapMessageContainer.getLdapMessage().getBindRequest();
+                    BindRequestCodec bindRequestMessage = ldapMessageContainer.getBindRequest();
 
                     // Get the Value and store it in the BindRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -869,19 +853,12 @@
             {
                 public void action( IAsn1Container container )
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
-                    // Now, we can allocate the BindRequest Object
+                    // Now, we can allocate the BindResponse Object
                     BindResponseCodec bindResponse = new BindResponseCodec();
-
-                    // As this is a new Constructed object, we have to init its
-                    // length
-                    bindResponse.setParent( ldapMessage );
-
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( bindResponse );
+                    bindResponse.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( bindResponse );
                 }
             } );
 
@@ -1062,8 +1039,7 @@
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    LdapResponseCodec response = ldapMessage.getLdapResponse();
+                    LdapResponseCodec response = ldapMessageContainer.getLdapResponse();
                     LdapResultCodec ldapResult = response.getLdapResult();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -1142,13 +1118,12 @@
             {
                 public void action( IAsn1Container container )
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // Now, we can allocate the SearchResultEntry Object
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( new SearchResultEntryCodec() );
+                    SearchResultEntryCodec searchResultEntry = new SearchResultEntryCodec();
+                    searchResultEntry.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( searchResultEntry );
                 }
             } );
 
@@ -1168,8 +1143,7 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    SearchResultEntryCodec searchResultEntry = ldapMessage.getSearchResultEntry();
+                    SearchResultEntryCodec searchResultEntry = ldapMessageContainer.getSearchResultEntry();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -1275,8 +1249,7 @@
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    SearchResultEntryCodec searchResultEntry = ldapMessage.getSearchResultEntry();
+                    SearchResultEntryCodec searchResultEntry = ldapMessageContainer.getSearchResultEntry();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -1412,12 +1385,12 @@
             {
                 public void action( IAsn1Container container )
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // Now, we can allocate the SearchResultDone Object
-                    ldapMessage.setProtocolOP( new SearchResultDoneCodec() );
+                    SearchResultDoneCodec searchResultDone = new SearchResultDoneCodec();
+                    searchResultDone.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( searchResultDone );
 
                     log.debug( "Search Result Done found" );
                 }
@@ -1451,13 +1424,12 @@
             {
                 public void action( IAsn1Container container )
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-
+                    
                     // Now, we can allocate the ModifyRequest Object
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( new ModifyRequestCodec() );
+                    ModifyRequestCodec modifyRequest = new ModifyRequestCodec();
+                    modifyRequest.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( modifyRequest );
                 }
             } );
 
@@ -1477,8 +1449,7 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    ModifyRequestCodec modifyRequest = ldapMessage.getModifyRequest();
+                    ModifyRequestCodec modifyRequest = ldapMessageContainer.getModifyRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -1504,7 +1475,7 @@
                                 + StringTools.dumpBytes( dnBytes ) + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            ModifyResponseImpl response = new ModifyResponseImpl( ldapMessage.getMessageId() );
+                            ModifyResponseImpl response = new ModifyResponseImpl( modifyRequest.getMessageId() );
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                 LdapDN.EMPTY_LDAPDN, ine );
                         }
@@ -1536,8 +1507,7 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    ModifyRequestCodec modifyRequest = ldapMessage.getModifyRequest();
+                    ModifyRequestCodec modifyRequest = ldapMessageContainer.getModifyRequest();
 
                     modifyRequest.initModifications();
                 }
@@ -1573,8 +1543,7 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    ModifyRequestCodec modifyRequest = ldapMessage.getModifyRequest();
+                    ModifyRequestCodec modifyRequest = ldapMessageContainer.getModifyRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -1657,8 +1626,7 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    ModifyRequestCodec modifyRequest = ldapMessage.getModifyRequest();
+                    ModifyRequestCodec modifyRequest = ldapMessageContainer.getModifyRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -1670,7 +1638,7 @@
                         String msg = "The type can't be null";
                         log.error( msg );
 
-                        ModifyResponseImpl response = new ModifyResponseImpl( ldapMessage.getMessageId() );
+                        ModifyResponseImpl response = new ModifyResponseImpl( modifyRequest.getMessageId() );
                         throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                             modifyRequest.getObject(), null );
                     }
@@ -1840,12 +1808,12 @@
             {
                 public void action( IAsn1Container container )
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
-                    // We associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( new ModifyResponseCodec() );
+                    // Now, we can allocate the ModifyResponse Object
+                    ModifyResponseCodec modifyResponse = new ModifyResponseCodec();
+                    modifyResponse.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( modifyResponse );
 
                     log.debug( "Modify response" );
                 }
@@ -1881,7 +1849,11 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
+                    
+                    // Now, we can allocate the AddRequest Object
+                    AddRequestCodec addRequest = new AddRequestCodec();
+                    addRequest.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( addRequest );
 
                     // We will check that the request is not null
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -1894,10 +1866,6 @@
                         // Will generate a PROTOCOL_ERROR
                         throw new DecoderException( msg );
                     }
-
-                    // Now, we can allocate the ModifyRequest Object
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( new AddRequestCodec() );
                 }
             } );
 
@@ -1917,8 +1885,7 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    AddRequestCodec addRequest = ldapMessage.getAddRequest();
+                    AddRequestCodec addRequest = ldapMessageContainer.getAddRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -1928,7 +1895,7 @@
                         String msg = "Empty entry DN given";
                         log.error( msg );
 
-                        AddResponseImpl response = new AddResponseImpl( ldapMessage.getMessageId() );
+                        AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );
 
                         // I guess that trying to add an entry which DN is empty is a naming violation...
                         // Not 100% sure though ...
@@ -1951,7 +1918,7 @@
                                 + StringTools.dumpBytes( dnBytes ) + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            AddResponseImpl response = new AddResponseImpl( ldapMessage.getMessageId() );
+                            AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                 LdapDN.EMPTY_LDAPDN, ine );
                         }
@@ -2003,19 +1970,17 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    TLV tlv = ldapMessageContainer.getCurrentTLV();
+                    AddRequestCodec addRequest = ldapMessageContainer.getAddRequest();
 
-                    AddRequestCodec addRequest = ldapMessage.getAddRequest();
+                    TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                     // Store the type. It can't be null.
-
                     if ( tlv.getLength() == 0 )
                     {
                         String msg = "Null or empty types are not allowed";
                         log.error( msg );
 
-                        AddResponseImpl response = new AddResponseImpl( ldapMessage.getMessageId() );
+                        AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );
 
                         throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                             addRequest.getEntry().getDn(), null );
@@ -2032,7 +1997,7 @@
                         String msg = "Error while injecting the AttributeType";
                         log.error( msg );
 
-                        AddResponseImpl response = new AddResponseImpl( ldapMessage.getMessageId() );
+                        AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );
                         throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                             addRequest.getEntry().getDn(), ne );
                     }
@@ -2114,7 +2079,11 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
+
+                    // Now, we can allocate the AddResponse Object
+                    AddResponseCodec addResponse = new AddResponseCodec();
+                    addResponse.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( addResponse );
 
                     // We will check that the request is not null
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2128,18 +2097,6 @@
                         throw new DecoderException( msg );
                     }
 
-                    // Now, we can allocate the AddRequest Object
-                    AddResponseCodec addResponse = new AddResponseCodec();
-
-                    // As this is a new Constructed object, we have to init its
-                    // length
-                    //addResponse.setExpectedLength( expectedLength );
-                    //addResponse.setCurrentLength( 0 );
-                    //addResponse.setParent( ldapMessage );
-
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( addResponse );
-
                     log.debug( "Add Response" );
                 }
             } );
@@ -2171,14 +2128,12 @@
             {
                 public void action( IAsn1Container container )
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // Now, we can allocate the DelResponse Object
-
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( new DelResponseCodec() );
+                    DelResponseCodec delResponse = new DelResponseCodec();
+                    delResponse.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( delResponse );
 
                     log.debug( "Del response " );
                 }
@@ -2212,14 +2167,14 @@
             {
                 public void action( IAsn1Container container )
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // Now, we can allocate the ModifyDNRequest Object
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( new ModifyDNRequestCodec() );
+                    ModifyDNRequestCodec modifyDNRequest = new ModifyDNRequestCodec();
+                    modifyDNRequest.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( modifyDNRequest );
 
+                    log.debug( "ModifyDn request" );
                 }
             } );
 
@@ -2237,11 +2192,9 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
-                    ModifyDNRequestCodec modifyDNRequest = ldapMessage.getModifyDNRequest();
+                    ModifyDNRequestCodec modifyDNRequest = ldapMessageContainer.getModifyDnRequest();
 
                     // Get the Value and store it in the modifyDNRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2270,7 +2223,7 @@
                                 + StringTools.dumpBytes( dnBytes ) + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( ldapMessage.getMessageId() );
+                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDNRequest.getMessageId() );
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                 LdapDN.EMPTY_LDAPDN, ine );
                         }
@@ -2304,11 +2257,9 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
-                    ModifyDNRequestCodec modifyDNRequest = ldapMessage.getModifyDNRequest();
+                    ModifyDNRequestCodec modifyDNRequest = ldapMessageContainer.getModifyDnRequest();
 
                     // Get the Value and store it in the modifyDNRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2322,7 +2273,7 @@
                         String msg = "The newrdn must not be null";
                         log.error( msg );
 
-                        ModifyDnResponseImpl response = new ModifyDnResponseImpl( ldapMessage.getMessageId() );
+                        ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDNRequest.getMessageId() );
                         throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                             modifyDNRequest.getEntry(), null );
                     }
@@ -2342,7 +2293,7 @@
                                 + StringTools.dumpBytes( dnBytes ) + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( ldapMessage.getMessageId() );
+                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDNRequest.getMessageId() );
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                 modifyDNRequest.getEntry(), ine );
                         }
@@ -2372,15 +2323,11 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
+                    ModifyDNRequestCodec modifyDNRequest = ldapMessageContainer.getModifyDnRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
-                    // Store the value.
-                    ModifyDNRequestCodec modifyDNRequest = ldapMessage.getModifyDNRequest();
-
                     // We get the value. If it's a 0, it's a FALSE. If it's
                     // a FF, it's a TRUE. Any other value should be an error,
                     // but we could relax this constraint. So if we have
@@ -2434,11 +2381,8 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-
-                    ModifyDNRequestCodec modifyDNRequest = ldapMessage.getModifyDNRequest();
+                    ModifyDNRequestCodec modifyDNRequest = ldapMessageContainer.getModifyDnRequest();
 
                     // Get the Value and store it in the modifyDNRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2478,7 +2422,7 @@
                                 + " (" + StringTools.dumpBytes( dnBytes ) + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( ldapMessage.getMessageId() );
+                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDNRequest.getMessageId() );
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                 modifyDNRequest.getEntry(), ine );
                         }
@@ -2537,10 +2481,11 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( new ModifyDNResponseCodec() );
+                    
+                    // Now, we can allocate the ModifyDnResponse Object
+                    ModifyDNResponseCodec modifyDnResponse = new ModifyDNResponseCodec();
+                    modifyDnResponse.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( modifyDnResponse );
 
                     log.debug( "Modify DN response " );
                 }
@@ -2578,12 +2523,14 @@
             {
                 public void action( IAsn1Container container )
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
-                    // We can allocate the CompareRequest Object
-                    ldapMessage.setProtocolOP( new CompareRequestCodec() );
+                    // Now, we can allocate the CompareRequest Object
+                    CompareRequestCodec compareRequest = new CompareRequestCodec();
+                    compareRequest.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( compareRequest );
+
+                    log.debug( "Compare Request" );
                 }
             } );
 
@@ -2603,10 +2550,7 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-
-                    // We can allocate the CompareRequest Object
-                    CompareRequestCodec compareRequest = ldapMessage.getCompareRequest();
+                    CompareRequestCodec compareRequest = ldapMessageContainer.getCompareRequest();
 
                     // Get the Value and store it in the CompareRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2634,7 +2578,7 @@
                                 + StringTools.dumpBytes( dnBytes ) + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            CompareResponseImpl response = new CompareResponseImpl( ldapMessage.getMessageId() );
+                            CompareResponseImpl response = new CompareResponseImpl( compareRequest.getMessageId() );
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                 LdapDN.EMPTY_LDAPDN, ine );
                         }
@@ -2680,10 +2624,9 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // Get the CompareRequest Object
-                    CompareRequestCodec compareRequest = ldapMessage.getCompareRequest();
+                    CompareRequestCodec compareRequest = ldapMessageContainer.getCompareRequest();
 
                     // Get the Value and store it in the CompareRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2694,7 +2637,7 @@
                     {
                         String msg = "The attribute description must not be null";
                         log.error( msg );
-                        CompareResponseImpl response = new CompareResponseImpl( ldapMessage.getMessageId() );
+                        CompareResponseImpl response = new CompareResponseImpl( compareRequest.getMessageId() );
 
                         throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                             compareRequest.getEntry(), null );
@@ -2728,10 +2671,9 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // Get the CompareRequest Object
-                    CompareRequestCodec compareRequest = ldapMessage.getCompareRequest();
+                    CompareRequestCodec compareRequest = ldapMessageContainer.getCompareRequest();
 
                     // Get the Value and store it in the CompareRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2797,7 +2739,11 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
+
+                    // Now, we can allocate the CompareResponse Object
+                    CompareResponseCodec compareResponse = new CompareResponseCodec();
+                    compareResponse.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( compareResponse );
 
                     // We will check that the request is not null
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2809,10 +2755,6 @@
                         throw new DecoderException( msg );
                     }
 
-                    // Now, we can allocate the CompareResponse Object
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( new CompareResponseCodec() );
-
                     log.debug( "Compare response " );
                 }
             } );
@@ -2845,19 +2787,14 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-
-                    // Now, we can allocate the BindRequest Object
+                    
+                    // Now, we can allocate the SearchResultReference Object
                     SearchResultReferenceCodec searchResultReference = new SearchResultReferenceCodec();
+                    searchResultReference.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( searchResultReference );
 
-                    // As this is a new Constructed object, we have to init its
-                    // length
-                    searchResultReference.setParent( ldapMessage );
-
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( searchResultReference );
+                    log.debug( "SearchResultReference response " );
                 }
             } );
 
@@ -2908,12 +2845,14 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
+                    
+                    // Now, we can allocate the ExtendedRequest Object
+                    ExtendedRequestCodec extendedRequest = new ExtendedRequestCodec();
+                    extendedRequest.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( extendedRequest );
 
-                    // We can allocate the ExtendedRequest Object
-                    ldapMessage.setProtocolOP( new ExtendedRequestCodec() );
+                    log.debug( "Extended request" );
                 }
             } );
 
@@ -2931,12 +2870,10 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // We can allocate the ExtendedRequest Object
-                    ExtendedRequestCodec extendedRequest = ldapMessage.getExtendedRequest();
+                    ExtendedRequestCodec extendedRequest = ldapMessageContainer.getExtendedRequest();
 
                     // Get the Value and store it in the ExtendedRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2994,12 +2931,10 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // We can allocate the ExtendedRequest Object
-                    ExtendedRequestCodec extendedRequest = ldapMessage.getExtendedRequest();
+                    ExtendedRequestCodec extendedRequest = ldapMessageContainer.getExtendedRequest();
 
                     // Get the Value and store it in the ExtendedRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -3062,12 +2997,14 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
-                    // We can allocate the ExtendedResponse Object
-                    ldapMessage.setProtocolOP( new ExtendedResponseCodec() );
+                    // Now, we can allocate the ExtendedResponse Object
+                    ExtendedResponseCodec extendedResponse = new ExtendedResponseCodec();
+                    extendedResponse.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( extendedResponse );
+
+                    log.debug( "Extended Response" );
                 }
             } );
 
@@ -3276,12 +3213,14 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
-                    // We can allocate the IntermediateResponse Object
-                    ldapMessage.setProtocolOP( new IntermediateResponseCodec() );
+                    // Now, we can allocate the IntermediateResponse Object
+                    IntermediateResponseCodec intermediateResponse = new IntermediateResponseCodec();
+                    intermediateResponse.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( intermediateResponse );
+
+                    log.debug( "Intermediate Response" );
                 }
             } );
 
@@ -3301,10 +3240,9 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // We can get the IntermediateResponse Object
-                    IntermediateResponseCodec intermediateResponse = ldapMessage.getIntermediateResponse();
+                    IntermediateResponseCodec intermediateResponse = ldapMessageContainer.getIntermediateResponse();
 
                     // Get the Value and store it in the IntermediateResponse
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -3363,12 +3301,10 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // We can get the IntermediateResponse Object
-                    IntermediateResponseCodec intermediateResponse = ldapMessage.getIntermediateResponse();
+                    IntermediateResponseCodec intermediateResponse = ldapMessageContainer.getIntermediateResponse();
 
                     // Get the Value and store it in the IntermediateResponse
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -3408,12 +3344,10 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
 
                     // We can allocate the ExtendedRequest Object
-                    IntermediateResponseCodec intermediateResponse = ldapMessage.getIntermediateResponse();
+                    IntermediateResponseCodec intermediateResponse = ldapMessageContainer.getIntermediateResponse();
 
                     // Get the Value and store it in the IntermediateResponse
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -3688,13 +3622,14 @@
             {
                 public void action( IAsn1Container container )
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
+                    
+                    // Now, we can allocate the SearchRequest Object
+                    SearchRequestCodec searchRequest = new SearchRequestCodec();
+                    searchRequest.setMessageId( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setLdapMessage( searchRequest );
 
-                    // Now, we can allocate the SearchRequest
-                    // And we associate it to the ldapMessage Object
-                    ldapMessage.setProtocolOP( new SearchRequestCodec() );
+                    log.debug( "Search Request" );
                 }
             } );
 
@@ -3712,10 +3647,8 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    SearchRequestCodec searchRequest = ldapMessage.getSearchRequest();
+                    SearchRequestCodec searchRequest = ldapMessageContainer.getSearchRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -3741,7 +3674,7 @@
                                 + StringTools.dumpBytes( dnBytes ) + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            SearchResponseDoneImpl response = new SearchResponseDoneImpl( ldapMessage.getMessageId() );
+                            SearchResponseDoneImpl response = new SearchResponseDoneImpl( searchRequest.getMessageId() );
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                 LdapDN.EMPTY_LDAPDN, ine );
                         }
@@ -3773,10 +3706,9 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
-                    SearchRequestCodec searchRequest = ldapMessageContainer.getLdapMessage().getSearchRequest();
+                    SearchRequestCodec searchRequest = ldapMessageContainer.getSearchRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -3838,10 +3770,9 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
-                    SearchRequestCodec searchRequest = ldapMessageContainer.getLdapMessage().getSearchRequest();
+                    SearchRequestCodec searchRequest = ldapMessageContainer.getSearchRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -3902,10 +3833,9 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
-                    SearchRequestCodec searchRequest = ldapMessageContainer.getLdapMessage().getSearchRequest();
+                    SearchRequestCodec searchRequest = ldapMessageContainer.getSearchRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -3950,10 +3880,9 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
-                    SearchRequestCodec searchRequest = ldapMessageContainer.getLdapMessage().getSearchRequest();
+                    SearchRequestCodec searchRequest = ldapMessageContainer.getSearchRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -3999,10 +3928,9 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
-                    SearchRequestCodec searchRequest = ldapMessageContainer.getLdapMessage().getSearchRequest();
+                    SearchRequestCodec searchRequest = ldapMessageContainer.getSearchRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -5149,8 +5077,7 @@
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    SearchRequestCodec searchRequest = ldapMessage.getSearchRequest();
+                    SearchRequestCodec searchRequest = ldapMessageContainer.getSearchRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -5223,8 +5150,7 @@
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    SearchRequestCodec searchRequest = ldapMessage.getSearchRequest();
+                    SearchRequestCodec searchRequest = ldapMessageContainer.getSearchRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -6144,8 +6070,7 @@
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    SearchRequestCodec searchRequest = ldapMessage.getSearchRequest();
+                    SearchRequestCodec searchRequest = ldapMessageContainer.getSearchRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -6271,8 +6196,7 @@
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessageCodec ldapMessage = ldapMessageContainer.getLdapMessage();
-                    SearchRequestCodec searchRequest = ldapMessage.getSearchRequest();
+                    SearchRequestCodec searchRequest = ldapMessageContainer.getSearchRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponseCodec.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponseCodec.java?rev=910150&r1=910149&r2=910150&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponseCodec.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponseCodec.java Mon Feb 15 01:37:34 2010
@@ -19,19 +19,20 @@
  */
 package org.apache.directory.shared.ldap.codec;
 
-
 import java.nio.ByteBuffer;
 
 import org.apache.directory.shared.asn1.codec.EncoderException;
 
 
+
+
 /**
  * A generic LdapResponse Object. It will contain the LdapResult.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$, 
  */
-public class LdapResponseCodec extends LdapMessageCodec
+public abstract class LdapResponseCodec extends LdapMessageCodec
 {
     // ~ Instance fields
     // ----------------------------------------------------------------------------
@@ -90,11 +91,16 @@
 
 
     /**
-     * Compute the LdapResponse length LdapResponse : LdapResult
+     * Compute the LdapResponse length
      */
-    public int computeLength()
+    public int computeLdapResultLength()
     {
-        ldapResponseLength = ldapResult.computeLength();
+        ldapResponseLength = 0;
+
+        if ( ldapResult != null )
+        {
+            ldapResponseLength = ldapResult.computeLength();
+        }
 
         return ldapResponseLength;
     }
@@ -114,9 +120,11 @@
         }
 
         // The ldapResult
-        ldapResult.encode( buffer );
+        if ( ldapResult != null )
+        {
+            ldapResult.encode( buffer );
+        }
 
-        // The ldapResult
         return buffer;
     }
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java?rev=910150&r1=910149&r2=910150&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java Mon Feb 15 01:37:34 2010
@@ -60,6 +60,7 @@
 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.search.SubstringFilter;
+import org.apache.directory.shared.ldap.codec.unbind.UnBindRequestCodec;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
@@ -137,10 +138,9 @@
      * @param messageId The message Id
      * @return An internal AbandonRequest message
      */
-    private static InternalMessage transformAbandonRequest( LdapMessageCodec codecMessage, int messageId )
+    private static InternalMessage transformAbandonRequest( AbandonRequestCodec abandonRequest, int messageId )
     {
         AbandonRequestImpl internalMessage = new AbandonRequestImpl( messageId );
-        AbandonRequestCodec abandonRequest = codecMessage.getAbandonRequest();
 
         // Codec : int abandonnedMessageId -> Internal : int abandonId
         internalMessage.setAbandoned( abandonRequest.getAbandonedMessageId() );
@@ -150,16 +150,15 @@
 
 
     /**
-     * Transform an AddRequest message from a CodecMessage to a InternalMessage
+     * Transform an AddRequest message from a addRequest to a InternalMessage
      * 
-     * @param codecMessage The message to transform
+     * @param addRequest The message to transform
      * @param messageId The message Id
      * @return A Internal AddRequestImpl
      */
-    private static InternalMessage transformAddRequest( LdapMessageCodec codecMessage, int messageId )
+    private static InternalMessage transformAddRequest( AddRequestCodec addRequest, int messageId )
     {
         AddRequestImpl internalMessage = new AddRequestImpl( messageId );
-        AddRequestCodec addRequest = codecMessage.getAddRequest();
 
         // Codec : LdapDN entry -> Internal : String name
         internalMessage.setEntry( addRequest.getEntry() );
@@ -174,14 +173,13 @@
     /**
      * Transform a BindRequest message from a CodecMessage to a InternalMessage
      * 
-     * @param codecMessage The message to transform
+     * @param bindRequest The message to transform
      * @param messageId The message Id
      * @return A Internal BindRequestImpl
      */
-    private static InternalMessage transformBindRequest( LdapMessageCodec codecMessage, int messageId )
+    private static InternalMessage transformBindRequest( BindRequestCodec bindRequest, int messageId )
     {
         BindRequestImpl internalMessage = new BindRequestImpl( messageId );
-        BindRequestCodec bindRequest = codecMessage.getBindRequest();
 
         // Codec : int version -> Internal : boolean isVersion3
         internalMessage.setVersion3( bindRequest.isLdapV3() );
@@ -217,14 +215,13 @@
      * BindResponse PDU and must decode it to return the Internal 
      * representation.
      * 
-     * @param codecMessage The message to transform
+     * @param bindResponse The message to transform
      * @param messageId The message Id
      * @return a Internal BindResponseImpl
      */
-    private static InternalMessage transformBindResponse( LdapMessageCodec codecMessage, int messageId )
+    private static InternalMessage transformBindResponse( BindResponseCodec bindResponse, int messageId )
     {
         BindResponseImpl internalMessage = new BindResponseImpl( messageId );
-        BindResponseCodec bindResponse = codecMessage.getBindResponse();
 
         // Codec : byte[] serverSaslcreds -> Internal : byte[] serverSaslCreds
         internalMessage.setServerSaslCreds( bindResponse.getServerSaslCreds() );
@@ -280,14 +277,13 @@
      * Transform a CompareRequest message from a CodecMessage to a
      * InternalMessage
      * 
-     * @param codecMessage The message to transform
+     * @param compareRequest The message to transform
      * @param messageId The message Id
      * @return A Internal CompareRequestImpl
      */
-    private static InternalMessage transformCompareRequest( LdapMessageCodec codecMessage, int messageId )
+    private static InternalMessage transformCompareRequest( CompareRequestCodec compareRequest, int messageId )
     {
         CompareRequestImpl internalMessage = new CompareRequestImpl( messageId );
-        CompareRequestCodec compareRequest = codecMessage.getCompareRequest();
 
         // Codec : LdapDN entry -> Internal : private LdapDN
         internalMessage.setName( compareRequest.getEntry() );
@@ -312,14 +308,13 @@
     /**
      * Transform a DelRequest message from a CodecMessage to a InternalMessage
      * 
-     * @param codecMessage The message to transform
+     * @param delRequest The message to transform
      * @param messageId The message Id
      * @return A Internal DeleteRequestImpl
      */
-    private static InternalMessage transformDelRequest( LdapMessageCodec codecMessage, int messageId )
+    private static InternalMessage transformDelRequest( DelRequestCodec delRequest, int messageId )
     {
         DeleteRequestImpl internalMessage = new DeleteRequestImpl( messageId );
-        DelRequestCodec delRequest = codecMessage.getDelRequest();
 
         // Codec : LdapDN entry -> Internal : LdapDN
         internalMessage.setName( delRequest.getEntry() );
@@ -332,13 +327,12 @@
      * Transform an ExtendedRequest message from a CodecMessage to a
      * InternalMessage
      * 
-     * @param codecMessage The message to transform
+     * @param extendedRequest The message to transform
      * @param messageId The message Id
      * @return A Internal ExtendedRequestImpl
      */
-    private static InternalMessage transformExtendedRequest( LdapMessageCodec codecMessage, int messageId )
+    private static InternalMessage transformExtendedRequest( ExtendedRequestCodec extendedRequest, int messageId )
     {
-        ExtendedRequestCodec extendedRequest = codecMessage.getExtendedRequest();
         ExtendedRequestImpl internalMessage;
 
         if ( extendedRequest.getRequestName().equals( GracefulShutdownRequest.EXTENSION_OID ) )
@@ -364,14 +358,13 @@
      * Transform a ModifyDNRequest message from a CodecMessage to a
      * InternalMessage
      * 
-     * @param codecMessage The message to transform
+     * @param modifyDNRequest The message to transform
      * @param messageId The message Id
      * @return A Internal ModifyDNRequestImpl
      */
-    private static InternalMessage transformModifyDNRequest( LdapMessageCodec codecMessage, int messageId )
+    private static InternalMessage transformModifyDNRequest( ModifyDNRequestCodec modifyDNRequest, int messageId )
     {
         ModifyDnRequestImpl internalMessage = new ModifyDnRequestImpl( messageId );
-        ModifyDNRequestCodec modifyDNRequest = codecMessage.getModifyDNRequest();
 
         // Codec : LdapDN entry -> Internal : LdapDN m_name
         internalMessage.setName( modifyDNRequest.getEntry() );
@@ -392,14 +385,13 @@
     /**
      * Transform a ModifyRequest message from a CodecMessage to a InternalMessage
      * 
-     * @param codecMessage The message to transform
+     * @param modifyRequest The message to transform
      * @param messageId The message Id
      * @return A Internal ModifyRequestImpl
      */
-    private static InternalMessage transformModifyRequest( LdapMessageCodec codecMessage, int messageId )
+    private static InternalMessage transformModifyRequest( ModifyRequestCodec modifyRequest, int messageId )
     {
         ModifyRequestImpl internalMessage = new ModifyRequestImpl( messageId );
-        ModifyRequestCodec modifyRequest = codecMessage.getModifyRequest();
 
         // Codec : LdapDN object -> Internal : String name
         internalMessage.setName( modifyRequest.getObject() );
@@ -719,14 +711,13 @@
     /**
      * Transform a SearchRequest message from a CodecMessage to a InternalMessage
      * 
-     * @param codecMessage The message to transform
+     * @param searchRequest The message to transform
      * @param messageId The message Id
      * @return A Internal SearchRequestImpl
      */
-    private static InternalMessage transformSearchRequest( LdapMessageCodec codecMessage, int messageId )
+    private static InternalMessage transformSearchRequest( SearchRequestCodec searchRequest, int messageId )
     {
         SearchRequestImpl internalMessage = new SearchRequestImpl( messageId );
-        SearchRequestCodec searchRequest = codecMessage.getSearchRequest();
 
         // Codec : LdapDN baseObject -> Internal : String baseDn
         internalMessage.setBase( searchRequest.getBaseObject() );
@@ -822,64 +813,64 @@
 
         InternalMessage internalMessage = null;
 
-        int messageType = codecMessage.getMessageType();
+        MessageTypeEnum messageType = codecMessage.getMessageType();
 
         switch ( messageType )
         {
-            case ( LdapConstants.BIND_REQUEST  ):
-                internalMessage = transformBindRequest( codecMessage, messageId );
+            case BIND_REQUEST :
+                internalMessage = transformBindRequest( (BindRequestCodec)codecMessage, messageId );
                 break;
 
-            case ( LdapConstants.UNBIND_REQUEST  ):
-                internalMessage = transformUnBindRequest( codecMessage, messageId );
+            case UNBIND_REQUEST :
+                internalMessage = transformUnBindRequest( (UnBindRequestCodec)codecMessage, messageId );
                 break;
 
-            case ( LdapConstants.SEARCH_REQUEST  ):
-                internalMessage = transformSearchRequest( codecMessage, messageId );
+            case SEARCH_REQUEST :
+                internalMessage = transformSearchRequest( (SearchRequestCodec)codecMessage, messageId );
                 break;
 
-            case ( LdapConstants.MODIFY_REQUEST  ):
-                internalMessage = transformModifyRequest( codecMessage, messageId );
+            case MODIFY_REQUEST :
+                internalMessage = transformModifyRequest( (ModifyRequestCodec)codecMessage, messageId );
                 break;
 
-            case ( LdapConstants.ADD_REQUEST  ):
-                internalMessage = transformAddRequest( codecMessage, messageId );
+            case ADD_REQUEST :
+                internalMessage = transformAddRequest( (AddRequestCodec)codecMessage, messageId );
                 break;
 
-            case ( LdapConstants.DEL_REQUEST  ):
-                internalMessage = transformDelRequest( codecMessage, messageId );
+            case DEL_REQUEST :
+                internalMessage = transformDelRequest( (DelRequestCodec)codecMessage, messageId );
                 break;
 
-            case ( LdapConstants.MODIFYDN_REQUEST  ):
-                internalMessage = transformModifyDNRequest( codecMessage, messageId );
+            case MODIFYDN_REQUEST :
+                internalMessage = transformModifyDNRequest( (ModifyDNRequestCodec)codecMessage, messageId );
                 break;
 
-            case ( LdapConstants.COMPARE_REQUEST  ):
-                internalMessage = transformCompareRequest( codecMessage, messageId );
+            case COMPARE_REQUEST :
+                internalMessage = transformCompareRequest( (CompareRequestCodec)codecMessage, messageId );
                 break;
 
-            case ( LdapConstants.ABANDON_REQUEST  ):
-                internalMessage = transformAbandonRequest( codecMessage, messageId );
+            case ABANDON_REQUEST :
+                internalMessage = transformAbandonRequest( (AbandonRequestCodec)codecMessage, messageId );
                 break;
 
-            case ( LdapConstants.EXTENDED_REQUEST  ):
-                internalMessage = transformExtendedRequest( codecMessage, messageId );
+            case EXTENDED_REQUEST :
+                internalMessage = transformExtendedRequest( (ExtendedRequestCodec)codecMessage, messageId );
                 break;
                 
-            case ( LdapConstants.BIND_RESPONSE  ):
-                internalMessage = transformBindResponse( codecMessage, messageId );
+            case BIND_RESPONSE :
+                internalMessage = transformBindResponse( (BindResponseCodec)codecMessage, messageId );
                 break;
 
-            case ( LdapConstants.SEARCH_RESULT_ENTRY ):
-            case ( LdapConstants.SEARCH_RESULT_DONE ):
-            case ( LdapConstants.SEARCH_RESULT_REFERENCE ):
-            case ( LdapConstants.MODIFY_RESPONSE ):
-            case ( LdapConstants.ADD_RESPONSE ):
-            case ( LdapConstants.DEL_RESPONSE ):
-            case ( LdapConstants.MODIFYDN_RESPONSE ):
-            case ( LdapConstants.COMPARE_RESPONSE ):
-            case ( LdapConstants.EXTENDED_RESPONSE ):
-            case ( LdapConstants.INTERMEDIATE_RESPONSE ):
+            case SEARCH_RESULT_ENTRY :
+            case SEARCH_RESULT_DONE :
+            case SEARCH_RESULT_REFERENCE :
+            case MODIFY_RESPONSE :
+            case ADD_RESPONSE :
+            case DEL_RESPONSE :
+            case MODIFYDN_RESPONSE :
+            case COMPARE_RESPONSE :
+            case EXTENDED_RESPONSE :
+            case INTERMEDIATE_RESPONSE :
                 // Nothing to do !
                 break;
 
@@ -945,10 +936,10 @@
     /**
      * Transform a Internal AddResponse to a Codec AddResponse
      * 
-     * @param codecMessage The Codec AddResponse to produce
      * @param internalMessage The incoming Internal AddResponse
+     * @return The AddResponseCodec instance
      */
-    private static void transformAddResponse( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformAddResponse( InternalMessage internalMessage )
     {
         AddResponseImpl internalAddResponse = ( AddResponseImpl ) internalMessage;
 
@@ -957,22 +948,21 @@
         // Transform the ldapResult
         addResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalAddResponse.getLdapResult() ) );
 
-        // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( addResponse );
+        return addResponse;
     }
 
 
     /**
      * Transform a Internal BindResponse to a Codec BindResponse
      * 
-     * @param codecMessage The Codec BindResponse to produce
      * @param internalMessage The incoming Internal BindResponse
+     * @return The BindResponseCodec instance
      */
-    private static void transformBindResponse( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformBindResponse( InternalMessage internalMessage )
     {
         BindResponseImpl internalBindResponse = ( BindResponseImpl ) internalMessage;
 
-        BindResponseCodec bindResponse = new BindResponseCodec();
+        BindResponseCodec bindResponseCodec = new BindResponseCodec();
 
         // Internal : byte [] serverSaslCreds -> Codec : OctetString
         // serverSaslCreds
@@ -980,29 +970,28 @@
 
         if ( serverSaslCreds != null )
         {
-            bindResponse.setServerSaslCreds( serverSaslCreds );
+            bindResponseCodec.setServerSaslCreds( serverSaslCreds );
         }
 
         // Transform the ldapResult
-        bindResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalBindResponse.getLdapResult() ) );
+        bindResponseCodec.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalBindResponse.getLdapResult() ) );
 
-        // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( bindResponse );
+        return bindResponseCodec;
     }
 
 
     /**
      * Transform a Internal BindRequest to a Codec BindRequest
      * 
-     * @param codecMessage The Codec BindRequest to produce
      * @param internalMessage The incoming Internal BindRequest
+     * @return The BindRequestCodec instance
      */
-    private static void transformBindRequest( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformBindRequest( InternalMessage internalMessage )
     {
         BindRequestImpl internalBindRequest = ( BindRequestImpl ) internalMessage;
 
         BindRequestCodec bindRequest = new BindRequestCodec();
-        
+
         if ( internalBindRequest.isSimple() )
         {
             SimpleAuthentication simple = new SimpleAuthentication();
@@ -1021,18 +1010,17 @@
         bindRequest.setName( internalBindRequest.getName() );
         bindRequest.setVersion( internalBindRequest.isVersion3() ? 3 : 2 );
         
-        // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( bindRequest );
+        return bindRequest;
     }
 
 
     /**
      * Transform a Internal CompareResponse to a Codec CompareResponse
      * 
-     * @param codecMessage The Codec CompareResponse to produce
      * @param internalMessage The incoming Internal CompareResponse
+     * @return The CompareResponseCodec instance
      */
-    private static void transformCompareResponse( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformCompareResponse( InternalMessage internalMessage )
     {
         CompareResponseImpl internalCompareResponse = ( CompareResponseImpl ) internalMessage;
 
@@ -1042,18 +1030,17 @@
         compareResponse
             .setLdapResult( transformLdapResult( ( LdapResultImpl ) internalCompareResponse.getLdapResult() ) );
 
-        // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( compareResponse );
+        return compareResponse;
     }
 
 
     /**
      * Transform a Internal DelResponse to a Codec DelResponse
      * 
-     * @param codecMessage The Codec DelResponse to produce
      * @param internalMessage The incoming Internal DelResponse
+     * @return The DelResponseCodec instance
      */
-    private static void transformDelResponse( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformDelResponse( InternalMessage internalMessage )
     {
         DeleteResponseImpl internalDelResponse = ( DeleteResponseImpl ) internalMessage;
 
@@ -1062,18 +1049,17 @@
         // Transform the ldapResult
         delResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalDelResponse.getLdapResult() ) );
 
-        // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( delResponse );
+        return delResponse;
     }
 
 
     /**
      * Transform a Internal ExtendedResponse to a Codec ExtendedResponse
      * 
-     * @param codecMessage The Codec ExtendedResponse to produce
      * @param internalMessage The incoming Internal ExtendedResponse
+     * @return The ExtendedResponseCodec instance
      */
-    private static void transformExtendedResponse( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformExtendedResponse( InternalMessage internalMessage )
     {
         ExtendedResponseImpl internalExtendedResponse = ( ExtendedResponseImpl ) internalMessage;
         ExtendedResponseCodec extendedResponse = new ExtendedResponseCodec();
@@ -1096,18 +1082,17 @@
         extendedResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalExtendedResponse
             .getLdapResult() ) );
 
-        // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( extendedResponse );
+        return extendedResponse;
     }
 
 
     /**
      * Transform a Internal IntermediateResponse to a Codec IntermediateResponse
      * 
-     * @param codecMessage The Codec IntermediateResponse to produce
      * @param internalMessage The incoming Internal IntermediateResponse
+     * @return The IntermediateResponseCodec instance
      */
-    private static void transformIntermediateResponse( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformIntermediateResponse( InternalMessage internalMessage )
     {
         IntermediateResponseImpl internalIntermediateResponse = (IntermediateResponseImpl) internalMessage;
         IntermediateResponseCodec intermediateResponse = new IntermediateResponseCodec();
@@ -1130,18 +1115,17 @@
         intermediateResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalIntermediateResponse
             .getLdapResult() ) );
 
-        // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( intermediateResponse );
+        return intermediateResponse;
     }
 
 
     /**
      * Transform a Internal ModifyResponse to a Codec ModifyResponse
      * 
-     * @param codecMessage The Codec ModifyResponse to produce
      * @param internalMessage The incoming Internal ModifyResponse
+     * @return The ModifyResponseCodec instance
      */
-    private static void transformModifyResponse( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformModifyResponse( InternalMessage internalMessage )
     {
         ModifyResponseImpl internalModifyResponse = ( ModifyResponseImpl ) internalMessage;
 
@@ -1150,18 +1134,17 @@
         // Transform the ldapResult
         modifyResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalModifyResponse.getLdapResult() ) );
 
-        // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( modifyResponse );
+        return modifyResponse;
     }
 
 
     /**
      * Transform a Internal ModifyDNResponse to a Codec ModifyDNResponse
      * 
-     * @param codecMessage The Codec ModifyDNResponse to produce
      * @param internalMessage The incoming Internal ModifyDNResponse
+     * @return The ModifyDnResponseCodec instance
      */
-    private static void transformModifyDNResponse( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformModifyDNResponse( InternalMessage internalMessage )
     {
         ModifyDnResponseImpl internalModifyDNResponse = ( ModifyDnResponseImpl ) internalMessage;
 
@@ -1171,18 +1154,17 @@
         modifyDNResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalModifyDNResponse
             .getLdapResult() ) );
 
-        // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( modifyDNResponse );
+        return modifyDNResponse;
     }
 
 
     /**
      * Transform a Internal SearchResponseDone to a Codec SearchResultDone
      * 
-     * @param codecMessage The Codec SearchResultDone to produce
      * @param internalMessage The incoming Internal SearchResponseDone
+     * @return The SearchResultDone instance
      */
-    private static void transformSearchResultDone( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformSearchResultDone( InternalMessage internalMessage )
     {
         SearchResponseDoneImpl internalSearchResponseDone = ( SearchResponseDoneImpl ) internalMessage;
         SearchResultDoneCodec searchResultDone = new SearchResultDoneCodec();
@@ -1192,17 +1174,16 @@
             .getLdapResult() ) );
 
         // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( searchResultDone );
+        return searchResultDone;
     }
 
 
     /**
      * Transform a Internal SearchResponseEntry to a Codec SearchResultEntry
      * 
-     * @param codecMessage The Codec SearchResultEntry to produce
      * @param internalMessage The incoming Internal SearchResponseEntry
      */
-    private static void transformSearchResultEntry( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformSearchResultEntry( InternalMessage internalMessage )
     {
         SearchResponseEntryImpl internalSearchResultResponse = ( SearchResponseEntryImpl ) internalMessage;
         SearchResultEntryCodec searchResultEntry = new SearchResultEntryCodec();
@@ -1214,8 +1195,7 @@
         // partialAttributeList
         searchResultEntry.setEntry( internalSearchResultResponse.getEntry() );
 
-        // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( searchResultEntry );
+        return searchResultEntry;
     }
 
 
@@ -1223,10 +1203,9 @@
      * Transform a Internal SearchResponseReference to a Codec
      * SearchResultReference
      * 
-     * @param codecMessage The Codec SearchResultReference to produce
      * @param internalMessage The incoming Internal SearchResponseReference
      */
-    private static void transformSearchResultReference( LdapMessageCodec codecMessage, InternalMessage internalMessage )
+    private static LdapMessageCodec transformSearchResultReference( InternalMessage internalMessage )
     {
         SearchResponseReferenceImpl internalSearchResponseReference = ( SearchResponseReferenceImpl ) internalMessage;
         SearchResultReferenceCodec searchResultReference = new SearchResultReferenceCodec();
@@ -1256,8 +1235,7 @@
             }
         }
 
-        // Set the operation into the LdapMessage
-        codecMessage.setProtocolOP( searchResultReference );
+        return searchResultReference;
     }
 
 
@@ -1274,61 +1252,61 @@
             LOG.debug( "Transforming message type " + msg.getType() );
         }
 
-        LdapMessageCodec codecMessage = new LdapMessageCodec();
-
-        codecMessage.setMessageId( msg.getMessageId() );
+        LdapMessageCodec codecMessage = null;
 
         switch ( msg.getType() )
         {
-            case SEARCH_RES_ENTRY :
-                transformSearchResultEntry( codecMessage, msg );
+            case SEARCH_RESULT_ENTRY :
+                codecMessage = transformSearchResultEntry( msg );
                 break;
                 
-            case SEARCH_RES_DONE :
-                transformSearchResultDone( codecMessage, msg );
+            case SEARCH_RESULT_DONE :
+                codecMessage = transformSearchResultDone( msg );
                 break;
                 
-            case SEARCH_RES_REF :
-                transformSearchResultReference( codecMessage, msg );
+            case SEARCH_RESULT_REFERENCE :
+                codecMessage = transformSearchResultReference( msg );
                 break;
                 
             case BIND_RESPONSE :
-                transformBindResponse( codecMessage, msg );
+                codecMessage = transformBindResponse( msg );
                 break;
                 
             case BIND_REQUEST :
-                transformBindRequest( codecMessage, msg );
+                codecMessage = transformBindRequest( msg );
                 break;
                 
             case ADD_RESPONSE :
-                transformAddResponse( codecMessage, msg );
+                codecMessage = transformAddResponse( msg );
                 break;
                 
             case COMPARE_RESPONSE :
-                transformCompareResponse( codecMessage, msg );
+                codecMessage = transformCompareResponse( msg );
                 break;
                 
             case DEL_RESPONSE :
-                transformDelResponse( codecMessage, msg );
+                codecMessage = transformDelResponse( msg );
                 break;
          
             case MODIFY_RESPONSE :
-                transformModifyResponse( codecMessage, msg );
+                codecMessage = transformModifyResponse( msg );
                 break;
 
-            case MOD_DN_RESPONSE :
-                transformModifyDNResponse( codecMessage, msg );
+            case MODIFYDN_RESPONSE :
+                codecMessage = transformModifyDNResponse( msg );
                 break;
                 
-            case EXTENDED_RESP :
-                transformExtendedResponse( codecMessage, msg );
+            case EXTENDED_RESPONSE :
+                codecMessage = transformExtendedResponse( msg );
                 break;
                 
-            case INTERMEDIATE_RESP :
-                transformIntermediateResponse( codecMessage, msg );
+            case INTERMEDIATE_RESPONSE :
+                codecMessage = transformIntermediateResponse( msg );
                 break;
         }
 
+        codecMessage.setMessageId( msg.getMessageId() );
+
         // We also have to transform the controls...
         if ( !msg.getControls().isEmpty() )
         {

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/MessageTypeEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/MessageTypeEnum.java?rev=910150&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/MessageTypeEnum.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/MessageTypeEnum.java Mon Feb 15 01:37:34 2010
@@ -0,0 +1,62 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.codec;
+
+/**
+ * An enum to store the Ldap message type.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public enum MessageTypeEnum
+{
+    ABANDON_REQUEST(0),
+    ADD_REQUEST (1),
+    ADD_RESPONSE(2),
+    BIND_REQUEST(3),
+    BIND_RESPONSE(4),
+    COMPARE_REQUEST(5),
+    COMPARE_RESPONSE(6),
+    DEL_REQUEST(7),
+    DEL_RESPONSE(8),
+    EXTENDED_REQUEST(9),
+    EXTENDED_RESPONSE(10),
+    MODIFYDN_REQUEST(11),
+    MODIFYDN_RESPONSE(12),
+    MODIFY_REQUEST(13),
+    MODIFY_RESPONSE(14),
+    SEARCH_REQUEST(15),
+    SEARCH_RESULT_DONE(16),
+    SEARCH_RESULT_ENTRY(17),
+    SEARCH_RESULT_REFERENCE(18),
+    UNBIND_REQUEST(19),
+    INTERMEDIATE_RESPONSE(20);
+
+    /** The internal value */
+    private int value;
+    
+    /** The message Type name */
+    private String name;
+    
+    private MessageTypeEnum( int value )
+    {
+        this.value = value;
+    }
+}



Mime
View raw message