public abstract class BootstrapResourceUtils extends Object
The utility methods provided in this class are meant to be used throughout the CCS environment to load resources in the Bootstrap environment.
For a description on how to control the Bootstrap environment please refer to the following manual.
| Constructor and Description |
|---|
BootstrapResourceUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Set<String> |
findMatchingResources(String pattern)
Find all resources that match the provided regular expression pattern.
|
static Set<Object> |
getAllKeysInProperties(Properties props)
Utility method to fetch all the keys in a properties file, including its parent, to loop over them.
|
static Properties |
getBootstrapProperties(String fileName)
Utility function to fetch Properties in the Bootstrap environment.
|
static Properties |
getBootstrapProperties(String fileName,
Class clazz)
Utility function to fetch Properties in the Bootstrap environment.
|
static InputStream |
getBootstrapPropertiesInputStream(String fileName,
Class clazz)
Get an InputStream corresponding to the Bootstrap Properties object.
|
static InputStream |
getBootstrapResource(String resourceName)
Utility functions to look for resources (excluding Properties) in the Bootstrap environment.
|
static InputStream |
getBootstrapResource(String resourceName,
Class clazz)
Utility functions to look for resources (excluding Properties) in the Bootstrap environment.
|
static Properties |
getBootstrapSystemProperties()
Return the Bootstrap System Properties object.
|
static List<String> |
getOrderedListOfResourceDirectories()
Get the ordered list of resource directories.
|
static String |
getPathOfPropertiesFileInUserResourceDirectories(String propertyFileName)
Utility function to find the top most property file in the user provided
resource directories (as specified in the CCS_RESOURCE_PATH environment
variable).
|
static URL |
getResourceURL(String resourceName)
Utility function to find the URL of a resource by name.
|
static String |
getTopUserResourceDirectory()
Utility function to get the top User defined Resource Directory.
|
static List<String>[] |
separateArgumentsForOptions(String[] args,
org.apache.commons.cli.Options options) |
public static List<String>[] separateArgumentsForOptions(String[] args, org.apache.commons.cli.Options options)
public static Properties getBootstrapSystemProperties()
This function builds a Properties object by searching and chaining properties according to the following search criteria
public static String getPathOfPropertiesFileInUserResourceDirectories(String propertyFileName)
propertyFileName - The name of the property file to getpublic static URL getResourceURL(String resourceName) throws MalformedURLException
resourceName - The name of the resource getMalformedURLExceptionpublic static String getTopUserResourceDirectory()
public static Properties getBootstrapProperties(String fileName, Class clazz)
This function builds a Properties object by searching and chaining properties according to the following search criteria
fileName - The name of the properties file to load. This can be a path.clazz - The class on which getResourceAsStream is invoked for the classpath search. If null BootstrapResourceUtils.class is used.public static Properties getBootstrapProperties(String fileName)
This function is similar to #getBootstrapProperties(java.lang.String, boolean, java.lang.Class) .
In this case the Class object is set to null and it defaults to BootstrapResourceUtils.class.
fileName - The name of the properties file to load. This can be a path.#getBootstrapProperties(java.lang.String, boolean, java.lang.Class)public static InputStream getBootstrapPropertiesInputStream(String fileName, Class clazz)
This function is similar to #getBootstrapProperties(java.lang.String, boolean, java.lang.Class) .
Rather than a Properties object it returns the InputStream corresponsing to
that Properties object. This is done by invoking
on a ByteArrayOutputStream and then returning an ByteArrayInputStream.
fileName - The name of the properties file to load. This can be a path.clazz - The class on which getResourceAsStream is invoked for the classpath search. If null BootstrapResourceUtils.class is used.BootstrapResourceUtils#getBootstrapProperties(java.lang.String, boolean, java.lang.Class)public static InputStream getBootstrapResource(String resourceName, Class clazz)
This function will search for the desired resource following the search criteria described below. It will return an InputStream for the first resource found.
Search Criteria:
For Properties refer to {@link #getBootstrapProperties(java.lang.String, boolean,java.lang.Class).
resourceName - The name of the resource. This can be a path.clazz - The class on which getResourceAsStream is invoked for the
classpath search. If null BootstrapResourceUtils.class is used.public static InputStream getBootstrapResource(String resourceName)
Internally it invokes getBootstrapResource(java.lang.String,java.lang.Class) with Class
set to BootstrapResourceUtils.class.
resourceName - The name of the resource. This can be a path.getBootstrapResource(java.lang.String, java.lang.Class)public static Set<Object> getAllKeysInProperties(Properties props)
This method keeps into account if a Properties object has a parent and goes down the parent chain to fetch all the keys.
props - The Properties objectpublic static List<String> getOrderedListOfResourceDirectories()
public static Set<String> findMatchingResources(String pattern)
pattern - The regular expression pattern to be used in the search.Copyright © 2018 LSST. All rights reserved.