Package com.amazonaws.regions
Class RegionUtils
- java.lang.Object
-
- com.amazonaws.regions.RegionUtils
-
public class RegionUtils extends Object
Utilities for working with regions.
-
-
Constructor Summary
Constructors Constructor Description RegionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static RegiongetRegion(String regionName)Returns the region with the id given, if it exists.static RegionMetadatagetRegionMetadata()Returns the current set of region metadata for this process, initializing it if it has not yet been explicitly initialized before.static List<Region>getRegions()Returns a list of the available AWS regions.static List<Region>getRegionsForService(String serviceAbbreviation)Returns a list of the regions that support the service given.static voidinit()Deprecated.in favor ofinitialize()static voidinitialize()Initializes the region metadata by loading from the default hierarchy of region metadata locations.static voidinitializeFromFile(File file)Deprecated.static voidinitializeFromResource(Class<?> clazz, String name)Deprecated.static voidinitializeFromResource(ClassLoader classLoader, String name)Deprecated.static voidinitializeFromResource(String name)Deprecated.static voidinitializeFromURI(URI uri)Deprecated.static voidinitializeFromURI(URI uri, ClientConfiguration config)Deprecated.static voidinitializeWithMetadata(RegionMetadata metadata)Directly sets the singletonRegionMetadatainstance.static RegionMetadataloadMetadataFromFile(File file)Deprecated.static RegionMetadataloadMetadataFromInputStream(InputStream stream)Deprecated.static RegionMetadataloadMetadataFromResource(Class<?> clazz, String name)Deprecated.static RegionMetadataloadMetadataFromResource(ClassLoader classLoader, String name)Deprecated.static RegionMetadataloadMetadataFromResource(String name)Deprecated.static RegionMetadataloadMetadataFromURI(URI uri)Deprecated.static RegionMetadataloadMetadataFromURI(URI uri, ClientConfiguration config)Deprecated.
-
-
-
Method Detail
-
getRegionMetadata
public static RegionMetadata getRegionMetadata()
Returns the current set of region metadata for this process, initializing it if it has not yet been explicitly initialized before.- Returns:
- the current set of region metadata
-
initialize
public static void initialize()
Initializes the region metadata by loading from the default hierarchy of region metadata locations.
-
initializeWithMetadata
public static void initializeWithMetadata(RegionMetadata metadata)
Directly sets the singletonRegionMetadatainstance.- Parameters:
metadata- the new region metadata object
-
getRegionsForService
public static List<Region> getRegionsForService(String serviceAbbreviation)
Returns a list of the regions that support the service given.- See Also:
ServiceAbbreviations
-
getRegion
public static Region getRegion(String regionName)
Returns the region with the id given, if it exists. Otherwise, returns null.
-
loadMetadataFromURI
@Deprecated public static RegionMetadata loadMetadataFromURI(URI uri) throws IOException
Deprecated.Loads a set of region metadata by downloading an XML file from the given URI and parsing it.- Parameters:
uri- the uri of the XML file to parse- Returns:
- the parsed region metadata
- Throws:
IOException- on error fetching or parsing the XML file
-
loadMetadataFromURI
@Deprecated public static RegionMetadata loadMetadataFromURI(URI uri, ClientConfiguration config) throws IOException
Deprecated.Loads a set of region metadata by downloading an XML file from the given URI and parsing it.- Parameters:
uri- the uri of the XML file to parseconfig- configuration for the HTTP client to use to fetch the file- Returns:
- the parsed region metadata
- Throws:
IOException- on error fetching or parsing the XML file
-
loadMetadataFromFile
@Deprecated public static RegionMetadata loadMetadataFromFile(File file) throws IOException
Deprecated.Loads a set of region metadata from an XML file on disk.- Parameters:
file- the file to load from- Returns:
- the loaded region metadata
- Throws:
IOException- on error opening or reading from the file
-
loadMetadataFromResource
@Deprecated public static RegionMetadata loadMetadataFromResource(String name) throws IOException
Deprecated.Loads a set of region metadata from an XML file stored as a resource of the classloader used to load the RegionUtils class.- Parameters:
name- the path of the resource, relative to the RegionUtils class- Returns:
- the parsed region metadata
- Throws:
IOException- if the resource is not found or cannot be parsed
-
loadMetadataFromResource
@Deprecated public static RegionMetadata loadMetadataFromResource(Class<?> clazz, String name) throws IOException
Deprecated.Loads a set of region metadata from an XML file stored as a resource of the classloader used to load the given class.- Parameters:
clazz- the class to use as a base for the resourcename- the path to the resource, relative to the given class- Returns:
- the parsed region metadata
- Throws:
IOException- if the resource is not found or cannot be parsed
-
loadMetadataFromResource
@Deprecated public static RegionMetadata loadMetadataFromResource(ClassLoader classLoader, String name) throws IOException
Deprecated.Loads a set of region metadata from an XML file stored as a resource of the given classloader.- Parameters:
classLoader- the class loader to load the resource fromname- the path to the resource- Returns:
- the parsed region metadata
- Throws:
IOException- if the resource is not found or cannot be parsed
-
loadMetadataFromInputStream
@Deprecated public static RegionMetadata loadMetadataFromInputStream(InputStream stream) throws IOException
Deprecated.Loads a set of region metadata from an arbitraryInputStreamcontaining an XML file.- Parameters:
stream- the stream to load from- Returns:
- the loaded region metadata
- Throws:
IOException- on error reading from the stream
-
init
@Deprecated public static void init()
Deprecated.in favor ofinitialize()This method no longer attempts to retrieve region metadata from CloudFront, as that file is no longer being maintained and the version bundled with the SDK is likely to be more up-to-date. It's deprecated to signal that it no longer has any possibility of retrieving a newer set of metadata than was previously loaded. If you are simply wanting to reinitialize from the bundled region metadata, callinitialize. If you want to maintain your own remote copy of the region metadata and periodically refresh it at runtime, callinitializeFromURI.
-
initializeFromURI
@Deprecated public static void initializeFromURI(URI uri)
Deprecated.Loads a set of region metadata by downloading an XML file from the given URI and parsing it.- Parameters:
uri- the uri of the XML file to parse- Throws:
AmazonClientException- on error
-
initializeFromURI
@Deprecated public static void initializeFromURI(URI uri, ClientConfiguration config)
Deprecated.Loads a set of region metadata by downloading an XML file from the given URI and parsing it.- Parameters:
uri- the uri of the XML file to parseconfig- configuration for the HTTP client to use to fetch the file- Throws:
AmazonClientException- on error
-
initializeFromFile
@Deprecated public static void initializeFromFile(File file)
Deprecated.Initializes the region metadata singleton from an XML file on disk.- Parameters:
file- the file to load from- Throws:
AmazonClientException- on error opening or reading from the file
-
initializeFromResource
@Deprecated public static void initializeFromResource(String name)
Deprecated.Initializes the region metadata singleton from an XML file stored as a resource of the classloader used to load the RegionUtils class.- Parameters:
name- the path of the resource, relative to the RegionUtils class- Throws:
AmazonClientException- on error
-
initializeFromResource
@Deprecated public static void initializeFromResource(Class<?> clazz, String name)
Deprecated.Initializes the region metadata singleton from the given resource.- Parameters:
clazz- the class to use as a base for the resourcename- the path to the resource, relative to the given class- Throws:
AmazonClientException- on error
-
initializeFromResource
@Deprecated public static void initializeFromResource(ClassLoader classLoader, String name)
Deprecated.Initializes the region metadata singleton from the given resource.- Parameters:
classLoader- the class loader to use to load the resourcename- the path to the resource- Throws:
AmazonClientException- on error
-
-