directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1075144 - in /directory/shared/branches/akarasulu: ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/ ldap-codec-standalone/ ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/ ldap-codec...
Date Sun, 27 Feb 2011 20:58:05 GMT
Author: akarasulu
Date: Sun Feb 27 20:58:05 2011
New Revision: 1075144

URL: http://svn.apache.org/viewvc?rev=1075144&view=rev
Log:
DIRSHARED-92: adding registration method and changing newPCF to getPCF

Modified:
    directory/shared/branches/akarasulu/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/shared/branches/akarasulu/ldap-codec-standalone/pom.xml
    directory/shared/branches/akarasulu/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
    directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapDecoder.java
    directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java
    directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/osgi/DefaultLdapCodecService.java
    directory/shared/branches/akarasulu/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/osgi/AbstractCodecServiceTest.java

Modified: directory/shared/branches/akarasulu/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1075144&r1=1075143&r2=1075144&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
(original)
+++ directory/shared/branches/akarasulu/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Sun Feb 27 20:58:05 2011
@@ -218,7 +218,7 @@ public class LdapNetworkConnection exten
     LdapCodecService codec = LdapCodecServiceFactory.getSingleton();
 
     /** The Ldap codec protocol filter */
-    private IoFilter ldapProtocolFilter = new ProtocolCodecFilter( codec.newProtocolCodecFactory()
);
+    private IoFilter ldapProtocolFilter = new ProtocolCodecFilter( codec.getProtocolCodecFactory()
);
 
     /** the SslFilter key */
     private static final String SSL_FILTER_KEY = "sslFilter";

Modified: directory/shared/branches/akarasulu/ldap-codec-standalone/pom.xml
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-codec-standalone/pom.xml?rev=1075144&r1=1075143&r2=1075144&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-codec-standalone/pom.xml (original)
+++ directory/shared/branches/akarasulu/ldap-codec-standalone/pom.xml Sun Feb 27 20:58:05
2011
@@ -49,6 +49,12 @@
     </dependency>
     
     <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap-protocol-codec</artifactId>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>shared-ldap-codec</artifactId>
     </dependency> 

Modified: directory/shared/branches/akarasulu/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java?rev=1075144&r1=1075143&r2=1075144&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
(original)
+++ directory/shared/branches/akarasulu/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
Sun Feb 27 20:58:05 2011
@@ -52,7 +52,6 @@ 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.protocol.mina.LdapProtocolCodecFactory;
 import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
 import org.apache.directory.shared.ldap.model.message.ExtendedRequestImpl;
@@ -132,6 +131,9 @@ public class StandaloneLdapCodecService 
     /** The map of registered {@link UnsolicitedResponseFactory}'s by request OID */
     private Map<String,UnsolicitedResponseFactory<?>> unsolicitedFactories =
new HashMap<String, UnsolicitedResponseFactory<?>>();
     
+    /** The LDAP {@link ProtocolCodecFactory} implementation used */
+    private ProtocolCodecFactory protocolCodecFactory;
+    
     /** The codec's {@link BundleActivator} */
     private CodecHostActivator activator;
     
@@ -309,6 +311,21 @@ public class StandaloneLdapCodecService 
         
         loadStockControls();
         setupFelix();
+        
+        if ( protocolCodecFactory == null )
+        {
+            try
+            {
+                @SuppressWarnings("unchecked")
+                Class<? extends ProtocolCodecFactory> clazz = ( Class<? extends
ProtocolCodecFactory> ) 
+                    Class.forName( DEFAULT_PROTOCOL_CODEC_FACTORY );
+                protocolCodecFactory = clazz.newInstance();
+            }
+            catch( Exception cause )
+            {
+                throw new RuntimeException( "Failed to load default codec factory.", cause
);
+            }
+        }
     }
     
     
@@ -588,15 +605,26 @@ public class StandaloneLdapCodecService 
     /**
      * {@inheritDoc}
      */
-    public ProtocolCodecFactory newProtocolCodecFactory()
+    public ProtocolCodecFactory getProtocolCodecFactory()
     {
-        return new LdapProtocolCodecFactory();
+        return protocolCodecFactory;
     }
 
     
     /**
      * {@inheritDoc}
      */
