Class JsonCacheDataImporterExporter

All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.EnvironmentAware, org.springframework.context.ResourceLoaderAware, CacheDataExporter, CacheDataImporter, CacheDataImporterExporter

@Component public class JsonCacheDataImporterExporter extends ResourceCapableCacheDataImporterExporter
The JsonCacheDataImporterExporter class is a CacheDataImporter and CacheDataExporter implementation that can export/import JSON data to/from a Resource given a target Region.
Since:
1.3.0
See Also:
  • Field Details

    • EMPTY_PDX_INSTANCE_ARRAY

      protected static final org.apache.geode.pdx.PdxInstance[] EMPTY_PDX_INSTANCE_ARRAY
  • Constructor Details

    • JsonCacheDataImporterExporter

      public JsonCacheDataImporterExporter()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Initializes the JSON to PDX (array) converter.
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Overrides:
      afterPropertiesSet in class ResourceCapableCacheDataImporterExporter
      See Also:
      • newJsonToPdxArrayConverter()
    • getJsonToPdxArrayConverter

      @NonNull protected JsonToPdxArrayConverter getJsonToPdxArrayConverter()
      Returns a reference to the configured JsonToPdxArrayConverter.
      Returns:
      a reference to the configured JsonToPdxArrayConverter.
      See Also:
    • doExportFrom

      @NonNull public org.apache.geode.cache.Region doExportFrom(@NonNull org.apache.geode.cache.Region region)
      Exports data contained in the given Region.
      Specified by:
      doExportFrom in class AbstractCacheDataImporterExporter
      Parameters:
      region - Region to export data from.
      Returns:
      the given Region.
      See Also:
    • doImportInto

      @NonNull public org.apache.geode.cache.Region doImportInto(@NonNull org.apache.geode.cache.Region region)
      Imports data into the given Region.
      Specified by:
      doImportInto in class AbstractCacheDataImporterExporter
      Parameters:
      region - Region to import data into.
      Returns:
      the given Region.
      See Also:
    • postProcess

      protected org.apache.geode.pdx.PdxInstance postProcess(org.apache.geode.pdx.PdxInstance pdxInstance)
      Post processes the given {PdxInstance.
      Parameters:
      pdxInstance - PdxInstance to process.
      Returns:
      the PdxInstance.
      See Also:
      • PdxInstance
    • resolveKey

      @NonNull protected Object resolveKey(@NonNull org.apache.geode.pdx.PdxInstance pdxInstance)
      Resolves the key used to map the given PdxInstance as the value for the Region.Entry stored in the Region.
      Parameters:
      pdxInstance - PdxInstance used to resolve the key.
      Returns:
      the resolved key.
      See Also:
    • resolveValue

      @Nullable protected Object resolveValue(@Nullable org.apache.geode.pdx.PdxInstance pdxInstance)
      Resolves the value to store in the Region from the given PdxInstance. If the given PdxInstance is an instance of PdxInstanceWrapper then this method will return the underlying, delegate PdxInstance. If the given PdxInstance is an instance of ObjectPdxInstanceAdapter then this method will return the underlying, Object. Otherwise, the given PdxInstance is returned.
      Parameters:
      pdxInstance - PdxInstance to unwrap.
      Returns:
      the resolved value.
      See Also:
    • toJson

      @NonNull protected String toJson(@NonNull org.apache.geode.cache.Region region)
      Convert values contained in the Region to JSON.
      Parameters:
      region - Region to process; must not be null.
      Returns:
      JSON containing the values from the given Region.
      See Also:
      • Region
    • toPdx

      @NonNull protected org.apache.geode.pdx.PdxInstance[] toPdx(@NonNull byte[] json)
      Converts the array of bytes containing multiple JSON objects into an array of PdxInstances.
      Parameters:
      json - array of bytes containing the JSON to convert to PDX.
      Returns:
      an array of PdxInstances for each JSON object.
      See Also: