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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceStorage container client.protected static classStorage container item.protected static classStorage item. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.beans.factory.config.ConfigurableListableBeanFactoryThe bean factory used by the application context.protected final org.springframework.util.AntPathMatcherStores the Ant path matcher.Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIXFields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetMatchedContainers(String pattern) List all containers with the provided pattern.getMatchedItems(AbstractAzureStorageProtocolResolver.StorageContainerClient containerClient, String itemPattern) List all storage items with specified container and item pattern.org.springframework.core.io.ResourcegetResource(String location) org.springframework.core.io.Resource[]getResources(String pattern) protected abstract AbstractAzureStorageProtocolResolver.StorageContainerClientGet StorageContainerClient with specified container name.protected abstract org.springframework.core.io.ResourcegetStorageResource(String location, Boolean autoCreate) Get Resource from resource location.protected abstract StorageTypeThe storageType of ProtocolResolverprotected abstract Stream<AbstractAzureStorageProtocolResolver.StorageContainerItem> listStorageContainers(String containerPrefix) List all storage containers.voidpostProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) org.springframework.core.io.Resourceprotected org.springframework.core.io.Resource[]resolveResources(String containerPattern, String itemPattern) List all resources with specified container pattern and item pattern.voidsetResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) Set the ResourceLoader that this object runs in.
-
Field Details
-
matcher
protected final org.springframework.util.AntPathMatcher matcherStores the Ant path matcher. -
beanFactory
protected org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactoryThe bean factory used by the application context.
-
-
Constructor Details
-
AbstractAzureStorageProtocolResolver
public AbstractAzureStorageProtocolResolver()Creates an instance ofAbstractAzureStorageProtocolResolver.
-
-
Method Details
-
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:
setResourceLoaderin interfaceorg.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:
postProcessBeanFactoryin interfaceorg.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:
resolvein interfaceorg.springframework.core.io.ProtocolResolver
-
getResources
- Specified by:
getResourcesin interfaceorg.springframework.core.io.support.ResourcePatternResolver- Throws:
IOException- See Also:
-
getResource
- Specified by:
getResourcein interfaceorg.springframework.core.io.ResourceLoader- See Also:
-
getClassLoader
- Specified by:
getClassLoaderin interfaceorg.springframework.core.io.ResourceLoader- See Also:
-
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
protected Stream<AbstractAzureStorageProtocolResolver.StorageContainerClient> getMatchedContainers(String pattern) 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
protected Stream<AbstractAzureStorageProtocolResolver.StorageItem> getMatchedItems(AbstractAzureStorageProtocolResolver.StorageContainerClient containerClient, String itemPattern) 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.
-