directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r178089 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/AbstractContainer.java /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java
Date Tue, 24 May 2005 06:30:24 GMT
Author: elecharny
Date: Mon May 23 23:30:23 2005
New Revision: 178089

URL: http://svn.apache.org/viewcvs?rev=178089&view=rev
Log:
Suppressed the pooling mechanism

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/AbstractContainer.java
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/AbstractContainer.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/AbstractContainer.java?rev=178089&r1=178088&r2=178089&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/AbstractContainer.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/AbstractContainer.java
Mon May 23 23:30:23 2005
@@ -19,13 +19,11 @@
 import org.apache.asn1.ber.containers.IAsn1Container;
 import org.apache.asn1.ber.grammar.IGrammar;
 import org.apache.asn1.ber.tlv.TLV;
-import org.apache.asn1.util.pools.LocalPoolManager;
-import org.apache.asn1.util.pools.PoolObject;
 
 /**
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AbstractContainer extends PoolObject implements IAsn1Container {
+public class AbstractContainer implements IAsn1Container {
     /** The grammars that are used.
      * It's a stack as we can switch grammars */
     protected IGrammar[] grammarStack;
@@ -45,9 +43,6 @@
     /** The current transition */
     protected int transition;
 
-    /** The pool that is associated with this container */
-    protected LocalPoolManager poolManager;
-
     /** The current TLV */
     protected TLV tlv;
 
@@ -89,24 +84,6 @@
     {
         grammarStack[currentGrammar] = null;
         currentGrammar --;
-    }
-
-    /**
-     * Associate a pool Manager to the container
-     *
-     * @param poolManager The pool manager
-     */
-    public void setPoolManager( LocalPoolManager poolManager )
-    {
-        this.poolManager = poolManager;
-    }
-
-    /**
-     * @return The poolManager associated with this container
-     */
-    public LocalPoolManager getPoolManager()
-    {
-        return poolManager;
     }
 
     /**

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java?rev=178089&r1=178088&r2=178089&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java Mon
May 23 23:30:23 2005
@@ -22,14 +22,9 @@
 import org.apache.asn1.ber.tlv.Length;
 import org.apache.asn1.ber.tlv.TLV;
 import org.apache.asn1.ber.tlv.ITLVBerDecoderMBean;
-import org.apache.asn1.ber.tlv.TLVPoolEnum;
 import org.apache.asn1.ber.tlv.TLVStateEnum;
 import org.apache.asn1.ber.tlv.Tag;
 import org.apache.asn1.util.StringUtils;
-import org.apache.asn1.util.pools.LocalPoolManager;
-import org.apache.asn1.util.pools.PoolEnum;
-import org.apache.asn1.util.pools.PoolException;
-import org.apache.asn1.util.pools.PoolObject;
 
 import org.apache.log4j.Logger;
 
@@ -71,38 +66,16 @@
     /** The maximum number of bytes that could be used to encode the Tag */
     private int maxTagLength;
 
-    /** The local pool Manager */
-    protected LocalPoolManager poolMgr;
-    
-    /** A flag to set the memory mechanism to use */
-    protected boolean isPooled;
-    
     //~ Constructors -------------------------------------------------------------------------------
 
     /**
      * A public constructor of an Asn1 Decoder.
-     * 
-     * @param isPooled Set the memory allocation mechanism. If <code>true</code>,
-     * a pooled mechanism will be used
-     */
-    public Asn1Decoder(boolean isPooled)
-    {
-        this.indefiniteLengthAllowed = false;
-        this.maxLengthLength         = 1;
-        this.maxTagLength            = 1;
-        poolMgr                      = new LocalPoolManager(60, isPooled);
-    }
-
-    /**
-     * A public constructor of an Asn1 Decoder.
      */
     public Asn1Decoder()
     {
         this.indefiniteLengthAllowed = false;
         this.maxLengthLength         = 1;
         this.maxTagLength            = 1;
-        isPooled                     = true;
-        poolMgr                      = new LocalPoolManager(60, isPooled);
     }
 
     //~ Methods ------------------------------------------------------------------------------------
@@ -128,67 +101,59 @@
 
             byte octet = stream.get();
 
