Class FileResourceWriter
java.lang.Object
org.springframework.geode.core.io.AbstractResourceWriter
org.springframework.geode.core.io.support.FileResourceWriter
- All Implemented Interfaces:
ResourceWriter
- Since:
- 1.3.1
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final boolean
protected static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected OutputStream
decorate
(OutputStream outputStream) Decorates the givenOutputStream
by adding buffering capabilities.protected void
doWrite
(OutputStream resourceOutputStream, byte[] data) Writes the given data to the targetResource
(intentionally) by using theOutputStream
returned byWritableResource.getOutputStream()
.protected int
Returns the configuredbuffer size
used by this writer to chunk the data written to theFile
.protected OpenOption[]
Returns the configuredOpenOptions
used to configure the stream writing to theFile
.protected Optional<org.springframework.core.io.Resource>
Returns anOptional
reference to the targetResource
.protected boolean
isAbleToHandle
(org.springframework.core.io.Resource resource) Determines whether this writer is able to handle and write to the targetResource
.protected OutputStream
Methods inherited from class org.springframework.geode.core.io.AbstractResourceWriter
preProcess, write
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.geode.core.io.ResourceWriter
thenWriteTo, write
-
Field Details
-
DEFAULT_APPEND_TO_FILE
protected static final boolean DEFAULT_APPEND_TO_FILE- See Also:
-
DEFAULT_BUFFER_SIZE
protected static final int DEFAULT_BUFFER_SIZE- See Also:
-
-
Constructor Details
-
FileResourceWriter
public FileResourceWriter()
-
-
Method Details
-
doWrite
Description copied from class:AbstractResourceWriter
Writes the given data to the targetResource
(intentionally) by using theOutputStream
returned byWritableResource.getOutputStream()
. However, other algorithm/strategy implementations are free to write to theResource
as is appropriate for the given context (e.g. cloud environment). In those cases, implementors should override theAbstractResourceWriter.write(Resource, byte[])
method.- Specified by:
doWrite
in classAbstractResourceWriter
- Parameters:
resourceOutputStream
-OutputStream
returned fromWritableResource.getOutputStream()
used to write the given data to the locations identified by the targetResource
.data
- array of bytes containing the data to write.- See Also:
-
isAbleToHandle
protected boolean isAbleToHandle(@Nullable org.springframework.core.io.Resource resource) Description copied from class:AbstractResourceWriter
Determines whether this writer is able to handle and write to the targetResource
. The default implementation determines that theResource
can be handled if theResource
handle is not null.- Overrides:
isAbleToHandle
in classAbstractResourceWriter
- Parameters:
resource
-Resource
to evaluate.- Returns:
- a boolean value indicating whether this writer is able to handle and write to the target
Resource
. - See Also:
-
Resource
-
getBufferSize
protected int getBufferSize()Returns the configuredbuffer size
used by this writer to chunk the data written to theFile
.Subclasses should override this method to tune the buffer size based on the context and requirements.
- Returns:
- the configured
buffer size
.
-
getOpenOptions
Returns the configuredOpenOptions
used to configure the stream writing to theFile
. By default, theFile
will becreated
,truncated
andwritten
to. Subclasses should override this method to tune theFile
stream based on context and requirements.- Returns:
- configured
OpenOptions
. - See Also:
-
getResource
Returns anOptional
reference to the targetResource
. -
decorate
Decorates the givenOutputStream
by adding buffering capabilities.- Parameters:
outputStream
-OutputStream
to decorate.- Returns:
- the decorated
OutputStream
. - See Also:
-
newFileOutputStream
Tries to construct a newFile
basedOutputStream
from the targetResource
. By default, the constructedOutputStream
is also buffered (e.g.BufferedOutputStream
).- Returns:
- a
OutputStream
writing to aFile
identified by the targetResource
. - Throws:
IllegalStateException
- if the targetResource
cannot be handled as aFile
.org.springframework.dao.DataAccessResourceFailureException
- if theOutputStream
could not be created.- See Also:
-