directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 65592 - in incubator/directory: eve/trunk/jndi-provider/src/java/org/apache/eve eve/trunk/jndi-provider/src/java/org/apache/eve/jndi eve/trunk/protocol/src/java/org/apache/eve/protocol ldap/trunk/common/src/java/org/apache/ldap/common/message ldap/trunk/common/src/java/org/apache/ldap/common/message/spi seda/trunk/src/java/org/apache/seda/encoder seda/trunk/src/java/org/apache/seda/event snickers/trunk/ber-codec/src/java/org/apache/snickers/ber snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder
Date Sun, 14 Nov 2004 10:22:32 GMT
Author: akarasulu
Date: Sun Nov 14 02:22:31 2004
New Revision: 65592

Modified:
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/EveMain.java
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
   incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/MessageDecoder.java
   incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/MessageEncoder.java
   incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/spi/Provider.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/event/GatheringOutputEvent.java
   incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TupleEncodingVisitor.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/SnickersLdapEncoder.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/AbstractEncoderTestCase.java
Log:
Changes ...

 o switched to using only Hashtables to align with JNDI
   environments in the LdapProtocolProvider, Provider,
   MessageDecoder, and MessageEncoder
 o LdapProtocolProvider checks to make sure the provider
   property is set to a valid value before abandoning the
   default provider
 o EveContextFactory now passes the environment to the LDAP
   protocol provider
 o Added code to collect ByteBuffers so the GatherOutputEvent
   is used instead of OutputEvent
 o Fixed AbstractEncoderTestCase to now use ByteBuffer arrays
 o SnickersLdapEncoder now flushes the visitor




Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/EveMain.java
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/EveMain.java	(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/EveMain.java	Sun Nov
14 02:22:31 2004
@@ -18,7 +18,6 @@
 
 
 import java.util.Properties;
-import java.io.FileInputStream;
 import java.io.File;
 
 import javax.naming.Context;

Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
Sun Nov 14 02:22:31 2004
@@ -491,7 +491,7 @@
 
     private void startUpWireProtocol() throws NamingException
     {
-        proto = new LdapProtocolProvider();
+        proto = new LdapProtocolProvider( initialEnv );
 
         try
         {

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
Sun Nov 14 02:22:31 2004
@@ -24,6 +24,7 @@
 import org.apache.seda.listener.ClientKey;
 
 import org.apache.ldap.common.message.*;
+import org.apache.ldap.common.message.spi.Provider;
 import org.apache.ldap.common.exception.LdapNamingException;
 
 import org.apache.commons.codec.stateful.DecoderFactory;
@@ -112,7 +113,7 @@
      * @param env environment properties used to configure the provider and
      * underlying codec providers if any
      */
-    public LdapProtocolProvider( Properties env ) throws LdapNamingException
+    public LdapProtocolProvider( Hashtable env ) throws LdapNamingException
     {
         this.handlers = new HashMap();
         SessionRegistry.getSingleton( env );
@@ -128,7 +129,7 @@
             {
                 try
                 {
-                    clazz = Class.forName( env.getProperty( type ) );
+                    clazz = Class.forName( ( String ) env.get( type ) );
                 }
                 catch ( ClassNotFoundException e )
                 {
@@ -268,7 +269,7 @@
      */
     private static final class DecoderFactoryImpl implements DecoderFactory
     {
-        final Properties env;
+        final Hashtable env;
 
 
         public DecoderFactoryImpl()
@@ -277,7 +278,7 @@
         }
 
 
-        DecoderFactoryImpl( Properties env )
+        DecoderFactoryImpl( Hashtable env )
         {
             this.env = env;
         }
@@ -285,7 +286,7 @@
 
         public StatefulDecoder createDecoder()
         {
-            if ( env == null )
+            if ( env == null || env.get( Provider.BERLIB_PROVIDER ) == null )
             {
                 return new MessageDecoder();
             }
@@ -302,7 +303,7 @@
      */
     private static final class EncoderFactoryImpl implements EncoderFactory
     {
-        final Properties env;
+        final Hashtable env;
 
 
         public EncoderFactoryImpl()
@@ -311,7 +312,7 @@
         }
 
 
-        public EncoderFactoryImpl( Properties env )
+        public EncoderFactoryImpl( Hashtable env )
         {
             this.env = env;
         }
@@ -319,7 +320,7 @@
 
         public StatefulEncoder createEncoder()
         {
-            if ( env == null )
+            if ( env == null || env.get( Provider.BERLIB_PROVIDER ) == null )
             {
                 return new MessageEncoder();
             }

Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/MessageDecoder.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/MessageDecoder.java
(original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/MessageDecoder.java
Sun Nov 14 02:22:31 2004
@@ -18,7 +18,7 @@
 
 
 import java.io.InputStream;
-import java.util.Properties;
+import java.util.Hashtable;
 
 import org.apache.ldap.common.message.spi.Provider;
 import org.apache.ldap.common.message.spi.TransformerSpi;
@@ -40,7 +40,7 @@
 public final class MessageDecoder implements ProviderDecoder
 {
     /** Environment parameters stored here */
-    private final Properties env;
+    private final Hashtable env;
     /** the ASN.1 provider */
     private final Provider provider;
     /** the ASN.1 provider's decoder */
@@ -70,9 +70,9 @@
      * @param env The Map of environment parameters.
      * @throws MessageException if there is a problem creating this decoder.
      */
-    public MessageDecoder( final Properties env ) throws MessageException
+    public MessageDecoder( final Hashtable env ) throws MessageException
     {
-        this.env = ( Properties ) env.clone();
+        this.env = ( Hashtable ) env.clone();
         this.provider = Provider.getProvider( this.env );
         this.decoder = this.provider.getDecoder();
         this.transformer = this.provider.getTransformer();

Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/MessageEncoder.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/MessageEncoder.java
(original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/MessageEncoder.java
Sun Nov 14 02:22:31 2004
@@ -19,6 +19,7 @@
 
 import java.io.OutputStream;
 import java.util.Properties;
+import java.util.Hashtable;
 import java.nio.ByteBuffer;
 
 import org.apache.commons.codec.EncoderException;
@@ -67,7 +68,7 @@
      * @param env The Map of environment parameters.
      * @throws MessageException if the encoder cannot be created.
      */
-    public MessageEncoder( final Properties env ) throws MessageException
+    public MessageEncoder( final Hashtable env ) throws MessageException
     {
         this.provider = Provider.getProvider( ( Properties ) env.clone() );
         this.encoder = provider.getEncoder();

Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/spi/Provider.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/spi/Provider.java
(original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/spi/Provider.java
Sun Nov 14 02:22:31 2004
@@ -227,6 +227,7 @@
 
 import java.util.List ;
 import java.util.Properties ;
+import java.util.Hashtable;
 
 
 /**
@@ -368,11 +369,11 @@
      * @return a singleton instance of the ASN.1 BER Library Provider
      * @throws ProviderException if the provider cannot be found 
      */
-    public static Provider getProvider( Properties a_env )
+    public static Provider getProvider( Hashtable a_env )
             throws ProviderException
     {
         Provider provider = null ;
-        String className = a_env.getProperty( BERLIB_PROVIDER ) ;
+        String className = ( String ) a_env.get( BERLIB_PROVIDER ) ;
 
         // --------------------------------------------------------------------
         // Check for a valid property value

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
Sun Nov 14 02:22:31 2004
@@ -254,25 +254,18 @@
          */
         encoder.setCallback(new EncoderCallback()
             {
-                public void encodeOccurred(StatefulEncoder encoder,
-                                           Object encoded)
+                public void encodeOccurred(StatefulEncoder encoder, Object encoded)
                 {
                     ClientKey key = ((ClientEncoder) encoder).getClientKey();
                     EventObject event;
 
                     if (encoded instanceof ByteBuffer)
                     {
-                        event =
-                                                        new OutputEvent(this,
-                                                                        key,
-                                                                        (ByteBuffer) encoded);
+                        event = new OutputEvent(this, key, (ByteBuffer) encoded);
                     }
                     else if (encoded instanceof ByteBuffer[])
                     {
-                        event =
-                                                        new GatheringOutputEvent(this,
-                                                                                 key,
-                                                                                 (ByteBuffer[])
encoded);
+                        event = new GatheringOutputEvent(this, key, (ByteBuffer[]) encoded);
                     }
                     else
                     {

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/event/GatheringOutputEvent.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/event/GatheringOutputEvent.java
(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/event/GatheringOutputEvent.java
Sun Nov 14 02:22:31 2004
@@ -40,7 +40,7 @@
      *
      * @param source the source which created this event
      * @param clientKey the key of the client
-     * @param buf the buffer containing the chunk to output
+     * @param buffers the buffer array containing the chunk to output
      */
     public GatheringOutputEvent(Object source, ClientKey clientKey, ByteBuffer[] buffers)
     {

Modified: incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TupleEncodingVisitor.java
==============================================================================
--- incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TupleEncodingVisitor.java
(original)
+++ incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TupleEncodingVisitor.java
Sun Nov 14 02:22:31 2004
@@ -38,6 +38,12 @@
 public class TupleEncodingVisitor extends AbstractStatefulEncoder
         implements TupleNodeVisitor
 {
+    /** An empty buffer array so we do not recreate every time on toArray */
+    private static final ByteBuffer[] EMPTY_ARRAY = new ByteBuffer[0];
+
+    /** The List storing the ByteBuffers collected during a visitation */
+    private ArrayList buffers = new ArrayList();
+
 
     // ------------------------------------------------------------------------
     // TupleNodeVisitor Implemenations
@@ -76,8 +82,7 @@
         ByteBuffer buf = ByteBuffer.wrap( new byte[size] );
         tlv.setTag( buf, tlv.getTagLength() );
         tlv.setLength( buf, tlv.getLengthLength() );
-        super.encodeOccurred( buf.flip() );
-        buf.rewind();
+        buffers.add( buf.flip() );
 
         /*
          * W A R N I N G
@@ -93,7 +98,7 @@
 
         if ( tlv.isPrimitive() )
         {
-            super.encodeOccurred( tlv.getLastValueChunk() );
+            buffers.add( tlv.getLastValueChunk() );
         }
 
         /*
@@ -145,5 +150,15 @@
     public ArrayList getOrder( TupleNode node, ArrayList children )
     {
         return children;
+    }
+
+
+    /**
+     * Flushes out the array of ByteBuffer's collected during the visitation.
+     * This is done by calling encodeOccurred in one shot.
+     */
+    public void flush()
+    {
+        super.encodeOccurred( ( ByteBuffer [] ) buffers.toArray( EMPTY_ARRAY ) );
     }
 }

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/SnickersLdapEncoder.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/SnickersLdapEncoder.java
(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/SnickersLdapEncoder.java
Sun Nov 14 02:22:31 2004
@@ -183,6 +183,9 @@
 
         // now encode using the another visitor
         root.accept( encoder );
+
+        // now make the encoder flush out the ByteBuffers with an encodeOccurred
+        encoder.flush();
     }
 
 

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/AbstractEncoderTestCase.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/AbstractEncoderTestCase.java
(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/AbstractEncoderTestCase.java
Sun Nov 14 02:22:31 2004
@@ -119,7 +119,12 @@
      */
     public void encodeOccurred( StatefulEncoder encoder, Object encoded )
     {
-        accumulator.put( ( ByteBuffer ) encoded );
+        ByteBuffer[] buffers = ( ByteBuffer [] ) encoded;
+
+        for ( int ii = 0; ii < buffers.length; ii++ )
+        {
+            accumulator.put( buffers[ii] );
+        }
     }
 
 
@@ -155,5 +160,6 @@
         TupleEncodingVisitor encoder = new TupleEncodingVisitor();
         encoder.setCallback( this );
         node.accept( encoder );
+        encoder.flush();
     }
 }

Mime
View raw message