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:
-
OutputStream
Resource
WritableResource
ResourceWriter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
doWrite
(OutputStream resourceOutputStream, byte[] data) Writes the given data to the targetResource
(intentionally) by using theOutputStream
returned byWritableResource.getOutputStream()
.protected boolean
isAbleToHandle
(org.springframework.core.io.Resource resource) Determines whether this writer is able to handle and write to the targetResource
.protected org.springframework.core.io.WritableResource
preProcess
(org.springframework.core.io.WritableResource resource) Pre-processes the targetWritableResource
before writing to theWritableResource
.void
write
(org.springframework.core.io.Resource resource, byte[] data) Writes data to the targetResource
as 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, wait
Methods 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) Writes data to the targetResource
as defined by the algorithm/strategy of this writer. This method should throw anUnhandledResourceException
if the algorithm or strategy used by this writer is not able to or capable of writing to theResource
at its location. This allows subsequent writers in a composition to possibly handle theResource
. Any otherException
thrown by thiswrite
method will break the chain of write calls in the composition.- Specified by:
write
in interfaceResourceWriter
- Parameters:
resource
-Resource
to 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 theResource
can be handled if theResource
handle is not null.- 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
-
doWrite
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 thewrite(Resource, byte[])
method.- 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.- 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 targetWritableResource
before writing to theWritableResource
.- Parameters:
resource
-WritableResource
to pre-process; never null.- Returns:
- the given, target
WritableResource
. - See Also:
-
WritableResource
-