Package org.rostore.v2.media.block
Class InternalBlockProvider
java.lang.Object
org.rostore.v2.media.block.InternalBlockProvider
- All Implemented Interfaces:
BlockProvider
This instance manages a low-level block operation and creates a new
BlockContainer
.
This effectively creates a transactional boundary, that needs to be managed.
Code that creates thisBlockProvider
is responsible to clean it up by calling BlockContainer.close()
.
It is meant to be only used in the entities that need to manage its own transactional boundary,
and do not expect that the BlockContainer
will be provided from the outside.
It is usually a major hull-like entity, that manages several other slave-entities that would need a transactional boundaries provided from this overarching one.
-
Method Summary
Modifier and TypeMethodDescriptionstatic InternalBlockProvider
create
(BlockAllocator blockAllocator) Creates a block provider that contains a newBlockContainer
.static InternalBlockProvider
Creates a block provider that contains a newBlockContainer
.void
exchangeBlockAllocator
(BlockAllocator blockAllocator) Exchange a block allocator.Provides a block allocatorProvides a block container.getMedia()
Provides an associatedMedia
objectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.rostore.v2.media.block.BlockProvider
allocateBlock, freeBlock
-
Method Details
-
getBlockContainer
Provides a block container.Used to account the set of blocks that participate in one specific transaction.
- Specified by:
getBlockContainer
in interfaceBlockProvider
- Returns:
- the block container
-
getBlockAllocator
Provides a block allocatorUsed to allocate new blocks from the set of free blocks nad mark them as used.
- Specified by:
getBlockAllocator
in interfaceBlockProvider
- Returns:
- the block allocator
-
exchangeBlockAllocator
Exchange a block allocator. Usually should not be excessively used, only in places when the allocator can't be known at the moment of the object creation.- Parameters:
blockAllocator
-
-
getMedia
Provides an associatedMedia
object- Specified by:
getMedia
in interfaceBlockProvider
- Returns:
- the media object
-
create
Creates a block provider that contains a newBlockContainer
.- Parameters:
blockAllocator
- the allocator to be used- Returns:
- an instance of the
BlockProvider
-
create
Creates a block provider that contains a newBlockContainer
.Allocator is not set in this one and needs to be associated with
exchangeBlockAllocator(BlockAllocator)
- Parameters:
media
- the media object- Returns:
- an instance of the
BlockProvider
-