directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1067749 - in /directory: apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/ shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/ shared/branches/m1/ldap-client-api/src/main/...
Date Sun, 06 Feb 2011 20:34:58 GMT
Author: akarasulu
Date: Sun Feb  6 20:34:58 2011
New Revision: 1067749

URL: http://svn.apache.org/viewvc?rev=1067749&view=rev
Log:
DIRSHARED-80: 

  o moved protocol codec classes into codec
  o removed references to ldap message container which is more SPI than API
  o the codec is the factory that will yeild access to these interfaces for 
    these kinds of objects to hide the implementation
  o still need to handle generating the server protocol codec factory
    and registration should be used via OSGi bundle activation to 
    register different protocol codec factories, to be used both for
    clients and servers: this can be the mechanism for swapping in and out
    different network API's like mina, grizzly, and netty


Added:
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java
      - copied, changed from r1067704, directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolCodecFactory.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolDecoder.java
      - copied, changed from r1067741, directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolDecoder.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolEncoder.java
      - copied, changed from r1067704, directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java
Removed:
    directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolCodecFactory.java
    directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolDecoder.java
    directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java
Modified:
    directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java
    directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java

Modified: directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java?rev=1067749&r1=1067748&r2=1067749&view=diff
==============================================================================
--- directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java
(original)
+++ directory/apacheds/branches/m1/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java
Sun Feb  6 20:34:58 2011
@@ -20,9 +20,9 @@
 package org.apache.directory.server.ldap;
 
 
-import org.apache.directory.ldap.client.api.protocol.LdapProtocolEncoder;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.shared.ldap.codec.LdapDecoder;
+import org.apache.directory.shared.ldap.codec.protocol.mina.LdapProtocolEncoder;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 import org.apache.mina.filter.codec.ProtocolDecoder;

Modified: directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1067749&r1=1067748&r2=1067749&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
(original)
+++ directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Sun Feb  6 20:34:58 2011
@@ -55,15 +55,11 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.ldap.client.api.future.ModifyFuture;
 import org.apache.directory.ldap.client.api.future.ResponseFuture;
 import org.apache.directory.ldap.client.api.future.SearchFuture;
-import org.apache.directory.ldap.client.api.protocol.LdapProtocolCodecFactory;
 import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.asn1.util.OID;
 import org.apache.directory.shared.ldap.codec.DefaultLdapCodecService;
-import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.MessageEncoderException;
 import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
-import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
 import org.apache.directory.shared.ldap.message.extended.NoticeOfDisconnect;
 import org.apache.directory.shared.ldap.message.extended.nod.AddNoDResponse;
 import org.apache.directory.shared.ldap.message.extended.nod.BindNoDResponse;
@@ -185,9 +181,6 @@ public class LdapNetworkConnection exten
     /** A flag set to true when we used a local connector */
     private boolean localConnector;
 
-    /** The Ldap codec */
-    private IoFilter ldapProtocolFilter = new ProtocolCodecFilter( new LdapProtocolCodecFactory()
);
-
     /**
      * The created session, created when we open a connection with
      * the Ldap server.
@@ -222,6 +215,9 @@ public class LdapNetworkConnection exten
 
     /** the ldap codec service */
     LdapCodecService codec = new DefaultLdapCodecService();
+
+    /** The Ldap codec protocol filter */
+    private IoFilter ldapProtocolFilter = new ProtocolCodecFilter( codec.newProtocolCodecFactory(
true ) );
     
     /** the SslFilter key */
     private static final String SSL_FILTER_KEY = "sslFilter";
@@ -605,11 +601,8 @@ public class LdapNetworkConnection exten
         ldapSession = connectionFuture.getSession();
         connected.set( true );
 
-        // And inject the current Ldap container into the session
-        Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<Message>>(
codec );
-
         // Store the container into the session
-        ldapSession.setAttribute( "LDAP-Container", ldapMessageContainer );
+        ldapSession.setAttribute( "LDAP-Container", codec.newMessageContainer() );
 
         // Initialize the MessageId
         messageId.set( 0 );

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java?rev=1067749&r1=1067748&r2=1067749&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
Sun Feb  6 20:34:58 2011
@@ -28,6 +28,7 @@ import java.util.Map;
 
 import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.ldap.codec.api.CodecControl;
 import org.apache.directory.shared.ldap.codec.api.ControlFactory;
 import org.apache.directory.shared.ldap.codec.api.ExtendedOpFactory;
@@ -38,6 +39,8 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.controls.search.pagedSearch.PagedResultsFactory;
 import org.apache.directory.shared.ldap.codec.controls.search.persistentSearch.PersistentSearchFactory;
 import org.apache.directory.shared.ldap.codec.controls.search.subentries.SubentriesFactory;
+import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
+import org.apache.directory.shared.ldap.codec.protocol.mina.LdapProtocolCodecFactory;
 import org.apache.directory.shared.ldap.extras.controls.PasswordPolicyImpl;
 import org.apache.directory.shared.ldap.extras.controls.SyncDoneValue;
 import org.apache.directory.shared.ldap.extras.controls.SyncInfoValue;
@@ -51,6 +54,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory;
 import org.apache.directory.shared.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory;
 import org.apache.directory.shared.ldap.model.message.Control;
+import org.apache.directory.shared.ldap.model.message.Message;
 import org.apache.directory.shared.ldap.model.message.controls.Cascade;
 import org.apache.directory.shared.ldap.model.message.controls.EntryChange;
 import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
