directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1064981 [6/8] - in /directory: apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/ apacheds/trunk/protocol-ldap/src/main/java/org/apach...
Date Sat, 29 Jan 2011 08:23:06 GMT
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/CompareResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/CompareResponseDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/CompareResponseDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/CompareResponseDecorator.java Sat Jan 29 08:23:02 2011
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.message.CompareResponse;
 
@@ -35,7 +36,8 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CompareResponseDecorator extends ResponseDecorator implements CompareResponse
+public class CompareResponseDecorator extends ResponseDecorator<CompareResponse> 
+    implements CompareResponse
 {
     /** The encoded compareResponse length */
     private int compareResponseLength;
@@ -46,18 +48,9 @@ public class CompareResponseDecorator ex
      *
      * @param decoratedMessage the decorated CompareResponse
      */
-    public CompareResponseDecorator( CompareResponse decoratedMessage )
+    public CompareResponseDecorator( ILdapCodecService codec, CompareResponse decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated CompareResponse
-     */
-    public CompareResponse getCompareResponse()
-    {
-        return ( CompareResponse ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -83,18 +76,22 @@ public class CompareResponseDecorator ex
     //-------------------------------------------------------------------------
     // The CompareResponse methods
     //-------------------------------------------------------------------------
+
+    
     /**
      * {@inheritDoc}
      */
     public boolean isTrue()
     {
-        return getCompareResponse().isTrue();
+        return getDecorated().isTrue();
     }
 
     
     //-------------------------------------------------------------------------
     // The Decorator methods
     //-------------------------------------------------------------------------
+    
+
     /**
      * Compute the CompareResponse length 
      * 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/DeleteRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/DeleteRequestDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/DeleteRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/DeleteRequestDecorator.java Sat Jan 29 08:23:02 2011
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.message.DeleteRequest;
 import org.apache.directory.shared.ldap.model.name.Dn;
@@ -36,37 +37,31 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DeleteRequestDecorator extends SingleReplyRequestDecorator implements DeleteRequest
+public class DeleteRequestDecorator extends SingleReplyRequestDecorator<DeleteRequest> 
+    implements DeleteRequest
 {
     /**
      * Makes a DeleteRequest a MessageDecorator.
      *
      * @param decoratedMessage the decorated DeleteRequest
      */
-    public DeleteRequestDecorator( DeleteRequest decoratedMessage )
+    public DeleteRequestDecorator( ILdapCodecService codec, DeleteRequest decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated DeleteRequest
-     */
-    public DeleteRequest getDeleteRequest()
-    {
-        return ( DeleteRequest ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
     //-------------------------------------------------------------------------
     // The DeleteRequest methods
     //-------------------------------------------------------------------------
+
+    
     /**
      * {@inheritDoc}
      */
     public Dn getName()
     {
-        return getDeleteRequest().getName();
+        return getDecorated().getName();
     }
 
 
@@ -75,7 +70,7 @@ public class DeleteRequestDecorator exte
      */
     public void setName( Dn name )
     {
-        getDeleteRequest().setName( name );
+        getDecorated().setName( name );
     }
 
     

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/DeleteResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/DeleteResponseDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/DeleteResponseDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/DeleteResponseDecorator.java Sat Jan 29 08:23:02 2011
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.message.DeleteResponse;
 
@@ -35,7 +36,8 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DeleteResponseDecorator extends ResponseDecorator implements DeleteResponse
+public class DeleteResponseDecorator extends ResponseDecorator<DeleteResponse> 
+    implements DeleteResponse
 {
     /** The encoded deleteResponse length */
     private int deleteResponseLength;
@@ -46,18 +48,9 @@ public class DeleteResponseDecorator ext
      *
      * @param decoratedMessage the decorated DeleteResponse
      */
-    public DeleteResponseDecorator( DeleteResponse decoratedMessage )
+    public DeleteResponseDecorator( ILdapCodecService codec, DeleteResponse decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated DeleteResponse
-     */
-    public DeleteResponse getDeleteResponse()
-    {
-        return ( DeleteResponse ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -83,6 +76,8 @@ public class DeleteResponseDecorator ext
     //-------------------------------------------------------------------------
     // The Decorator methods
     //-------------------------------------------------------------------------
+    
+    
     /**
      * Compute the DelResponse length 
      * 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ExtendedRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ExtendedRequestDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ExtendedRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ExtendedRequestDecorator.java Sat Jan 29 08:23:02 2011
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
 import org.apache.directory.shared.util.Strings;
@@ -36,7 +37,8 @@ import org.apache.directory.shared.util.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ExtendedRequestDecorator extends SingleReplyRequestDecorator implements ExtendedRequest
+public class ExtendedRequestDecorator extends SingleReplyRequestDecorator<ExtendedRequest> 
+    implements ExtendedRequest
 {
     /** The extended request length */
     private int extendedRequestLength;
@@ -50,18 +52,9 @@ public class ExtendedRequestDecorator ex
      *
      * @param decoratedMessage the decorated ExtendedRequest
      */
-    public ExtendedRequestDecorator( ExtendedRequest decoratedMessage )
+    public ExtendedRequestDecorator( ILdapCodecService codec, ExtendedRequest decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated ExtendedRequest
-     */
-    public ExtendedRequest getExtendedRequest()
-    {
-        return ( ExtendedRequest ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -117,7 +110,7 @@ public class ExtendedRequestDecorator ex
      */
     public String getRequestName()
     {
-        return getExtendedRequest().getRequestName();
+        return getDecorated().getRequestName();
     }
 
 
@@ -126,7 +119,7 @@ public class ExtendedRequestDecorator ex
      */
     public void setRequestName( String oid )
     {
-        getExtendedRequest().setRequestName( oid );
+        getDecorated().setRequestName( oid );
     }
 
 
@@ -135,7 +128,7 @@ public class ExtendedRequestDecorator ex
      */
     public byte[] getRequestValue()
     {
-        return getExtendedRequest().getRequestValue();
+        return getDecorated().getRequestValue();
     }
 
 
@@ -144,13 +137,15 @@ public class ExtendedRequestDecorator ex
      */
     public void setRequestValue( byte[] requestValue )
     {
-        getExtendedRequest().setRequestValue( requestValue );
+        getDecorated().setRequestValue( requestValue );
     }
 
     
     //-------------------------------------------------------------------------
     // The Decorator methods
     //-------------------------------------------------------------------------
+    
+    
     /**
      * Compute the ExtendedRequest length
      * 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ExtendedResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ExtendedResponseDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ExtendedResponseDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ExtendedResponseDecorator.java Sat Jan 29 08:23:02 2011
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
 import org.apache.directory.shared.util.Strings;
@@ -36,7 +37,8 @@ import org.apache.directory.shared.util.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ExtendedResponseDecorator extends ResponseDecorator implements ExtendedResponse
+public class ExtendedResponseDecorator extends ResponseDecorator<ExtendedResponse> 
+    implements ExtendedResponse
 {
     private static final long serialVersionUID = -9029282485890195506L;
 
@@ -52,18 +54,9 @@ public class ExtendedResponseDecorator e
      *
      * @param decoratedMessage the decorated ExtendedResponse
      */
-    public ExtendedResponseDecorator( ExtendedResponse decoratedMessage )
+    public ExtendedResponseDecorator( ILdapCodecService codec, ExtendedResponse decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated ExtendedResponse
-     */
-    public ExtendedResponse getExtendedResponse()
-    {
-        return ( ExtendedResponse ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -119,7 +112,7 @@ public class ExtendedResponseDecorator e
      */
     public byte[] getEncodedValue()
     {
-        return getExtendedResponse().getEncodedValue();
+        return getDecorated().getEncodedValue();
     }
 
 
@@ -128,7 +121,7 @@ public class ExtendedResponseDecorator e
      */
     public String getID()
     {
-        return getExtendedResponse().getID();
+        return getDecorated().getID();
     }
 
 
@@ -137,7 +130,7 @@ public class ExtendedResponseDecorator e
      */
     public String getResponseName()
     {
-        return getExtendedResponse().getResponseName();
+        return getDecorated().getResponseName();
     }
 
 
@@ -146,7 +139,7 @@ public class ExtendedResponseDecorator e
      */
     public void setResponseName( String oid )
     {
-        getExtendedResponse().setResponseName( oid );
+        getDecorated().setResponseName( oid );
     }
 
 
@@ -155,7 +148,7 @@ public class ExtendedResponseDecorator e
      */
     public byte[] getResponseValue()
     {
-        return getExtendedResponse().getEncodedValue();
+        return getDecorated().getEncodedValue();
     }
 
 
@@ -164,7 +157,7 @@ public class ExtendedResponseDecorator e
      */
     public void setResponseValue( byte[] responseValue )
     {
-        getExtendedResponse().setResponseValue( responseValue );
+        getDecorated().setResponseValue( responseValue );
     }
 
     
@@ -192,7 +185,7 @@ public class ExtendedResponseDecorator e
      */
     public int computeLength()
     {
-        int ldapResultLength = ((LdapResultDecorator)getLdapResult()).computeLength();
+        int ldapResultLength = ( (LdapResultDecorator) getLdapResult() ).computeLength();
 
         int extendedResponseLength = ldapResultLength;
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/IntermediateResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/IntermediateResponseDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/IntermediateResponseDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/IntermediateResponseDecorator.java Sat Jan 29 08:23:02 2011
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.message.IntermediateResponse;
 import org.apache.directory.shared.util.Strings;
@@ -36,7 +37,8 @@ import org.apache.directory.shared.util.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class IntermediateResponseDecorator extends ResponseDecorator implements IntermediateResponse
+public class IntermediateResponseDecorator extends MessageDecorator<IntermediateResponse> 
+    implements IntermediateResponse
 {
     /** The response name as a byte[] */
     private byte[] responseNameBytes;
@@ -50,18 +52,9 @@ public class IntermediateResponseDecorat
      *
      * @param decoratedMessage the decorated IntermediateResponse
      */
-    public IntermediateResponseDecorator( IntermediateResponse decoratedMessage )
+    public IntermediateResponseDecorator( ILdapCodecService codec, IntermediateResponse decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated IntermediateResponse
-     */
-    public IntermediateResponse getIntermediateResponse()
-    {
-        return ( IntermediateResponse ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -117,7 +110,7 @@ public class IntermediateResponseDecorat
      */
     public String getResponseName()
     {
-        return getIntermediateResponse().getResponseName();
+        return getDecorated().getResponseName();
     }
 
 
@@ -126,7 +119,7 @@ public class IntermediateResponseDecorat
      */
     public void setResponseName( String oid )
     {
-        getIntermediateResponse().setResponseName( oid );
+        getDecorated().setResponseName( oid );
     }
 
 
@@ -135,7 +128,7 @@ public class IntermediateResponseDecorat
      */
     public byte[] getResponseValue()
     {
-        return getIntermediateResponse().getResponseValue();
+        return getDecorated().getResponseValue();
     }
 
 
@@ -144,7 +137,7 @@ public class IntermediateResponseDecorat
      */
     public void setResponseValue( byte[] value )
     {
-        getIntermediateResponse().setResponseValue( value );
+        getDecorated().setResponseValue( value );
     }
     
     

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/LdapResultDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/LdapResultDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/LdapResultDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/LdapResultDecorator.java Sat Jan 29 08:23:02 2011
@@ -28,6 +28,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.IDecorator;
 import org.apache.directory.shared.ldap.codec.LdapEncoder;
 import org.apache.directory.shared.ldap.model.message.LdapResult;
 import org.apache.directory.shared.ldap.model.message.Referral;
@@ -41,7 +42,7 @@ import org.apache.directory.shared.util.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapResultDecorator implements LdapResult, Decorator
+public class LdapResultDecorator implements LdapResult, IDecorator<LdapResult>
 {
     /** The decorated LdapResult */
     private final LdapResult decoratedLdapResult;
@@ -65,15 +66,6 @@ public class LdapResultDecorator impleme
 
 
     /**
-     * @return The decorated LdapResult
-     */
-    public LdapResult getLdapResult()
-    {
-        return decoratedLdapResult;
-    }
-
-
-    /**
      * @return The encoded Error message
      */
     public  byte[] getErrorMessageBytes()
@@ -311,4 +303,11 @@ public class LdapResultDecorator impleme
 
         return buffer;
     }
+
+
+    
+    public LdapResult getDecorated()
+    {
+        return decoratedLdapResult;
+    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/MessageDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/MessageDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/MessageDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/MessageDecorator.java Sat Jan 29 08:23:02 2011
@@ -20,9 +20,14 @@
 package org.apache.directory.shared.ldap.codec.decorators;
 
 
+import java.nio.ByteBuffer;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.ldap.codec.ICodecControl;
+import org.apache.directory.shared.ldap.codec.IDecorator;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.controls.ControlDecorator;
 import org.apache.directory.shared.ldap.model.exception.MessageException;
 import org.apache.directory.shared.ldap.model.message.AbandonRequest;
@@ -57,10 +62,10 @@ import org.apache.directory.shared.ldap.
  * @TODO make this class abstract, after finishing switch and all types and make default blow an EncoderException
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class MessageDecorator implements Message, Decorator
+public abstract class MessageDecorator<E extends Message> implements Message, IDecorator<E>
 {
     /** The decorated Control */
-    private final Message decoratedMessage;
+    private final E decoratedMessage;
 
     /** Map of message controls using OID Strings for keys and Control values */
     private final Map<String, Control> controls;
@@ -72,102 +77,105 @@ public abstract class MessageDecorator i
     private int controlsLength;
 
     /** The current control */
-    private Control currentControl;
+    private ICodecControl<? extends Control> currentControl;
+    
+    /** The LdapCodecService */
+    private final ILdapCodecService codec;
 
     
-    public static MessageDecorator getDecorator( Message decoratedMessage )
+    public static MessageDecorator<? extends Message> getDecorator( ILdapCodecService codec, Message decoratedMessage )
     {
         if ( decoratedMessage instanceof MessageDecorator )
         {
-            return (MessageDecorator)decoratedMessage;
+            return ( MessageDecorator<?> ) decoratedMessage;
         }
         
-        MessageDecorator decorator = null;
+        MessageDecorator<?> decorator = null;
         
         switch ( decoratedMessage.getType() )
         {
             case ABANDON_REQUEST:
-                decorator = new AbandonRequestDecorator( ( AbandonRequest ) decoratedMessage );
+                decorator = new AbandonRequestDecorator( codec, ( AbandonRequest ) decoratedMessage );
                 break;
 
             case ADD_REQUEST:
-                decorator = new AddRequestDecorator( ( AddRequest ) decoratedMessage );
+                decorator = new AddRequestDecorator( codec, ( AddRequest ) decoratedMessage );
                 break;
                 
             case ADD_RESPONSE:
-                decorator = new AddResponseDecorator( ( AddResponse ) decoratedMessage );
+                decorator = new AddResponseDecorator( codec, ( AddResponse ) decoratedMessage );
                 break;
                 
             case BIND_REQUEST:
-                decorator = new BindRequestDecorator( ( BindRequest ) decoratedMessage );
+                decorator = new BindRequestDecorator( codec, ( BindRequest ) decoratedMessage );
                 break;
                 
             case BIND_RESPONSE:
-                decorator = new BindResponseDecorator( ( BindResponse ) decoratedMessage );
+                decorator = new BindResponseDecorator( codec, ( BindResponse ) decoratedMessage );
                 break;
                 
             case COMPARE_REQUEST:
-                decorator = new CompareRequestDecorator( ( CompareRequest ) decoratedMessage );
+                decorator = new CompareRequestDecorator( codec, ( CompareRequest ) decoratedMessage );
                 break;
                 
             case COMPARE_RESPONSE:
-                decorator = new CompareResponseDecorator( ( CompareResponse ) decoratedMessage );
+                decorator = new CompareResponseDecorator( codec, ( CompareResponse ) decoratedMessage );
                 break;
                 
             case DEL_REQUEST:
-                decorator = new DeleteRequestDecorator( ( DeleteRequest ) decoratedMessage );
+                decorator = new DeleteRequestDecorator( codec, ( DeleteRequest ) decoratedMessage );
                 break;
 
             case DEL_RESPONSE:
-                decorator = new DeleteResponseDecorator( ( DeleteResponse ) decoratedMessage );
+                decorator = new DeleteResponseDecorator( codec, ( DeleteResponse ) decoratedMessage );
                 break;
                 
             case EXTENDED_REQUEST:
-                decorator = new ExtendedRequestDecorator( ( ExtendedRequest ) decoratedMessage );
+                decorator = new ExtendedRequestDecorator( codec, ( ExtendedRequest ) decoratedMessage );
                 break;
                 
             case EXTENDED_RESPONSE:
-                decorator = new ExtendedResponseDecorator( ( ExtendedResponse ) decoratedMessage );
+                decorator = new ExtendedResponseDecorator( codec, ( ExtendedResponse ) decoratedMessage );
                 break;
                 
             case INTERMEDIATE_RESPONSE:
-                decorator = new IntermediateResponseDecorator( ( IntermediateResponse ) decoratedMessage );
+                decorator = new IntermediateResponseDecorator( codec, ( IntermediateResponse ) decoratedMessage );
                 break;
                 
             case MODIFY_REQUEST:
-                decorator = new ModifyRequestDecorator( ( ModifyRequest ) decoratedMessage );
+                decorator = new ModifyRequestDecorator( codec, ( ModifyRequest ) decoratedMessage );
                 break;
                 
             case MODIFY_RESPONSE:
-                decorator = new ModifyResponseDecorator( ( ModifyResponse ) decoratedMessage );
+                decorator = new ModifyResponseDecorator( codec, ( ModifyResponse ) decoratedMessage );
                 break;
                 
             case MODIFYDN_REQUEST:
-                decorator = new ModifyDnRequestDecorator( ( ModifyDnRequest ) decoratedMessage );
+                decorator = new ModifyDnRequestDecorator( codec, ( ModifyDnRequest ) decoratedMessage );
                 break;
                 
             case MODIFYDN_RESPONSE:
-                decorator = new ModifyDnResponseDecorator( ( ModifyDnResponse ) decoratedMessage );
+                decorator = new ModifyDnResponseDecorator( codec, ( ModifyDnResponse ) decoratedMessage );
                 break;
                 
             case SEARCH_REQUEST:
-                decorator = new SearchRequestDecorator( ( SearchRequest ) decoratedMessage );
+                decorator = new SearchRequestDecorator( codec, ( SearchRequest ) decoratedMessage );
                 break;
                 
             case SEARCH_RESULT_DONE:
-                decorator = new SearchResultDoneDecorator( ( SearchResultDone ) decoratedMessage );
+                decorator = new SearchResultDoneDecorator( codec, ( SearchResultDone ) decoratedMessage );
                 break;
                 
             case SEARCH_RESULT_ENTRY:
-                decorator = new SearchResultEntryDecorator( ( SearchResultEntry ) decoratedMessage );
+                decorator = new SearchResultEntryDecorator( codec, ( SearchResultEntry ) decoratedMessage );
                 break;
                 
             case SEARCH_RESULT_REFERENCE:
-                decorator = new SearchResultReferenceDecorator( ( SearchResultReference ) decoratedMessage );
+                decorator = new SearchResultReferenceDecorator( codec, ( SearchResultReference ) decoratedMessage );
                 break;
             
             case UNBIND_REQUEST:
-                decorator = new UnbindRequestDecorator( ( UnbindRequest ) decoratedMessage );
+                decorator = new UnbindRequestDecorator( codec, ( UnbindRequest ) decoratedMessage );
                 break;
                 
             default :
@@ -180,9 +188,7 @@ public abstract class MessageDecorator i
         {
             for ( Control control : controls.values() )
             {
-                Control controlDecorator = ControlDecorator.getDecorator( control );
-                
-                decorator.addControl( controlDecorator );
+                decorator.addControl( control );
             }
         }
         
@@ -193,23 +199,15 @@ public abstract class MessageDecorator i
     /**
      * Makes a Message an Decorator object.
      */
-    protected MessageDecorator( Message decoratedMessage )
+    protected MessageDecorator( ILdapCodecService codec, E decoratedMessage )
     {
+        this.codec = codec;
         this.decoratedMessage = decoratedMessage;
         controls = new HashMap<String, Control>();
     }
 
 
     /**
-     * @return The decorated LDAP Message
-     */
-    public Message getDecoratedMessage()
-    {
-        return decoratedMessage;
-    }
-
-
-    /**
      * @param controlsLength the encoded controls length
      */
     public void setControlsLength( int controlsLength )
@@ -250,7 +248,7 @@ public abstract class MessageDecorator i
      * 
      * @return The current Control Object
      */
-    public Control getCurrentControl()
+    public ICodecControl<? extends Control> getCurrentControl()
     {
         return currentControl;
     }
@@ -259,6 +257,8 @@ public abstract class MessageDecorator i
     //-------------------------------------------------------------------------
     // The Message methods
     //-------------------------------------------------------------------------
+    
+    
     /**
      * {@inheritDoc}
      */
@@ -298,13 +298,26 @@ public abstract class MessageDecorator i
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("unchecked")
     public void addControl( Control control ) throws MessageException
     {
-        ControlDecorator controlDecorator = (ControlDecorator)control;
-        Control decoratedControl = controlDecorator.getDecorated();
-        decoratedMessage.addControl( decoratedControl );
-        controls.put( control.getOid(), control );
-        currentControl = control;
+        Control decorated;
+        ICodecControl<? extends Control> controlDecorator;
+        
+        if ( control instanceof ControlDecorator )
+        {
+            controlDecorator = ( ICodecControl<? extends Control> ) control;
+            decorated = controlDecorator.getDecorated();
+        }
+        else
+        {
+            controlDecorator = codec.decorate( control );
+            decorated = control;
+        }
+        
+        decoratedMessage.addControl( decorated );
+        controls.put( control.getOid(), controlDecorator );
+        currentControl = controlDecorator;
     }
 
 
@@ -315,8 +328,7 @@ public abstract class MessageDecorator i
     {
         for ( Control control : controls )
         {
-            decoratedMessage.addControl( ((ControlDecorator)control).getDecorated() );
-            this.controls.put( control.getOid(), control );
+            addControl( control );
         }
     }
 
@@ -374,4 +386,22 @@ public abstract class MessageDecorator i
     {
         return decoratedMessage.toString();
     }
+
+
+    public E getDecorated()
+    {
+        return decoratedMessage;
+    }
+
+
+    public int computeLength()
+    {
+        return 0;
+    }
+
+
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        return null;
+    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyDnRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyDnRequestDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyDnRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyDnRequestDecorator.java Sat Jan 29 08:23:02 2011
@@ -27,6 +27,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.message.ModifyDnRequest;
 import org.apache.directory.shared.ldap.model.name.Dn;
@@ -39,7 +40,8 @@ import org.apache.directory.shared.util.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ModifyDnRequestDecorator extends SingleReplyRequestDecorator implements ModifyDnRequest
+public class ModifyDnRequestDecorator extends SingleReplyRequestDecorator<ModifyDnRequest> 
+    implements ModifyDnRequest
 {
     /** The modify Dn request length */
     private int modifyDnRequestLength;
@@ -50,18 +52,9 @@ public class ModifyDnRequestDecorator ex
      *
      * @param decoratedMessage the decorated ModifyDnRequest
      */
-    public ModifyDnRequestDecorator( ModifyDnRequest decoratedMessage )
+    public ModifyDnRequestDecorator( ILdapCodecService codec, ModifyDnRequest decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated ModifyDnRequest
-     */
-    public ModifyDnRequest getModifyDnRequest()
-    {
-        return ( ModifyDnRequest ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -94,7 +87,7 @@ public class ModifyDnRequestDecorator ex
      */
     public Dn getName()
     {
-        return getModifyDnRequest().getName();
+        return getDecorated().getName();
     }
 
 
@@ -103,7 +96,7 @@ public class ModifyDnRequestDecorator ex
      */
     public void setName( Dn name )
     {
-        getModifyDnRequest().setName( name );
+        getDecorated().setName( name );
     }
 
 
@@ -112,7 +105,7 @@ public class ModifyDnRequestDecorator ex
      */
     public Rdn getNewRdn()
     {
-        return getModifyDnRequest().getNewRdn();
+        return getDecorated().getNewRdn();
     }
 
 
@@ -121,7 +114,7 @@ public class ModifyDnRequestDecorator ex
      */
     public void setNewRdn( Rdn newRdn )
     {
-        getModifyDnRequest().setNewRdn( newRdn );
+        getDecorated().setNewRdn( newRdn );
     }
 
 
@@ -130,7 +123,7 @@ public class ModifyDnRequestDecorator ex
      */
     public boolean getDeleteOldRdn()
     {
-        return getModifyDnRequest().getDeleteOldRdn();
+        return getDecorated().getDeleteOldRdn();
     }
 
 
@@ -139,7 +132,7 @@ public class ModifyDnRequestDecorator ex
      */
     public void setDeleteOldRdn( boolean deleteOldRdn )
     {
-        getModifyDnRequest().setDeleteOldRdn( deleteOldRdn );
+        getDecorated().setDeleteOldRdn( deleteOldRdn );
     }
 
 
@@ -148,7 +141,7 @@ public class ModifyDnRequestDecorator ex
      */
     public Dn getNewSuperior()
     {
-        return getModifyDnRequest().getNewSuperior();
+        return getDecorated().getNewSuperior();
     }
 
 
@@ -157,7 +150,7 @@ public class ModifyDnRequestDecorator ex
      */
     public void setNewSuperior( Dn newSuperior )
     {
-        getModifyDnRequest().setNewSuperior( newSuperior );
+        getDecorated().setNewSuperior( newSuperior );
     }
 
 
@@ -166,13 +159,15 @@ public class ModifyDnRequestDecorator ex
      */
     public boolean isMove()
     {
-        return getModifyDnRequest().isMove();
+        return getDecorated().isMove();
     }
 
     
     //-------------------------------------------------------------------------
     // The Decorator methods
     //-------------------------------------------------------------------------
+    
+    
     /**
      * Compute the ModifyDNRequest length
      * 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyDnResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyDnResponseDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyDnResponseDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyDnResponseDecorator.java Sat Jan 29 08:23:02 2011
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.message.ModifyDnResponse;
 
@@ -35,7 +36,8 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ModifyDnResponseDecorator extends ResponseDecorator implements ModifyDnResponse
+public class ModifyDnResponseDecorator extends ResponseDecorator<ModifyDnResponse> 
+    implements ModifyDnResponse
 {
     /** The encoded modifyDnResponse length */
     private int modifyDnResponseLength;
@@ -46,18 +48,9 @@ public class ModifyDnResponseDecorator e
      *
      * @param decoratedMessage the decorated ModifyDnResponse
      */
-    public ModifyDnResponseDecorator( ModifyDnResponse decoratedMessage )
+    public ModifyDnResponseDecorator( ILdapCodecService codec, ModifyDnResponse decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated ModifyDnResponse
-     */
-    public ModifyDnResponse getModifyDnResponse()
-    {
-        return ( ModifyDnResponse ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyRequestDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyRequestDecorator.java Sat Jan 29 08:23:02 2011
@@ -31,6 +31,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntryAttribute;
 import org.apache.directory.shared.ldap.model.entry.DefaultModification;
@@ -46,7 +47,8 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ModifyRequestDecorator extends SingleReplyRequestDecorator implements ModifyRequest
+public class ModifyRequestDecorator extends SingleReplyRequestDecorator<ModifyRequest>
+    implements ModifyRequest
 {
     /** The modify request length */
     private int modifyRequestLength;
@@ -76,18 +78,9 @@ public class ModifyRequestDecorator exte
      *
      * @param decoratedMessage the decorated ModifyRequest
      */
-    public ModifyRequestDecorator( ModifyRequest decoratedMessage )
+    public ModifyRequestDecorator( ILdapCodecService codec, ModifyRequest decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated ModifyRequest
-     */
-    public ModifyRequest getModifyRequest()
-    {
-        return ( ModifyRequest ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -202,7 +195,7 @@ public class ModifyRequestDecorator exte
         currentAttribute = new DefaultEntryAttribute( type );
 
         Modification modification = new DefaultModification( currentOperation, currentAttribute );
-        ((ModifyRequest)getDecoratedMessage()).addModification( modification );
+        getDecorated().addModification( modification );
     }
 
 
@@ -247,7 +240,7 @@ public class ModifyRequestDecorator exte
      */
     public Dn getName()
     {
-        return getModifyRequest().getName();
+        return getDecorated().getName();
     }
 
 
@@ -256,7 +249,7 @@ public class ModifyRequestDecorator exte
      */
     public void setName( Dn name )
     {
-        getModifyRequest().setName( name );
+        getDecorated().setName( name );
     }
 
 
@@ -265,7 +258,7 @@ public class ModifyRequestDecorator exte
      */
     public Collection<Modification> getModifications()
     {
-        return getModifyRequest().getModifications();
+        return getDecorated().getModifications();
     }
 
 
@@ -274,7 +267,7 @@ public class ModifyRequestDecorator exte
      */
     public void addModification( Modification mod )
     {
-        getModifyRequest().addModification( mod );
+        getDecorated().addModification( mod );
     }
 
 
@@ -283,7 +276,7 @@ public class ModifyRequestDecorator exte
      */
     public void removeModification( Modification mod )
     {
-        getModifyRequest().removeModification( mod );
+        getDecorated().removeModification( mod );
     }
 
 
@@ -292,7 +285,7 @@ public class ModifyRequestDecorator exte
      */
     public void remove( String attributeName, String... attributeValue )
     {
-        getModifyRequest().remove( attributeName, attributeValue );
+        getDecorated().remove( attributeName, attributeValue );
     }
 
 
@@ -301,7 +294,7 @@ public class ModifyRequestDecorator exte
      */
     public void remove( String attributeName, byte[]... attributeValue )
     {
-        getModifyRequest().remove( attributeName, attributeValue );
+        getDecorated().remove( attributeName, attributeValue );
     }
 
 
@@ -310,7 +303,7 @@ public class ModifyRequestDecorator exte
      */
     public void remove( EntryAttribute attr )
     {
-        getModifyRequest().remove( attr );
+        getDecorated().remove( attr );
     }
 
 
@@ -319,7 +312,7 @@ public class ModifyRequestDecorator exte
      */
     public void addModification( EntryAttribute attr, ModificationOperation modOp )
     {
-        getModifyRequest().addModification( attr, modOp );
+        getDecorated().addModification( attr, modOp );
     }
 
 
@@ -328,7 +321,7 @@ public class ModifyRequestDecorator exte
      */
     public void add( String attributeName, String... attributeValue )
     {
-        getModifyRequest().add( attributeName, attributeValue );
+        getDecorated().add( attributeName, attributeValue );
     }
 
 
@@ -337,7 +330,7 @@ public class ModifyRequestDecorator exte
      */
     public void add( String attributeName, byte[]... attributeValue )
     {
-        getModifyRequest().add( attributeName, attributeValue );
+        getDecorated().add( attributeName, attributeValue );
     }
 
 
@@ -346,7 +339,7 @@ public class ModifyRequestDecorator exte
      */
     public void add( EntryAttribute attr )
     {
-        getModifyRequest().add( attr );
+        getDecorated().add( attr );
     }
 
 
@@ -355,7 +348,7 @@ public class ModifyRequestDecorator exte
      */
     public void replace( String attributeName )
     {
-        getModifyRequest().replace( attributeName );
+        getDecorated().replace( attributeName );
     }
 
 
@@ -364,7 +357,7 @@ public class ModifyRequestDecorator exte
      */
     public void replace( String attributeName, String... attributeValue )
     {
-        getModifyRequest().replace( attributeName, attributeValue );
+        getDecorated().replace( attributeName, attributeValue );
     }
 
 
@@ -373,7 +366,7 @@ public class ModifyRequestDecorator exte
      */
     public void replace( String attributeName, byte[]... attributeValue )
     {
-        getModifyRequest().replace( attributeName, attributeValue );
+        getDecorated().replace( attributeName, attributeValue );
     }
 
 
@@ -382,13 +375,15 @@ public class ModifyRequestDecorator exte
      */
     public void replace( EntryAttribute attr )
     {
-        getModifyRequest().replace( attr );
+        getDecorated().replace( attr );
     }
 
 
     //-------------------------------------------------------------------------
     // The Decorator methods
     //-------------------------------------------------------------------------
+    
+    
     /**
      * Compute the ModifyRequest length 
      * 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyResponseDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyResponseDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyResponseDecorator.java Sat Jan 29 08:23:02 2011
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.message.ModifyResponse;
 
@@ -35,7 +36,8 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ModifyResponseDecorator extends ResponseDecorator implements ModifyResponse
+public class ModifyResponseDecorator extends ResponseDecorator<ModifyResponse> 
+    implements ModifyResponse
 {
     /** The encoded modifyResponse length */
     private int modifyResponseLength;
@@ -46,18 +48,9 @@ public class ModifyResponseDecorator ext
      *
      * @param decoratedMessage the decorated ModifyResponse
      */
-    public ModifyResponseDecorator( ModifyResponse decoratedMessage )
+    public ModifyResponseDecorator( ILdapCodecService codec, ModifyResponse decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated ModifyResponse
-     */
-    public ModifyResponse getModifyResponse()
-    {
-        return ( ModifyResponse ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -83,6 +76,8 @@ public class ModifyResponseDecorator ext
     //-------------------------------------------------------------------------
     // The Decorator methods
     //-------------------------------------------------------------------------
+    
+    
     /**
      * Compute the ModifyResponse length 
      * 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/RequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/RequestDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/RequestDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/RequestDecorator.java Sat Jan 29 08:23:02 2011
@@ -20,7 +20,7 @@
 package org.apache.directory.shared.ldap.codec.decorators;
 
 
-import org.apache.directory.shared.ldap.model.message.Message;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.message.Request;
 
 
@@ -29,16 +29,16 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class RequestDecorator extends MessageDecorator implements Request
+public abstract class RequestDecorator<M extends Request> extends MessageDecorator<M> implements Request
 {
     /**
      * Makes Request a MessageDecorator.
      *
      * @param decoratedMessage the decorated message
      */
-    public RequestDecorator( Message decoratedMessage )
+    public RequestDecorator( ILdapCodecService codec, M decoratedMessage )
     {
-        super( decoratedMessage );
+        super( codec, decoratedMessage );
     }
     
 
@@ -47,6 +47,6 @@ public abstract class RequestDecorator e
      */
     public boolean hasResponse()
     {
-        return ( ( Request ) getDecoratedMessage() ).hasResponse();
+        return ( getDecorated() ).hasResponse();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ResponseDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ResponseDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ResponseDecorator.java Sat Jan 29 08:23:02 2011
@@ -20,8 +20,8 @@
 package org.apache.directory.shared.ldap.codec.decorators;
 
 
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.message.LdapResult;
-import org.apache.directory.shared.ldap.model.message.Message;
 import org.apache.directory.shared.ldap.model.message.ResultResponse;
 
 
@@ -30,7 +30,7 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class ResponseDecorator extends MessageDecorator implements ResultResponse
+public abstract class ResponseDecorator<M extends ResultResponse> extends MessageDecorator<M> implements ResultResponse
 {
     /** The LdapResult decorator */
     private LdapResultDecorator ldapResultDecorator;
@@ -41,9 +41,9 @@ public abstract class ResponseDecorator 
      *
      * @param decoratedMessage the decorated AddRequest
      */
-    public ResponseDecorator( Message decoratedMessage )
+    public ResponseDecorator( ILdapCodecService codec, M decoratedMessage )
     {
-        super( decoratedMessage );
+        super( codec, decoratedMessage );
         
         ldapResultDecorator = new LdapResultDecorator( ((ResultResponse)decoratedMessage).getLdapResult() );
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ResultResponseRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ResultResponseRequestDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ResultResponseRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ResultResponseRequestDecorator.java Sat Jan 29 08:23:02 2011
@@ -20,8 +20,7 @@
 package org.apache.directory.shared.ldap.codec.decorators;
 
 
-import org.apache.directory.shared.ldap.model.message.Message;
-import org.apache.directory.shared.ldap.model.message.Request;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.message.ResultResponse;
 import org.apache.directory.shared.ldap.model.message.ResultResponseRequest;
 
@@ -31,16 +30,17 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class ResultResponseRequestDecorator extends RequestDecorator implements ResultResponseRequest
+public abstract class ResultResponseRequestDecorator<M extends ResultResponseRequest> 
+    extends RequestDecorator<M> implements ResultResponseRequest
 {
     /**
      * Makes Request a MessageDecorator.
      *
      * @param decoratedMessage the decorated message
      */
-    public ResultResponseRequestDecorator( Message decoratedMessage )
+    public ResultResponseRequestDecorator( ILdapCodecService codec, M decoratedMessage )
     {
-        super( decoratedMessage );
+        super( codec, decoratedMessage );
     }
     
 
@@ -49,7 +49,7 @@ public abstract class ResultResponseRequ
      */
     public boolean hasResponse()
     {
-        return ( ( Request ) getDecoratedMessage() ).hasResponse();
+        return getDecorated().hasResponse();
     }
 
 
@@ -58,6 +58,6 @@ public abstract class ResultResponseRequ
      */
     public ResultResponse getResultResponse()
     {
-        return ( ( ResultResponseRequest ) getDecoratedMessage() ).getResultResponse();
+        return getDecorated().getResultResponse();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java Sat Jan 29 08:23:02 2011
@@ -32,6 +32,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.AttributeValueAssertion;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.search.AndFilter;
@@ -61,8 +62,11 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.filter.SearchScope;
 import org.apache.directory.shared.ldap.model.filter.SimpleNode;
 import org.apache.directory.shared.ldap.model.filter.SubstringNode;
+import org.apache.directory.shared.ldap.model.message.AbandonListener;
 import org.apache.directory.shared.ldap.model.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.model.message.Message;
 import org.apache.directory.shared.ldap.model.message.MessageTypeEnum;
+import org.apache.directory.shared.ldap.model.message.ResultResponse;
 import org.apache.directory.shared.ldap.model.message.SearchRequest;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.util.Strings;
@@ -73,7 +77,7 @@ import org.apache.directory.shared.util.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class SearchRequestDecorator extends AbandonableResultResponseRequestDecorator implements SearchRequest
+public class SearchRequestDecorator extends MessageDecorator<SearchRequest> implements SearchRequest
 {
     /** The searchRequest length */
     private int searchRequestLength;
@@ -99,18 +103,9 @@ public class SearchRequestDecorator exte
      *
      * @param decoratedMessage the decorated SearchRequest
      */
-    public SearchRequestDecorator( SearchRequest decoratedMessage )
+    public SearchRequestDecorator( ILdapCodecService codec, SearchRequest decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated SearchRequest
-     */
-    public SearchRequest getSearchRequest()
-    {
-        return ( SearchRequest ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -226,8 +221,8 @@ public class SearchRequestDecorator exte
      */
     public void setFilter( String filter ) throws LdapException
     {
-        getSearchRequest().setFilter( filter );
-        this.currentFilter = transform( getSearchRequest().getFilter() );
+        getDecorated().setFilter( filter );
+        this.currentFilter = transform( getDecorated().getFilter() );
     }
 
 
@@ -286,9 +281,11 @@ public class SearchRequestDecorator exte
      *
      * @param container The container being decoded
      */
+    @SuppressWarnings("unchecked")
     public void unstackFilters( Asn1Container container )
     {
-        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessageContainer<MessageDecorator<Message>> ldapMessageContainer = 
+            ( LdapMessageContainer<MessageDecorator<Message>> ) container;
 
         TLV tlv = ldapMessageContainer.getCurrentTLV();
         TLV localParent = tlv.getParent();
@@ -640,18 +637,18 @@ public class SearchRequestDecorator exte
     {
         int hash = 37;
 
-        if ( getSearchRequest().getBase() != null )
+        if ( getDecorated().getBase() != null )
         {
-            hash = hash * 17 + getSearchRequest().getBase().hashCode();
+            hash = hash * 17 + getDecorated().getBase().hashCode();
         }
 
-        hash = hash * 17 + getSearchRequest().getDerefAliases().hashCode();
-        hash = hash * 17 + getSearchRequest().getScope().hashCode();
-        hash = hash * 17 + Long.valueOf( getSearchRequest().getSizeLimit() ).hashCode();
-        hash = hash * 17 + getSearchRequest().getTimeLimit();
-        hash = hash * 17 + ( getSearchRequest().getTypesOnly() ? 0 : 1 );
+        hash = hash * 17 + getDecorated().getDerefAliases().hashCode();
+        hash = hash * 17 + getDecorated().getScope().hashCode();
+        hash = hash * 17 + Long.valueOf( getDecorated().getSizeLimit() ).hashCode();
+        hash = hash * 17 + getDecorated().getTimeLimit();
+        hash = hash * 17 + ( getDecorated().getTypesOnly() ? 0 : 1 );
 
-        List<String> attributes = getSearchRequest().getAttributes();
+        List<String> attributes = getDecorated().getAttributes();
         if ( attributes != null )
         {
             hash = hash * 17 + attributes.size();
@@ -664,7 +661,7 @@ public class SearchRequestDecorator exte
         }
 
         BranchNormalizedVisitor visitor = new BranchNormalizedVisitor();
-        getSearchRequest().getFilter().accept( visitor );
+        getDecorated().getFilter().accept( visitor );
         hash = hash * 17 + currentFilter.toString().hashCode();
         hash = hash * 17 + super.hashCode();
 
@@ -698,37 +695,37 @@ public class SearchRequestDecorator exte
 
         SearchRequest req = ( SearchRequest ) obj;
 
-        if ( !req.getBase().equals( getSearchRequest().getBase() ) )
+        if ( !req.getBase().equals( getDecorated().getBase() ) )
         {
             return false;
         }
 
-        if ( req.getDerefAliases() != getSearchRequest().getDerefAliases() )
+        if ( req.getDerefAliases() != getDecorated().getDerefAliases() )
         {
             return false;
         }
 
-        if ( req.getScope() != getSearchRequest().getScope() )
+        if ( req.getScope() != getDecorated().getScope() )
         {
             return false;
         }
 
-        if ( req.getSizeLimit() != getSearchRequest().getSizeLimit() )
+        if ( req.getSizeLimit() != getDecorated().getSizeLimit() )
         {
             return false;
         }
 
-        if ( req.getTimeLimit() != getSearchRequest().getTimeLimit() )
+        if ( req.getTimeLimit() != getDecorated().getTimeLimit() )
         {
             return false;
         }
 
-        if ( req.getTypesOnly() != getSearchRequest().getTypesOnly() )
+        if ( req.getTypesOnly() != getDecorated().getTypesOnly() )
         {
             return false;
         }
 
-        List<String> attributes = getSearchRequest().getAttributes();
+        List<String> attributes = getDecorated().getAttributes();
         if ( req.getAttributes() == null && attributes != null && attributes.size() > 0 )
         {
             return false;
@@ -757,7 +754,7 @@ public class SearchRequestDecorator exte
 
         BranchNormalizedVisitor visitor = new BranchNormalizedVisitor();
         req.getFilter().accept( visitor );
-        getSearchRequest().getFilter().accept( visitor );
+        getDecorated().getFilter().accept( visitor );
 
         String myFilterString = currentFilter.toString();
         String reqFilterString = req.getFilter().toString();
@@ -775,7 +772,7 @@ public class SearchRequestDecorator exte
         StringBuilder sb = new StringBuilder();
 
         sb.append( "    SearchRequest\n" );
-        sb.append( "        baseDn : '" ).append( getSearchRequest().getBase() ).append( "'\n" );
+        sb.append( "        baseDn : '" ).append( getDecorated().getBase() ).append( "'\n" );
 
         if ( currentFilter != null )
         {
@@ -786,7 +783,7 @@ public class SearchRequestDecorator exte
 
         sb.append( "        scope : " );
 
-        switch ( getSearchRequest().getScope() )
+        switch ( getDecorated().getScope() )
         {
             case OBJECT:
                 sb.append( "base object" );
@@ -803,37 +800,37 @@ public class SearchRequestDecorator exte
 
         sb.append( '\n' );
 
-        sb.append( "        typesOnly : " ).append( getSearchRequest().getTypesOnly() ).append( '\n' );
+        sb.append( "        typesOnly : " ).append( getDecorated().getTypesOnly() ).append( '\n' );
 
         sb.append( "        Size Limit : " );
 
-        if ( getSearchRequest().getSizeLimit() == 0L )
+        if ( getDecorated().getSizeLimit() == 0L )
         {
             sb.append( "no limit" );
         }
         else
         {
-            sb.append( getSearchRequest().getSizeLimit() );
+            sb.append( getDecorated().getSizeLimit() );
         }
 
         sb.append( '\n' );
 
         sb.append( "        Time Limit : " );
 
-        if ( getSearchRequest().getTimeLimit() == 0 )
+        if ( getDecorated().getTimeLimit() == 0 )
         {
             sb.append( "no limit" );
         }
         else
         {
-            sb.append( getSearchRequest().getTimeLimit() );
+            sb.append( getDecorated().getTimeLimit() );
         }
 
         sb.append( '\n' );
 
         sb.append( "        Deref Aliases : " );
 
-        switch ( getSearchRequest().getDerefAliases() )
+        switch ( getDecorated().getDerefAliases() )
         {
             case NEVER_DEREF_ALIASES:
                 sb.append( "never Deref Aliases" );
@@ -857,7 +854,7 @@ public class SearchRequestDecorator exte
 
         boolean isFirst = true;
 
-        List<String> attributes = getSearchRequest().getAttributes();
+        List<String> attributes = getDecorated().getAttributes();
         if ( attributes != null )
         {
             for ( String attribute : attributes )
@@ -894,7 +891,7 @@ public class SearchRequestDecorator exte
      */
     public MessageTypeEnum[] getResponseTypes()
     {
-        return getSearchRequest().getResponseTypes();
+        return getDecorated().getResponseTypes();
     }
 
 
@@ -903,7 +900,7 @@ public class SearchRequestDecorator exte
      */
     public Dn getBase()
     {
-        return getSearchRequest().getBase();
+        return getDecorated().getBase();
     }
 
 
@@ -912,7 +909,7 @@ public class SearchRequestDecorator exte
      */
     public void setBase( Dn baseDn )
     {
-        getSearchRequest().setBase( baseDn );
+        getDecorated().setBase( baseDn );
     }
 
 
@@ -921,7 +918,7 @@ public class SearchRequestDecorator exte
      */
     public SearchScope getScope()
     {
-        return getSearchRequest().getScope();
+        return getDecorated().getScope();
     }
 
 
@@ -930,7 +927,7 @@ public class SearchRequestDecorator exte
      */
     public void setScope( SearchScope scope )
     {
-        getSearchRequest().setScope( scope );
+        getDecorated().setScope( scope );
     }
 
 
@@ -939,7 +936,7 @@ public class SearchRequestDecorator exte
      */
     public AliasDerefMode getDerefAliases()
     {
-        return getSearchRequest().getDerefAliases();
+        return getDecorated().getDerefAliases();
     }
 
 
@@ -948,7 +945,7 @@ public class SearchRequestDecorator exte
      */
     public void setDerefAliases( AliasDerefMode aliasDerefAliases )
     {
-        getSearchRequest().setDerefAliases( aliasDerefAliases );
+        getDecorated().setDerefAliases( aliasDerefAliases );
     }
 
 
@@ -957,7 +954,7 @@ public class SearchRequestDecorator exte
      */
     public long getSizeLimit()
     {
-        return getSearchRequest().getSizeLimit();
+        return getDecorated().getSizeLimit();
     }
 
 
@@ -966,7 +963,7 @@ public class SearchRequestDecorator exte
      */
     public void setSizeLimit( long entriesMax )
     {
-        getSearchRequest().setSizeLimit( entriesMax );
+        getDecorated().setSizeLimit( entriesMax );
     }
 
 
@@ -975,7 +972,7 @@ public class SearchRequestDecorator exte
      */
     public int getTimeLimit()
     {
-        return getSearchRequest().getTimeLimit();
+        return getDecorated().getTimeLimit();
     }
 
 
@@ -984,7 +981,7 @@ public class SearchRequestDecorator exte
      */
     public void setTimeLimit( int secondsMax )
     {
-        getSearchRequest().setTimeLimit( secondsMax );
+        getDecorated().setTimeLimit( secondsMax );
     }
 
 
@@ -993,7 +990,7 @@ public class SearchRequestDecorator exte
      */
     public boolean getTypesOnly()
     {
-        return getSearchRequest().getTypesOnly();
+        return getDecorated().getTypesOnly();
     }
 
 
@@ -1002,7 +999,7 @@ public class SearchRequestDecorator exte
      */
     public void setTypesOnly( boolean typesOnly )
     {
-        getSearchRequest().setTypesOnly( typesOnly );
+        getDecorated().setTypesOnly( typesOnly );
     }
 
 
@@ -1011,7 +1008,7 @@ public class SearchRequestDecorator exte
      */
     public ExprNode getFilter()
     {
-        return getSearchRequest().getFilter();
+        return getDecorated().getFilter();
     }
 
 
@@ -1020,7 +1017,7 @@ public class SearchRequestDecorator exte
      */
     public List<String> getAttributes()
     {
-        return getSearchRequest().getAttributes();
+        return getDecorated().getAttributes();
     }
 
 
@@ -1029,7 +1026,7 @@ public class SearchRequestDecorator exte
      */
     public void addAttributes( String... attributes )
     {
-        getSearchRequest().addAttributes( attributes );
+        getDecorated().addAttributes( attributes );
     }
 
 
@@ -1038,13 +1035,15 @@ public class SearchRequestDecorator exte
      */
     public void removeAttribute( String attribute )
     {
-        getSearchRequest().removeAttribute( attribute );
+        getDecorated().removeAttribute( attribute );
     }
 
 
     //-------------------------------------------------------------------------
     // The Decorator methods
     //-------------------------------------------------------------------------
+    
+    
     /**
      * Compute the SearchRequest length
      * 
@@ -1190,4 +1189,34 @@ public class SearchRequestDecorator exte
 
         return buffer;
     }
+
+
+    public ResultResponse getResultResponse()
+    {
+        return getDecorated().getResultResponse();
+    }
+
+
+    public boolean hasResponse()
+    {
+        return getDecorated().hasResponse();
+    }
+
+
+    public void abandon()
+    {
+        getDecorated().abandon();
+    }
+
+
+    public boolean isAbandoned()
+    {
+        return getDecorated().isAbandoned();
+    }
+
+
+    public void addAbandonListener( AbandonListener listener )
+    {
+        getDecorated().addAbandonListener( listener );
+    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultDoneDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultDoneDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultDoneDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultDoneDecorator.java Sat Jan 29 08:23:02 2011
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.message.SearchResultDone;
 
@@ -35,7 +36,7 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class SearchResultDoneDecorator extends ResponseDecorator implements SearchResultDone
+public class SearchResultDoneDecorator extends ResponseDecorator<SearchResultDone> implements SearchResultDone
 {
     /** The encoded searchResultDone length */
     private int searchResultDoneLength;
@@ -46,18 +47,9 @@ public class SearchResultDoneDecorator e
      *
      * @param decoratedMessage the decorated SearchResultDone
      */
-    public SearchResultDoneDecorator( SearchResultDone decoratedMessage )
+    public SearchResultDoneDecorator( ILdapCodecService codec, SearchResultDone decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated SearchResultDone
-     */
-    public SearchResultDone getSearchResultDone()
-    {
-        return ( SearchResultDone ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -83,6 +75,8 @@ public class SearchResultDoneDecorator e
     //-------------------------------------------------------------------------
     // The Decorator methods
     //-------------------------------------------------------------------------
+    
+    
     /**
      * Compute the SearchResultDone length 
      * 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java Sat Jan 29 08:23:02 2011
@@ -31,6 +31,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.util.Asn1StringUtils;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntryAttribute;
 import org.apache.directory.shared.ldap.model.entry.Entry;
@@ -46,7 +47,7 @@ import org.apache.directory.shared.util.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class SearchResultEntryDecorator extends MessageDecorator implements SearchResultEntry
+public class SearchResultEntryDecorator extends MessageDecorator<SearchResultEntry> implements SearchResultEntry
 {
     /** A temporary storage for the byte[] representing the objectName */
     private byte[] objectNameBytes;
@@ -72,18 +73,9 @@ public class SearchResultEntryDecorator 
      *
      * @param decoratedMessage the decorated SearchResultEntry
      */
-    public SearchResultEntryDecorator( SearchResultEntry decoratedMessage )
+    public SearchResultEntryDecorator( ILdapCodecService codec, SearchResultEntry decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated SearchResultEntry
-     */
-    public SearchResultEntry getSearchResultEntry()
-    {
-        return ( SearchResultEntry ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -199,7 +191,7 @@ public class SearchResultEntryDecorator 
     {
         currentAttribute = new DefaultEntryAttribute( type );
 
-        getSearchResultEntry().getEntry().put( currentAttribute );
+        getDecorated().getEntry().put( currentAttribute );
     }
 
 
@@ -231,7 +223,7 @@ public class SearchResultEntryDecorator 
      */
     public Dn getObjectName()
     {
-        return getSearchResultEntry().getObjectName();
+        return getDecorated().getObjectName();
     }
 
 
@@ -240,7 +232,7 @@ public class SearchResultEntryDecorator 
      */
     public void setObjectName( Dn objectName )
     {
-        getSearchResultEntry().setObjectName( objectName );
+        getDecorated().setObjectName( objectName );
     }
 
 
@@ -249,7 +241,7 @@ public class SearchResultEntryDecorator 
      */
     public Entry getEntry()
     {
-        return getSearchResultEntry().getEntry();
+        return getDecorated().getEntry();
     }
 
 
@@ -258,13 +250,15 @@ public class SearchResultEntryDecorator 
      */
     public void setEntry( Entry entry )
     {
-        getSearchResultEntry().setEntry( entry );
+        getDecorated().setEntry( entry );
     }
 
 
     //-------------------------------------------------------------------------
     // The Decorator methods
     //-------------------------------------------------------------------------
+    
+    
     /**
      * Compute the SearchResultEntry length
      * 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultReferenceDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultReferenceDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultReferenceDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultReferenceDecorator.java Sat Jan 29 08:23:02 2011
@@ -27,6 +27,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapEncoder;
 import org.apache.directory.shared.ldap.model.message.Referral;
@@ -38,7 +39,8 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class SearchResultReferenceDecorator extends MessageDecorator implements SearchResultReference
+public class SearchResultReferenceDecorator extends MessageDecorator<SearchResultReference> 
+    implements SearchResultReference
 {
     /** The length of the referral */
     private int referralLength;
@@ -52,18 +54,9 @@ public class SearchResultReferenceDecora
      *
      * @param decoratedMessage the decorated SearchResultReference
      */
-    public SearchResultReferenceDecorator( SearchResultReference decoratedMessage )
+    public SearchResultReferenceDecorator( ILdapCodecService codec, SearchResultReference decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-
-    /**
-     * @return The decorated SearchResultReference
-     */
-    public SearchResultReference getSearchResultReference()
-    {
-        return ( SearchResultReference ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
@@ -115,7 +108,7 @@ public class SearchResultReferenceDecora
      */
     public Referral getReferral()
     {
-        return getSearchResultReference().getReferral();
+        return getDecorated().getReferral();
     }
 
 
@@ -124,13 +117,15 @@ public class SearchResultReferenceDecora
      */
     public void setReferral( Referral referral )
     {
-        getSearchResultReference().setReferral( referral );        
+        getDecorated().setReferral( referral );        
     }
 
 
     //-------------------------------------------------------------------------
     // The Decorator methods
     //-------------------------------------------------------------------------
+    
+    
     /**
      * Compute the SearchResultReference length
      * 
@@ -188,7 +183,7 @@ public class SearchResultReferenceDecora
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
     {
-        SearchResultReference searchResultReference = getSearchResultReference();
+        SearchResultReference searchResultReference = getDecorated();
         try
         {
             // The SearchResultReference Tag

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SingleReplyRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SingleReplyRequestDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SingleReplyRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SingleReplyRequestDecorator.java Sat Jan 29 08:23:02 2011
@@ -20,7 +20,9 @@
 package org.apache.directory.shared.ldap.codec.decorators;
 
 
-import org.apache.directory.shared.ldap.model.message.Message;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
+import org.apache.directory.shared.ldap.model.message.AbandonListener;
+import org.apache.directory.shared.ldap.model.message.AbandonableRequest;
 import org.apache.directory.shared.ldap.model.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.model.message.SingleReplyRequest;
 
@@ -30,16 +32,17 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class SingleReplyRequestDecorator extends AbandonableResultResponseRequestDecorator implements SingleReplyRequest
+public abstract class SingleReplyRequestDecorator<M extends SingleReplyRequest> 
+    extends ResultResponseRequestDecorator<M> implements SingleReplyRequest, AbandonableRequest
 {
     /**
      * Makes Request a MessageDecorator.
      *
      * @param decoratedMessage the decorated message
      */
-    public SingleReplyRequestDecorator( Message decoratedMessage )
+    public SingleReplyRequestDecorator( ILdapCodecService codec, M decoratedMessage )
     {
-        super( decoratedMessage );
+        super( codec, decoratedMessage );
     }
 
     
@@ -48,6 +51,24 @@ public abstract class SingleReplyRequest
      */
     public MessageTypeEnum getResponseType()
     {
-        return ( ( SingleReplyRequest ) getDecoratedMessage() ).getResponseType();
+        return getDecorated().getResponseType();
+    }
+
+
+    public void abandon()
+    {
+        ( ( AbandonableRequest ) getDecorated() ).abandon();
+    }
+
+
+    public boolean isAbandoned()
+    {
+        return ( ( AbandonableRequest ) getDecorated() ).isAbandoned();
+    }
+
+
+    public void addAbandonListener( AbandonListener listener )
+    {
+        ( ( AbandonableRequest ) getDecorated() ).addAbandonListener( listener );
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/UnbindRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/UnbindRequestDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/UnbindRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/UnbindRequestDecorator.java Sat Jan 29 08:23:02 2011
@@ -25,6 +25,7 @@ import java.nio.ByteBuffer;
 
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.model.message.UnbindRequest;
 
@@ -34,33 +35,24 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class UnbindRequestDecorator extends RequestDecorator implements UnbindRequest
+public class UnbindRequestDecorator extends RequestDecorator<UnbindRequest> implements UnbindRequest
 {
     /**
      * Makes Request a MessageDecorator.
      *
      * @param decoratedMessage the decorated message
      */
-    public UnbindRequestDecorator( UnbindRequest decoratedMessage )
+    public UnbindRequestDecorator( ILdapCodecService codec, UnbindRequest decoratedMessage )
     {
-        super( decoratedMessage );
-    }
-
-    
-    /**
-     * Gets the decorated UnbindRequest.
-     *
-     * @return The decorated {@link UnbindRequest}
-     */
-    public UnbindRequest getUnbindRequest()
-    {
-        return ( UnbindRequest ) getDecoratedMessage();
+        super( codec, decoratedMessage );
     }
 
 
     //-------------------------------------------------------------------------
     // The Decorator methods
     //-------------------------------------------------------------------------
+
+    
     /**
      * Compute the UnBindRequest length 
      * 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeDecorator.java?rev=1064981&r1=1064980&r2=1064981&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeDecorator.java Sat Jan 29 08:23:02 2011
@@ -22,7 +22,10 @@ package org.apache.directory.shared.ldap
 
 import java.nio.ByteBuffer;
 
+import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
@@ -42,7 +45,7 @@ import org.apache.directory.shared.util.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class EntryChangeDecorator extends ControlDecorator implements EntryChange
+public class EntryChangeDecorator extends ControlDecorator<EntryChange> implements EntryChange
 {
 
     public static final int UNDEFINED_CHANGE_NUMBER = -1;
@@ -53,14 +56,20 @@ public class EntryChangeDecorator extend
     /** The entry change global length */
     private int eccSeqLength;
 
+    /** The encoded value of the control. */
+    private byte[] value;
+    
+    /** An instance of this decoder */
+    private static final Asn1Decoder decoder = new Asn1Decoder();
 
+    
     /**
      * Creates a new instance of EntryChangeDecoder wrapping a newly created
      * EntryChange Control object.
      */
     public EntryChangeDecorator()
     {
-        super( new EntryChangeImpl(), new EntryChangeDecoder() );
+        super( new EntryChangeImpl() );
     }
 
 
@@ -72,7 +81,7 @@ public class EntryChangeDecorator extend
      */
     public EntryChangeDecorator( EntryChange control )
     {
-        super( control, new EntryChangeDecoder() );
+        super( control );
     }
 
 
@@ -169,7 +178,7 @@ public class EntryChangeDecorator extend
      */
     public byte[] getValue()
     {
-        if ( getDecorated().getValue() == null )
+        if ( value == null )
         {
             try
             {
@@ -193,7 +202,7 @@ public class EntryChangeDecorator extend
                     Value.encode( buffer, getChangeNumber() );
                 }
 
-                getDecorated().setValue( buffer.array() );
+                value = buffer.array();
             }
             catch ( Exception e )
             {
@@ -201,7 +210,7 @@ public class EntryChangeDecorator extend
             }
         }
 
-        return getDecorated().getValue();
+        return value;
     }
 
 
@@ -257,4 +266,14 @@ public class EntryChangeDecorator extend
     {
         getEntryChange().setChangeNumber( changeNumber );
     }
+
+
+    @Override
+    public Asn1Object decode( byte[] controlBytes ) throws DecoderException
+    {
+        ByteBuffer bb = ByteBuffer.wrap( controlBytes );
+        EntryChangeContainer container = new EntryChangeContainer( this );
+        decoder.decode( bb, container );
+        return this;
+    }
 }



Mime
View raw message