Interface ReadOnlyTransaction

All Superinterfaces:
AutoCloseable
All Known Subinterfaces:
ReadWriteTransaction

public interface ReadOnlyTransaction extends AutoCloseable
Represents a read only transaction.
  • Method Details

    • getNodeId

      NodeId getNodeId()
      Returns the NodeId of this ReadOnlyTransaction.
      Returns:
      the NodeId
    • exists

      boolean exists(ResourceId resourceId)
      Checks if the resource exists, returning false if it does not exist.
      Parameters:
      resourceId - the ResourceId to check
      Returns:
      true if the resource with the specified ID exists, false otherwise
    • list

      Returns a Stream<ResourceService.Listing> of all instances reading the current stream. If nothing, matches an empty stream is returned.
      Parameters:
      path - the path to check, may be direct or wildcard
      Returns:
      a Stream<ResourceService.Listing>
    • getResourceId

      ResourceId getResourceId(Path path)
      Gets the ResourceId associated with the given Path.
      Parameters:
      path -
      Returns:
      @throws ResourceNotFoundException if there is no ResourceId associated with the path
    • loadResourceContents

      ReadableByteChannel loadResourceContents(ResourceId resourceId) throws IOException
      Loads the contents of the Resource given the supplied ResourceId. The supplied ReadableByteChannel is only guaranteed to be valid for the life of this transaction. However, the caller must not assume the transaction will automatically clean up open byte channels. If no resource exists with the supplied id, then this must throw an instance of ResourceNotFoundException to indicate there is no resource in the persistent storage with that particular ResourceId. The supplied ReadableByteChannel is only guaranteed to be valid for the life of the transaction which created it. It may still be possible to write after the transaction is closed. However, the behavior of which is not defined.
      Parameters:
      resourceId - the ResourceId
      Returns:
      a ReadableByteChannel with the contents of the Resource
      Throws:
      IOException
    • close

      void close()
      Closes this transaction, releasing any underlying system resources associated with this transaction.
      Specified by:
      close in interface AutoCloseable
    • check

      default <T extends HasNodeId> T check(T owner)
      Checks that this transaction's NodeId matches the supplied NodeId, which is to say that both NodeId instances have the same InstanceId.
      Parameters:
      owner - the object owning the NodeId (used only for exception formatting)
      Returns:
      the owner object, if the check succeeds