@@ -58,6 +62,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.message.controls.PagedResults;
 import org.apache.directory.shared.ldap.model.message.controls.PersistentSearch;
 import org.apache.directory.shared.ldap.model.message.controls.Subentries;
+import org.apache.directory.shared.util.exception.NotImplementedException;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 
 
@@ -178,10 +183,23 @@ public class DefaultLdapCodecService imp
     
     /**
      * {@inheritDoc}
+     * 
+     * @TODO - finish this up and add factory registration capabilities,
+     * of course there is one default mechanism for now.
      */
     public ProtocolCodecFactory newProtocolCodecFactory( boolean client )
     {
-        return null;
+        if ( client )
+        {
+            return new LdapProtocolCodecFactory();
+        }
+        else
+        {
+            throw new NotImplementedException( 
+                "Filters may be different here, and we're probably going to " +
+                "want to have a protocol codec factory registration mechanism" +
+                "since this way we can swap in and out MINA/Grizzly" );
+        }
     }
 
     
@@ -204,6 +222,7 @@ public class DefaultLdapCodecService imp
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("unchecked")
     public CodecControl<? extends Control> newControl( Control control )
     {
         if ( control == null )
@@ -217,6 +236,7 @@ public class DefaultLdapCodecService imp
             return (org.apache.directory.shared.ldap.codec.api.CodecControl<?> )control;
         }
         
+        @SuppressWarnings("rawtypes")
         ControlFactory factory = controlFactories.get( control.getOid() );
         
         if ( factory == null )
@@ -248,6 +268,7 @@ public class DefaultLdapCodecService imp
      */
     public Control fromJndiControl( javax.naming.ldap.Control control ) throws DecoderException
     {
+        @SuppressWarnings("rawtypes")
         ControlFactory factory = controlFactories.get( control.getID() );
         
         if ( factory == null )
@@ -260,10 +281,20 @@ public class DefaultLdapCodecService imp
             return decorator;
         }
         
+        @SuppressWarnings("unchecked")
         CodecControl<? extends Control> ourControl = factory.newCodecControl();
         ourControl.setCritical( control.isCritical() );
         ourControl.setValue( control.getEncodedValue() );
         ourControl.decode( control.getEncodedValue() );
         return ourControl;
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Asn1Container newMessageContainer()
+    {
+        return new LdapMessageContainer<MessageDecorator<? extends Message>>(
this );
+    }
 }

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java?rev=1067749&r1=1067748&r2=1067749&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
Sun Feb  6 20:34:58 2011
@@ -55,7 +55,7 @@ public class LdapEncoder
     private int computeControlLength( Control control )
     {
         // First, compute the control's value length
-        int controlValueLength = ((CodecControl)control).computeLength();
+        int controlValueLength = ( ( CodecControl<?> ) control).computeLength();
         
         // Now, compute the envelop length
         // The OID
@@ -180,7 +180,7 @@ public class LdapEncoder
                     encodeControl( buffer, control );
                     
                     // The OctetString tag if the value is not null
-                    int controlValueLength = ((CodecControl)control).computeLength();
+                    int controlValueLength = ( ( CodecControl<?> ) control).computeLength();
                     
                     if ( controlValueLength > 0 )
                     {

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=1067749&r1=1067748&r2=1067749&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
Sun Feb  6 20:34:58 2011
@@ -169,6 +169,7 @@ public final class LdapMessageGrammar ex
     /**
      * Creates a new LdapMessageGrammar object.
      */
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     private LdapMessageGrammar()
     {
 

Modified: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java?rev=1067749&r1=1067748&r2=1067749&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java
Sun Feb  6 20:34:58 2011
@@ -24,6 +24,7 @@ import java.util.Iterator;
 
 import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 
@@ -125,4 +126,7 @@ public interface LdapCodecService
      * @throws DecoderException if there are problems decoding the value of the JNDI control.
      */
     Control fromJndiControl( javax.naming.ldap.Control jndiControl ) throws DecoderException;
+
+
+    Asn1Container newMessageContainer();
 }

Copied: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java
(from r1067704, directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolCodecFactory.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java?p2=directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java&p1=directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolCodecFactory.java&r1=1067704&r2=1067749&rev=1067749&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolCodecFactory.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java
Sun Feb  6 20:34:58 2011
@@ -17,7 +17,7 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.ldap.client.api.protocol;
+package org.apache.directory.shared.ldap.codec.protocol.mina;
 
 
 import org.apache.mina.core.session.IoSession;

Copied: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolDecoder.java
(from r1067741, directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolDecoder.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolDecoder.java?p2=directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolDecoder.java&p1=directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolDecoder.java&r1=1067741&r2=1067749&rev=1067749&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolDecoder.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolDecoder.java
Sun Feb  6 20:34:58 2011
@@ -17,7 +17,7 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.ldap.client.api.protocol;
+package org.apache.directory.shared.ldap.codec.protocol.mina;
 
 
 import java.nio.ByteBuffer;

Copied: directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolEncoder.java
(from r1067704, directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolEncoder.java?p2=directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolEncoder.java&p1=directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java&r1=1067704&r2=1067749&rev=1067749&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java
(original)
+++ directory/shared/branches/m1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/protocol/mina/LdapProtocolEncoder.java
Sun Feb  6 20:34:58 2011
@@ -17,7 +17,7 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.ldap.client.api.protocol;
+package org.apache.directory.shared.ldap.codec.protocol.mina;
 
 
 import java.nio.ByteBuffer;



Mime
View raw message