Class MetaDataAccessorImpl<M>

java.lang.Object
com.sap.cds.services.utils.lib.mtx.impl.MetaDataAccessorImpl<M>
Type Parameters:
M - Type used for the Edmx model
All Implemented Interfaces:
MetaDataAccessor<M>

public class MetaDataAccessorImpl<M> extends Object implements MetaDataAccessor<M>
Class that provides access to CDS and Edmx models and caches them
  • Field Details

  • Constructor Details

    • MetaDataAccessorImpl

      public MetaDataAccessorImpl(MetaDataAccessorImpl.MetaDataAccessorConfig config, com.github.benmanes.caffeine.cache.Ticker cacheTicker)
      Parameters:
      config - MetaDataAccessor configurations
      cacheTicker - Optional ticker used by guava cache for testing purposes, use null for productive use
    • MetaDataAccessorImpl

      public MetaDataAccessorImpl(SidecarAccess sidecarAccess, CacheParams cacheParams, MetaDataAccessorImpl.EdmxModelCreator<M> strToEdmx, com.github.benmanes.caffeine.cache.Ticker cacheTicker)
      Parameters:
      sidecarAccess - Object of type SidecarAccessthat provides access to the node.js application sidecar/mtx via a rest API
      cacheParams - Parameters that control size and lifecycle of cache for cds and edmx models
      strToEdmx - Function that converts an edmx model description given as string into an edmx model
      cacheTicker - Optional ticker used by guava cache for testing purposes, use null for productive use
  • Method Details

    • getCdsModel

      public com.sap.cds.reflect.CdsModel getCdsModel(ModelId key, int maxAgeSeconds)
      Specified by:
      getCdsModel in interface MetaDataAccessor<M>
      Parameters:
      key - model identifier
      maxAgeSeconds - maximum acceptable age of resource
      Returns:
      CDS model
    • getEdmx

      public M getEdmx(ModelId key, int maxAgeSeconds) throws com.sap.cds.CdsException
      Specified by:
      getEdmx in interface MetaDataAccessor<M>
      Parameters:
      key - model identifier
      maxAgeSeconds - maximum acceptable age of resource
      Returns:
      EDMX model
      Throws:
      com.sap.cds.CdsException
    • getI18n

      public MetaDataAccessor.I18n getI18n(ModelId modelId, int maxAgeSeconds)
      Specified by:
      getI18n in interface MetaDataAccessor<M>
      Parameters:
      modelId - model identifier
      maxAgeSeconds - maximum acceptable age of resource
      Returns:
      model related i18n resources
    • evict

      public void evict(String tenantId)
      Description copied from interface: MetaDataAccessor
      evicts CDS and EDMX models for the specified tenant
      Specified by:
      evict in interface MetaDataAccessor<M>
      Parameters:
      tenantId - tenant identifier
    • refresh

      public void refresh(String tenantId, int maxAgeSeconds)
      Description copied from interface: MetaDataAccessor
      TODO sync Rereads CDS and EDMX models for the specified tenant if they have changed
      Specified by:
      refresh in interface MetaDataAccessor<M>
      Parameters:
      tenantId - tenant identifier
      maxAgeSeconds - maximum acceptable age of resource