Class AbstractResourceWriter
java.lang.Object
org.springframework.geode.core.io.AbstractResourceWriter
- All Implemented Interfaces:
ResourceWriter
- Direct Known Subclasses:
FileResourceWriter
Abstract base class providing functionality common to all
ResourceWriter implementations.- Since:
- 1.3.1
- See Also:
-
OutputStreamResourceWritableResourceResourceWriter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voiddoWrite(OutputStream resourceOutputStream, byte[] data) Writes the given data to the targetResource(intentionally) by using theOutputStreamreturned byWritableResource.getOutputStream().protected booleanisAbleToHandle(org.springframework.core.io.Resource resource) Determines whether this writer is able to handle and write to the targetResource.protected org.springframework.core.io.WritableResourcepreProcess(org.springframework.core.io.WritableResource resource) Pre-processes the targetWritableResourcebefore writing to theWritableResource.voidwrite(org.springframework.core.io.Resource resource, byte[] data) Writes data to the targetResourceas defined by the algorithm/strategy of this writer.Methods 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
-
Constructor Details
-
AbstractResourceWriter
public AbstractResourceWriter()
-
-
Method Details
-
write
public void write(@NonNull org.springframework.core.io.Resource resource, byte[] data) Description copied from interface:ResourceWriterWrites data to the targetResourceas defined by the algorithm/strategy of this writer. This method should throw anUnhandledResourceExceptionif the algorithm or strategy used by this writer is not able to or capable of writing to theResourceat its location. This allows subsequent writers in a composition to possibly handle theResource. Any otherExceptionthrown by thiswritemethod will break the chain of write calls in the composition.- Specified by:
writein interfaceResourceWriter- Parameters:
resource-Resourceto write data to.data- array of bytes containing the data to write to the targetResource.- See Also:
-
Resource
-
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.- 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
-
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 thewrite(Resource, byte[])method.- 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.- Throws:
IOException- if an I/O error occurs while writing to the targetResource.- See Also:
-
preProcess
@NonNull protected org.springframework.core.io.WritableResource preProcess(@NonNull org.springframework.core.io.WritableResource resource) Pre-processes the targetWritableResourcebefore writing to theWritableResource.- Parameters:
resource-WritableResourceto pre-process; never null.- Returns:
- the given, target
WritableResource. - See Also:
-
WritableResource
-