Class AbstractResourceWriter

java.lang.Object
org.springframework.geode.core.io.AbstractResourceWriter
All Implemented Interfaces:
ResourceWriter
Direct Known Subclasses:
FileResourceWriter

public abstract class AbstractResourceWriter extends Object implements ResourceWriter
Abstract base class providing functionality common to all ResourceWriter implementations.
Since:
1.3.1
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    doWrite(OutputStream resourceOutputStream, byte[] data)
    Writes the given data to the target Resource (intentionally) by using the OutputStream returned by WritableResource.getOutputStream().
    protected boolean
    isAbleToHandle(org.springframework.core.io.Resource resource)
    Determines whether this writer is able to handle and write to the target Resource.
    protected org.springframework.core.io.WritableResource
    preProcess(org.springframework.core.io.WritableResource resource)
    Pre-processes the target WritableResource before writing to the WritableResource.
    void
    write(org.springframework.core.io.Resource resource, byte[] data)
    Writes data to the target Resource 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 target Resource as defined by the algorithm/strategy of this writer. This method should throw an UnhandledResourceException if the algorithm or strategy used by this writer is not able to or capable of writing to the Resource at its location. This allows subsequent writers in a composition to possibly handle the Resource. Any other Exception thrown by this write method will break the chain of write calls in the composition.
      Specified by:
      write in interface ResourceWriter
      Parameters:
      resource - Resource to write data to.
      data - array of bytes containing the data to write to the target Resource.
      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 target Resource. The default implementation determines that the Resource can be handled if the Resource 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

      protected abstract void doWrite(OutputStream resourceOutputStream, byte[] data) throws IOException
      Writes the given data to the target Resource (intentionally) by using the OutputStream returned by WritableResource.getOutputStream(). However, other algorithm/strategy implementations are free to write to the Resource as is appropriate for the given context (e.g. cloud environment). In those cases, implementors should override the write(Resource, byte[]) method.
      Parameters:
      resourceOutputStream - OutputStream returned from WritableResource.getOutputStream() used to write the given data to the locations identified by the target Resource.
      data - array of bytes containing the data to write.
      Throws:
      IOException - if an I/O error occurs while writing to the target Resource.
      See Also:
    • preProcess

      @NonNull protected org.springframework.core.io.WritableResource preProcess(@NonNull org.springframework.core.io.WritableResource resource)
      Pre-processes the target WritableResource before writing to the WritableResource.
      Parameters:
      resource - WritableResource to pre-process; never null.
      Returns:
      the given, target WritableResource.
      See Also:
      • WritableResource