Package com.ibm.di.util
Class ResourceLocator
- java.lang.Object
-
- com.ibm.di.util.ResourceLocator
-
public class ResourceLocator extends java.lang.Object
A utility class for working with resources.
Note: This class is for internal usage only. Any dependency from the end-user will not be supported. Changes to this class will happen without a warning.- Since:
- 7.1
-
-
Constructor Summary
Constructors Constructor Description ResourceLocator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.net.URL
getResourceFromClassLoaderChain(java.lang.String resource)
This method looks for a resource using the ClassLoaders chain.static java.net.URL
getResourceURL(java.lang.String resourceName)
Finds a resource URL by its name.static java.net.URL
resolveLocalURL(java.net.URL resource)
If we are inside an OSGi context the URL will not be a file but a bundleresource.
-
-
-
Method Detail
-
getResourceURL
public static java.net.URL getResourceURL(java.lang.String resourceName)
Finds a resource URL by its name. The lookup is made by usinggetResourceFromClassLoaderChain(String)
method. If the name does not start with a leading slash and the resource was not found the first time another try will be made by prefixing the name with a forward slash. If the resource exists and an URL is obtained it is then resolved using theresolveLocalURL(URL)
method.- Parameters:
resourceName
- the name to look for.- Returns:
- the URL of the resource.
-
getResourceFromClassLoaderChain
public static java.net.URL getResourceFromClassLoaderChain(java.lang.String resource)
This method looks for a resource using the ClassLoaders chain. The first classloader that is asked is the context loader, then the loader that has loaded theResourceLocator
class and finally the system loader.- Parameters:
resource
- the name of the resource to look for.- Returns:
- the url to the resource or
null
if not found. The first classloader responding with non-null value is the winner and its response is returned.
-
resolveLocalURL
public static java.net.URL resolveLocalURL(java.net.URL resource)
If we are inside an OSGi context the URL will not be a file but a bundleresource. Use this method to convert that URL to a file. If the url is already a File or the OSGi context is not present this method will not perform anything and the provided URL will be returned. The access to the eclipse code is done through reflection so it is safe to include this code in non-osgi context.- Parameters:
resource
- the URL to convert- Returns:
- a connection to the jar file containing the passes resource.
- Throws:
java.io.IOException
- if there is a problem to connect to the jar file.
-
-