+    public ProtocolCodecFactory registerProtocolCodecFactory( ProtocolCodecFactory protocolCodecFactory
)
+    {
+        ProtocolCodecFactory old = this.protocolCodecFactory;
+        this.protocolCodecFactory = protocolCodecFactory;
+        return old;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
     public CodecControl<? extends Control> newControl( String oid )
     {
         ControlFactory<?,?> factory = controlFactories.get( oid );

Modified: directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapDecoder.java?rev=1075144&r1=1075143&r2=1075144&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapDecoder.java
(original)
+++ directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapDecoder.java
Sun Feb 27 20:58:05 2011
@@ -51,9 +51,6 @@ public class LdapDecoder
     /** A speedup for logger */
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-    /** The message container for this instance */
-    private LdapMessageContainer<MessageDecorator<? extends Message>> ldapMessageContainer;
-
     /** The ASN 1 decoder instance */
     private Asn1Decoder asn1Decoder;
 

Modified: directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java?rev=1075144&r1=1075143&r2=1075144&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java
(original)
+++ directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java
Sun Feb 27 20:58:05 2011
@@ -39,6 +39,8 @@ import org.apache.mina.filter.codec.Prot
  */
 public interface LdapCodecService
 {
+    String DEFAULT_PROTOCOL_CODEC_FACTORY = 
+        "org.apache.directory.shared.ldap.codec.protocol.mina.LdapProtocolCodecFactory";
     
     // ------------------------------------------------------------------------
     // Control Methods
@@ -244,7 +246,17 @@ public interface LdapCodecService
      *
      * @return the {@link ProtocolCodecFactory}
      */
-    ProtocolCodecFactory newProtocolCodecFactory();
+    ProtocolCodecFactory getProtocolCodecFactory();
+    
+    
+    /**
+     * Registers a ProtocolCodecFactory with this LdapCodecService.
+     *
+     * @param factory The factory being registered.
+     * @return The previously set {@link ProtocolCodecFactory}, or null if 
+     * none had been set earlier.
+     */
+    ProtocolCodecFactory registerProtocolCodecFactory( ProtocolCodecFactory factory );
 
     
     /**

Modified: directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/osgi/DefaultLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/osgi/DefaultLdapCodecService.java?rev=1075144&r1=1075143&r2=1075144&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/osgi/DefaultLdapCodecService.java
(original)
+++ directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/osgi/DefaultLdapCodecService.java
Sun Feb 27 20:58:05 2011
@@ -39,7 +39,6 @@ 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.protocol.mina.LdapProtocolCodecFactory;
 import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
 import org.apache.directory.shared.ldap.model.message.ExtendedRequestImpl;
@@ -82,6 +81,9 @@ public class DefaultLdapCodecService imp
     /** The map of registered {@link UnsolicitedResponseFactory}'s by request OID */
     private Map<String,UnsolicitedResponseFactory<?>> unsolicitedFactories =
new HashMap<String, UnsolicitedResponseFactory<?>>();
 
+    /** The registered ProtocolCodecFactory */
+    private ProtocolCodecFactory protocolCodecFactory;
+    
 
     /**
      * Creates a new instance of DefaultLdapCodecService.
@@ -185,9 +187,17 @@ public class DefaultLdapCodecService imp
     /**
      * {@inheritDoc}
      */
-    public ProtocolCodecFactory newProtocolCodecFactory()
+    public ProtocolCodecFactory getProtocolCodecFactory()
+    {
+        return protocolCodecFactory;
+    }
+    
+    
+    public ProtocolCodecFactory registerProtocolCodecFactory( ProtocolCodecFactory protocolCodecFactory
)
     {
-        return new LdapProtocolCodecFactory();
+        ProtocolCodecFactory oldFactory = this.protocolCodecFactory;
+        this.protocolCodecFactory = protocolCodecFactory;
+        return oldFactory;
     }
 
 

Modified: directory/shared/branches/akarasulu/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/osgi/AbstractCodecServiceTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/osgi/AbstractCodecServiceTest.java?rev=1075144&r1=1075143&r2=1075144&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/osgi/AbstractCodecServiceTest.java
(original)
+++ directory/shared/branches/akarasulu/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/osgi/AbstractCodecServiceTest.java
Sun Feb 27 20:58:05 2011
@@ -23,6 +23,10 @@ package org.apache.directory.shared.ldap
 import org.apache.directory.shared.ldap.codec.LdapEncoder;
 import org.apache.directory.shared.ldap.codec.api.LdapCodecServiceFactory;
 import org.apache.directory.shared.ldap.codec.osgi.DefaultLdapCodecService;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
@@ -47,6 +51,20 @@ public abstract class AbstractCodecServi
     public static void setupLdapCodecService()
     {
         codec = new DefaultLdapCodecService();
+
+        codec.registerProtocolCodecFactory( new ProtocolCodecFactory()
+        {
+            public ProtocolEncoder getEncoder( IoSession session ) throws Exception
+            {
+                return null;
+            }
+            
+            public ProtocolDecoder getDecoder( IoSession session ) throws Exception
+            {
+                return null;
+            }
+        });
+        
         
         if ( LdapCodecServiceFactory.isInitialized() == false )
         {



Mime
View raw message