Spring Boot for VMware GemFire
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
FieldsModifier and TypeFieldDescriptionprotected static final booleanprotected static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected OutputStreamdecorate(OutputStream outputStream) Decorates the givenOutputStreamby adding buffering capabilities.protected voiddoWrite(OutputStream resourceOutputStream, byte[] data) Writes the given data to the targetResource(intentionally) by using theOutputStreamreturned byWritableResource.getOutputStream().protected intReturns the configuredbuffer sizeused by this writer to chunk the data written to theFile.protected OpenOption[]Returns the configuredOpenOptionsused to configure the stream writing to theFile.protected Optional<org.springframework.core.io.Resource>Returns anOptionalreference to the targetResource.protected booleanisAbleToHandle(org.springframework.core.io.Resource resource) Determines whether this writer is able to handle and write to the targetResource.protected OutputStreamMethods inherited from class org.springframework.geode.core.io.AbstractResourceWriter
preProcess, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
Writes the given data to the targetResource(intentionally) by using theOutputStreamreturned byWritableResource.getOutputStream(). However, other algorithm/strategy implementations are free to write to theResourceas is appropriate for the given context (e.g. cloud environment). In those cases, implementors should override theAbstractResourceWriter.write(Resource, byte[])method.- Specified by:
doWritein classAbstractResourceWriter- Parameters:
resourceOutputStream-OutputStreamreturned 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) Determines whether this writer is able to handle and write to the targetResource. The default implementation determines that theResourcecan be handled if theResourcehandle is not null.- Overrides:
isAbleToHandlein classAbstractResourceWriter- Parameters:
resource-Resourceto 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 sizeused 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 configuredOpenOptionsused to configure the stream writing to theFile. By default, theFilewill becreated,truncatedandwrittento. Subclasses should override this method to tune theFilestream based on context and requirements.- Returns:
- configured
OpenOptions. - See Also:
-
getResource
Returns anOptionalreference to the targetResource. -
decorate
Decorates the givenOutputStreamby adding buffering capabilities.- Parameters:
outputStream-OutputStreamto decorate.- Returns:
- the decorated
OutputStream. - See Also:
-
newFileOutputStream
Tries to construct a newFilebasedOutputStreamfrom the targetResource. By default, the constructedOutputStreamis also buffered (e.g.BufferedOutputStream).- Returns:
- a
OutputStreamwriting to aFileidentified by the targetResource. - Throws:
IllegalStateException- if the targetResourcecannot be handled as aFile.org.springframework.dao.DataAccessResourceFailureException- if theOutputStreamcould not be created.- See Also:
-