Interface ReadOnlyTransaction
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
ReadWriteTransaction
Represents a read only transaction.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface -
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends HasNodeId>
Tcheck(T owner) Checks that this transaction'sNodeIdmatches the suppliedNodeId, which is to say that bothNodeIdinstances have the sameInstanceId.voidclose()Closes this transaction, releasing any underlying system resources associated with this transaction.booleanexists(ResourceId resourceId) Checks if the resource exists, returning false if it does not exist.Returns theNodeIdof thisReadOnlyTransaction.getResourceId(Path path) Gets theResourceIdassociated with the givenPath.Returns aStream<ResourceService.Listing>of all instances reading the current stream.loadResourceContents(ResourceId resourceId) Loads the contents of theResourcegiven the suppliedResourceId.
-
Method Details
-
getNodeId
NodeId getNodeId()Returns theNodeIdof thisReadOnlyTransaction.- Returns:
- the
NodeId
-
exists
Checks if the resource exists, returning false if it does not exist.- Parameters:
resourceId- theResourceIdto check- Returns:
- true if the resource with the specified ID exists, false otherwise
-
list
Returns aStream<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
Gets theResourceIdassociated with the givenPath.- Parameters:
path-- Returns:
- @throws
ResourceNotFoundExceptionif there is noResourceIdassociated with the path
-
loadResourceContents
Loads the contents of theResourcegiven the suppliedResourceId. The suppliedReadableByteChannelis 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 ofResourceNotFoundExceptionto indicate there is no resource in the persistent storage with that particularResourceId. The suppliedReadableByteChannelis 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- theResourceId- Returns:
- a
ReadableByteChannelwith the contents of theResource - Throws:
IOException
-
close
void close()Closes this transaction, releasing any underlying system resources associated with this transaction.- Specified by:
closein interfaceAutoCloseable
-
check
Checks that this transaction'sNodeIdmatches the suppliedNodeId, which is to say that bothNodeIdinstances have the sameInstanceId.- Parameters:
owner- the object owning theNodeId(used only for exception formatting)- Returns:
- the owner object, if the check succeeds
-