Hi,

I was planning to use MINA ByteBuffer for replacement of java.nio.ByteBuffer.

Is there any reason in MINA has not provided java.nio.ByteBuffer.array
and java.nio.ByteBuffer.arrayOffSet methods(apart from the following
reasons):
* Releasing of mina ByteBuffers may become complicated, if we expose
the Backing byte[[] store to outside as in Sun's
java.nio.ByteBuffer.array
* Exposing the Backing store is against the good coding
practices.(But  nio.ByteBuffer and MIN.ByteBuffer to violate that by
ByteBuffer.wrap methods)

------------------------------------------------------------------------------------------
Why I need this array/arrayoffset in backing store is:
* I have lots of small allocations of headers(around 64 bytes), I
want to do some calculations(like SHA1 digest,etc) at high rate. I
want to avoid high rate of GC  for ' new byte[]' creations OR
ByteBuffer/byte[] create-copy-operations.

My operation is like this:

 DIGEST = java.security.MessageDigest.getInstance("SHA-1"); DIGEST =
java.security.MessageDigest.getInstance("SHA-1");

 public static ByteBuffer digest(byte[] buf,ByteBuffer b1,ByteBuffer b2){
      // typically b1,b2 size  < 64 bytes
       DIGEST.reset();
        /// If Mina's ByteBuffer.array is not there , I have to create/copy
to  a temp byte buffer. Rate of this function invoking is high rate
       DIGEST.update(b1.array());
       DIGEST.update(b2.array());
       DIGEST.update(buf);

        return ByteBuffer.wrap(DIGEST.digest());

}
---------------------------------------------------------------------------------------------------

Am I missing some thing here.


Thanks in advance

mahadevan

Reply via email to