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
Modifier and TypeClassDescriptionprotected static interface
Storage container client.protected static class
Storage container item.protected static class
Storage item. -
Field Summary
Modifier and TypeFieldDescriptionprotected org.springframework.beans.factory.config.ConfigurableListableBeanFactory
The bean factory used by the application context.protected final org.springframework.util.AntPathMatcher
Stores the Ant path matcher.Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
-
Constructor Summary
-
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.Resource
getResource
(String location) org.springframework.core.io.Resource[]
getResources
(String pattern) protected abstract AbstractAzureStorageProtocolResolver.StorageContainerClient
Get StorageContainerClient with specified container name.protected abstract org.springframework.core.io.Resource
getStorageResource
(String location, Boolean autoCreate) Get Resource from resource location.protected abstract StorageType
The storageType of ProtocolResolverprotected abstract Stream<AbstractAzureStorageProtocolResolver.StorageContainerItem>
listStorageContainers
(String containerPrefix) List all storage containers.void
postProcessBeanFactory
(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) org.springframework.core.io.Resource
protected org.springframework.core.io.Resource[]
resolveResources
(String containerPattern, String itemPattern) List all resources with specified container pattern and item pattern.void
setResourceLoader
(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:
setResourceLoader
in 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:
postProcessBeanFactory
in 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:
resolve
in interfaceorg.springframework.core.io.ProtocolResolver
-
getResources
- Specified by:
getResources
in interfaceorg.springframework.core.io.support.ResourcePatternResolver
- Throws:
IOException
- See Also:
-
ResourcePatternResolver.getResources(java.lang.String)
-
getResource
- Specified by:
getResource
in interfaceorg.springframework.core.io.ResourceLoader
- See Also:
-
ResourceLoader.getResource(java.lang.String)
-
getClassLoader
- Specified by:
getClassLoader
in interfaceorg.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
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.
-