public static WsByteBuffer allocateByteBuffer ( int size , boolean allocateDirect ) { WsByteBuffer newBuffer = null ; // Allocate based on the input parameter. if ( allocateDirect ) { newBuffer = ChannelFrameworkFactory . getBufferManager ( ) . allocateDirect ( size ) ; } else { newBuffer = ChannelFrameworkFactory . getBufferManager ( ) . allocate ( size ) ; } // Shift the limit to the capacity to maximize the space available in the buffer. newBuffer . limit ( newBuffer . capacity ( ) ) ; return newBuffer ; }
Allocate a ByteBuffer per the SSL config at least as big as the input size .