-            try
-            {
+            TLV tlv = new TLV();
+            Tag tag = tlv.getTag();
 
-                TLV tlv = ( TLV ) poolMgr.allocate( TLVPoolEnum.TLV_POOL );
-                Tag tag = tlv.getTag();
+            tag.setSize( 1 );
+            tag.setPrimitive( ( octet & Tag.CONSTRUCTED_FLAG ) == 0 );
+            tag.setTypeClass( Tag.TYPE_CLASS[( octet & Tag.TYPE_CLASS_MASK ) >>>
6] );
 
-                tag.setSize( 1 );
-                tag.setPrimitive( ( octet & Tag.CONSTRUCTED_FLAG ) == 0 );
-                tag.setTypeClass( Tag.TYPE_CLASS[( octet & Tag.TYPE_CLASS_MASK ) >>>
6] );
+            int value = octet & Tag.SHORT_MASK;
 
-                int value = octet & Tag.SHORT_MASK;
+            if ( value == Tag.SHORT_MASK )
+            {
 
-                if ( value == Tag.SHORT_MASK )
+                // we have to check the typeClass. UNIVERSAL class is not
+                // allowed with this value.
+                if ( tag.isUniversal() )
                 {
+                    throw new DecoderException( "Universal tag 31 is reserved" );
+                }
 
-                    // we have to check the typeClass. UNIVERSAL class is not
-                    // allowed with this value.
-                    if ( tag.isUniversal() )
-                    {
-                        throw new DecoderException( "Universal tag 31 is reserved" );
-                    }
+                // we will have more than one byte to encode the value
+                // The tag is encoded on [2 - 6 bytes], its value
+                // is container in the 7 lower bits of the bytes following
+                // the first byte.
+                container.setState( TLVStateEnum.TAG_STATE_PENDING );
+                tag.setId( 0 );
+                tag.addByte( octet );
+            }
+            else
+            {
+                // It's a tag wich value is below 30 (31 is not allowed
+                // as it signals a multi-bytes value. Everything is done.
 
-                    // we will have more than one byte to encode the value
-                    // The tag is encoded on [2 - 6 bytes], its value
-                    // is container in the 7 lower bits of the bytes following
-                    // the first byte.
-                    container.setState( TLVStateEnum.TAG_STATE_PENDING );
-                    tag.setId( 0 );
-                    tag.addByte( octet );
-                }
-                else
+                // We have to check for reserved tags if typeClass is UNIVERSAL
+                if ( tag.isUniversal() )
                 {
-                    // It's a tag wich value is below 30 (31 is not allowed
-                    // as it signals a multi-bytes value. Everything is done.
 
-                    // We have to check for reserved tags if typeClass is UNIVERSAL
-                    if ( tag.isUniversal() )
+                    if ( ( value == 14 ) || ( value == 15 ) )
                     {
-
-                        if ( ( value == 14 ) || ( value == 15 ) )
-                        {
-                            throw new DecoderException( "Universal tag " + value + " is reserved"
);
-                        }
+                        throw new DecoderException( "Universal tag " + value + " is reserved"
);
                     }
-
-                    tag.setId( value );
-                    tag.addByte( octet );
-
-                    // The tag has been completed, we have to decode the Length
-                    container.setState( TLVStateEnum.TAG_STATE_END );
                 }
 
-                // Store the current TLV in the container.
-                container.setCurrentTLV( tlv );
+                tag.setId( value );
+                tag.addByte( octet );
 
-                return MORE;
-            }
-            catch ( PoolException pe )
-            {
-                throw new DecoderException( "Cannot allocate a TLV : " + pe.getMessage()
);
+                // The tag has been completed, we have to decode the Length
+                container.setState( TLVStateEnum.TAG_STATE_END );
             }
+
+            // Store the current TLV in the container.
+            container.setCurrentTLV( tlv );
+
+            return MORE;
         }
         else
         {
@@ -557,7 +522,6 @@
 
         // Then we switch to the Start tag state and free the current TLV
         container.setState( TLVStateEnum.TAG_STATE_START );
-        container.getCurrentTLV().free();
 
         return stream.hasRemaining();
     }
@@ -811,26 +775,4 @@
         this.maxTagLength = maxTagLength;
     }
 
-    /**
-     * Ask the local pool manager to allocate an object.
-     *
-     * @param pool The pool in which the object will be taken from
-     *
-     * @return The allocated object
-     *
-     * @throws PoolException Thrown if the object could not be allocated
-     */
-    public PoolObject allocate( int pool ) throws PoolException
-    {
-   		return isPooled ? poolMgr.allocate( pool ) : PoolEnum.allocate( pool );
-    }
-
-    /**
-     * @return Returns the pool manager to the caller.
-     */
-    public LocalPoolManager getPoolManager()
-    {
-
-        return poolMgr;
-    }
 } // end class TLVTagDecoder



Mime
View raw message