Class JettyDataBufferFactory
java.lang.Object
org.springframework.core.io.buffer.JettyDataBufferFactory
- All Implemented Interfaces:
DataBufferFactory
Implementation of the
DataBufferFactory interface that creates
JettyDataBuffer instances.- Since:
- 6.2
- Author:
- Arjen Poutsma
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newJettyDataBufferFactorywith default settings.JettyDataBufferFactory(boolean preferDirect) Creates a newJettyDataBufferFactory, indicating whether direct buffers should be created byallocateBuffer()andallocateBuffer(int).JettyDataBufferFactory(boolean preferDirect, int defaultInitialCapacity) Creates a newJettyDataBufferFactory, indicating whether direct buffers should be created byallocateBuffer()andallocateBuffer(int), and what the capacity is to be used forallocateBuffer(). -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.allocateBuffer(int initialCapacity) Allocate a data buffer of the given initial capacity.booleanisDirect()Indicates whether this factory allocates direct buffers (i.e.join(List<? extends DataBuffer> dataBuffers) Return a newDataBuffercomposed of thedataBufferselements joined together.wrap(byte[] bytes) Wrap the givenbytearray in aDataBuffer.wrap(ByteBuffer byteBuffer) Wrap the givenByteBufferin aDataBuffer.wrap(org.eclipse.jetty.io.Content.Chunk chunk)
-
Constructor Details
-
JettyDataBufferFactory
public JettyDataBufferFactory()Creates a newJettyDataBufferFactorywith default settings. -
JettyDataBufferFactory
public JettyDataBufferFactory(boolean preferDirect) Creates a newJettyDataBufferFactory, indicating whether direct buffers should be created byallocateBuffer()andallocateBuffer(int).- Parameters:
preferDirect-trueif direct buffers are to be preferred;falseotherwise
-
JettyDataBufferFactory
public JettyDataBufferFactory(boolean preferDirect, int defaultInitialCapacity) Creates a newJettyDataBufferFactory, indicating whether direct buffers should be created byallocateBuffer()andallocateBuffer(int), and what the capacity is to be used forallocateBuffer().- Parameters:
preferDirect-trueif direct buffers are to be preferred;falseotherwise
-
-
Method Details
-
allocateBuffer
Deprecated.Description copied from interface:DataBufferFactoryAllocate a data buffer of a default initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.- Specified by:
allocateBufferin interfaceDataBufferFactory- Returns:
- the allocated buffer
-
allocateBuffer
Description copied from interface:DataBufferFactoryAllocate a data buffer of the given initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.- Specified by:
allocateBufferin interfaceDataBufferFactory- Parameters:
initialCapacity- the initial capacity of the buffer to allocate- Returns:
- the allocated buffer
-
wrap
Description copied from interface:DataBufferFactory- Specified by:
wrapin interfaceDataBufferFactory- Parameters:
byteBuffer- the NIO byte buffer to wrap- Returns:
- the wrapped buffer
-
wrap
Description copied from interface:DataBufferFactory- Specified by:
wrapin interfaceDataBufferFactory- Parameters:
bytes- the byte array to wrap- Returns:
- the wrapped buffer
-
wrap
-
join
Description copied from interface:DataBufferFactoryReturn a newDataBuffercomposed of thedataBufferselements joined together. Depending on the implementation, the returned buffer may be a single buffer containing all data of the provided buffers, or it may be a true composite that contains references to the buffers.Note that the given data buffers do not have to be released, as they are released as part of the returned composite.
- Specified by:
joinin interfaceDataBufferFactory- Parameters:
dataBuffers- the data buffers to be composed- Returns:
- a buffer that is composed of the
dataBuffersargument
-
isDirect
public boolean isDirect()Description copied from interface:DataBufferFactoryIndicates whether this factory allocates direct buffers (i.e. non-heap, native memory).- Specified by:
isDirectin interfaceDataBufferFactory- Returns:
trueif this factory allocates direct buffers;falseotherwise
-