public class BufferWrapper<T> extends Object implements org.glassfish.grizzly.Cacheable
Buffer, which has original message origin, original object type BufferWrapper.BufferType and converted Buffer
Messages which should be sent to the remote peer via network will be always converted into Buffer instance by wrap(T, org.glassfish.grizzly.memory.MemoryManager),
and the received packet will be always restored to its original messages by unwrap(org.glassfish.grizzly.Buffer, org.glassfish.grizzly.memcached.BufferWrapper.BufferType, org.glassfish.grizzly.memory.MemoryManager)| Modifier and Type | Class and Description |
|---|---|
static class |
BufferWrapper.BufferType |
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_COMPRESSION_THRESHOLD |
| Modifier and Type | Method and Description |
|---|---|
org.glassfish.grizzly.Buffer |
getBuffer()
Return buffer corresponding to original object
|
T |
getOrigin()
Return original object
|
BufferWrapper.BufferType |
getType()
Return original object's type
|
void |
recycle() |
String |
toString() |
static Object |
unwrap(org.glassfish.grizzly.Buffer buffer,
BufferWrapper.BufferType type,
org.glassfish.grizzly.memory.MemoryManager memoryManager)
Return the original instance from
buffer |
static Object |
unwrap(org.glassfish.grizzly.Buffer buffer,
int position,
int limit,
BufferWrapper.BufferType type,
org.glassfish.grizzly.memory.MemoryManager memoryManager)
Return the original instance from
buffer |
static <T> BufferWrapper<T> |
wrap(T origin,
org.glassfish.grizzly.memory.MemoryManager memoryManager)
Return
BufferWrapper instance from original object |
public static final int DEFAULT_COMPRESSION_THRESHOLD
public T getOrigin()
public org.glassfish.grizzly.Buffer getBuffer()
public BufferWrapper.BufferType getType()
public void recycle()
recycle in interface org.glassfish.grizzly.Cacheablepublic static <T> BufferWrapper<T> wrap(T origin, org.glassfish.grizzly.memory.MemoryManager memoryManager) throws IllegalArgumentException
BufferWrapper instance from original objectorigin - original objectmemoryManager - the memory manager for allocating BufferoriginIllegalArgumentException - if given parameters are not validpublic static Object unwrap(org.glassfish.grizzly.Buffer buffer, BufferWrapper.BufferType type, org.glassfish.grizzly.memory.MemoryManager memoryManager)
bufferbuffer - the Buffer for being restoredtype - the type of original objectmemoryManager - the memory manager which will be used for decompressing packetspublic static Object unwrap(org.glassfish.grizzly.Buffer buffer, int position, int limit, BufferWrapper.BufferType type, org.glassfish.grizzly.memory.MemoryManager memoryManager)
bufferbuffer - the Buffer for being restoredposition - the position of buffer to convert buffer into originlimit - the limit of buffer to convert buffer into origintype - the type of original objectmemoryManager - the memory manager which will be used for decompressing packetsCopyright © 2015 Project Grizzly. All Rights Reserved.