Interface ProtonBufferComponentAccessor

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
Netty4ToProtonBufferAdapter, Netty5ToProtonBufferAdapter, ProtonByteArrayBuffer

public interface ProtonBufferComponentAccessor extends AutoCloseable
Provides a way of accessing the internal components of a ProtonBuffer which can be used to gain access to underlying buffer internals for IO or other low level buffer operations.

A component access object is not meant to have a long life-span as it can prevent the quick cleanup of buffer resources. Likewise the access object must be closed upon completion of the access if proper resource cleanup is to occur as the object itself ensure that there is concrete referencing of the buffer preventing a JVM GC of the object should the user discard the buffer before the access object has been discarded.

The general usage of the component access object should be within a try-with-resource block as follows:


   try (ProtonBufferComponentAccessor accessor = buffer.componentAccessor()) {
      for (ProtonBufferComponent component : accessor.readableComponents()) {
         // Access logic here....
      }
   }
 
 

Or an alternative that does not create an iterator for walking the list of available ProtonBufferComponents would look as follows:


   try (ProtonBufferComponentAccessor accessor = buffer.componentAccessor()) {
      for (ProtonBufferComponent component = accessor.first(); component != null; component = accessor.next()) {
         // Access logic here....
      }
   }