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'sNodeId
matches the suppliedNodeId
, which is to say that bothNodeId
instances have the sameInstanceId
.void
close()
Closes this transaction, releasing any underlying system resources associated with this transaction.boolean
exists
(ResourceId resourceId) Checks if the resource exists, returning false if it does not exist.Returns theNodeId
of thisReadOnlyTransaction
.getResourceId
(Path path) Gets theResourceId
associated with the givenPath
.Returns aStream<ResourceService.Listing>
of all instances reading the current stream.loadResourceContents
(ResourceId resourceId) Loads the contents of theResource
given the suppliedResourceId
.
-
Method Details
-
getNodeId
NodeId getNodeId()Returns theNodeId
of thisReadOnlyTransaction
.- Returns:
- the
NodeId
-
exists
Checks if the resource exists, returning false if it does not exist.- Parameters:
resourceId
- theResourceId
to 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 theResourceId
associated with the givenPath
.- Parameters:
path
-- Returns:
- @throws
ResourceNotFoundException
if there is noResourceId
associated with the path
-
loadResourceContents
Loads the contents of theResource
given the suppliedResourceId
. The suppliedReadableByteChannel
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 ofResourceNotFoundException
to indicate there is no resource in the persistent storage with that particularResourceId
. The suppliedReadableByteChannel
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
- theResourceId
- Returns:
- a
ReadableByteChannel
with the contents of theResource
- Throws:
IOException
-
close
void close()Closes this transaction, releasing any underlying system resources associated with this transaction.- Specified by:
close
in interfaceAutoCloseable
-
check
Checks that this transaction'sNodeId
matches the suppliedNodeId
, which is to say that bothNodeId
instances have the sameInstanceId
.- Parameters:
owner
- the object owning theNodeId
(used only for exception formatting)- Returns:
- the owner object, if the check succeeds
-