Class AbstractAzureStorageProtocolResolver

java.lang.Object
com.azure.spring.cloud.core.resource.AbstractAzureStorageProtocolResolver
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.context.ResourceLoaderAware, org.springframework.core.io.ProtocolResolver, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver
Direct Known Subclasses:
AzureStorageBlobProtocolResolver, AzureStorageFileProtocolResolver

public abstract class AbstractAzureStorageProtocolResolver extends Object implements org.springframework.core.io.ProtocolResolver, org.springframework.core.io.support.ResourcePatternResolver, org.springframework.context.ResourceLoaderAware, org.springframework.beans.factory.config.BeanFactoryPostProcessor
Abstract protocolResolver for Storage
  • Field Details

    • matcher

      protected final org.springframework.util.AntPathMatcher matcher
      Stores the Ant path matcher.
    • beanFactory

      protected org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory
      The bean factory used by the application context.
  • Constructor Details

    • AbstractAzureStorageProtocolResolver

      public AbstractAzureStorageProtocolResolver()
  • Method Details

    • getStorageType

      protected abstract StorageType getStorageType()
      The storageType of ProtocolResolver
      Returns:
      the storage type.
    • getStorageResource

      protected abstract org.springframework.core.io.Resource getStorageResource(String location, Boolean autoCreate)
      Get Resource from resource location.
      Parameters:
      location - The specified resource location.
      autoCreate - Whether to auto-create the resource if the resource is not exist.
      Returns:
      the storage Resource.
    • listStorageContainers

      protected abstract Stream<AbstractAzureStorageProtocolResolver.StorageContainerItem> listStorageContainers(String containerPrefix)
      List all storage containers.

      The underlying storage system may support 'prefix' filter, for example, Azure Storage Blob supports this

      https://docs.microsoft.com/rest/api/storageservices/list-blobs

      In this case, we can avoid load all containers to do client side filtering.

      Parameters:
      containerPrefix - container name prefix, without any wildcard characters.
      Returns:
      All storage containers match the given prefix, or all containers if the underlying storage system doesn't support prefix match.
    • getStorageContainerClient

      protected abstract AbstractAzureStorageProtocolResolver.StorageContainerClient getStorageContainerClient(String name)
      Get StorageContainerClient with specified container name.
      Parameters:
      name - Container name
      Returns:
      the storage container client.
    • setResourceLoader

      public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
      Set the ResourceLoader that this object runs in.
      Specified by:
      setResourceLoader in interface org.springframework.context.ResourceLoaderAware
      Parameters:
      resourceLoader - the ResourceLoader object to be used by this object
    • postProcessBeanFactory

      public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      postProcessBeanFactory in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • resolve

      public org.springframework.core.io.Resource resolve(String location, org.springframework.core.io.ResourceLoader resourceLoader)
      Specified by:
      resolve in interface org.springframework.core.io.ProtocolResolver
    • getResources

      public org.springframework.core.io.Resource[] getResources(String pattern) throws IOException
      Specified by:
      getResources in interface org.springframework.core.io.support.ResourcePatternResolver
      Throws:
      IOException
      See Also:
      • ResourcePatternResolver.getResources(java.lang.String)
    • getResource

      public org.springframework.core.io.Resource getResource(String location)
      Specified by:
      getResource in interface org.springframework.core.io.ResourceLoader
      See Also:
      • ResourceLoader.getResource(java.lang.String)
    • getClassLoader

      public ClassLoader getClassLoader()
      Specified by:
      getClassLoader in interface org.springframework.core.io.ResourceLoader
      See Also:
      • ResourceLoader.getClassLoader()
    • resolveResources

      protected org.springframework.core.io.Resource[] resolveResources(String containerPattern, String itemPattern)
      List all resources with specified container pattern and item pattern.
      Parameters:
      containerPattern - An ant style string which represent containers.
      itemPattern - An ant style string which represent storage items.
      Returns:
      All resources matching the provided patterns.
    • getMatchedContainers

      List all containers with the provided pattern.
      Parameters:
      pattern - An ant style string which represent containers.
      Returns:
      All container clients matching the provided pattern.
    • getMatchedItems

      List all storage items with specified container and item pattern.
      Parameters:
      containerClient - The specified container where to get storage items.
      itemPattern - An ant style string represents StorageItems.
      Returns:
      All matching items.