org.hibernate.util
Class ConfigHelper
java.lang.Object
org.hibernate.util.ConfigHelper
public final class ConfigHelper
extends java.lang.Object
A simple class to centralize logic needed to locate config files on the system.
static URL | findAsResource(String path) - Try to locate a local URL representing the incoming path.
|
static Properties | getConfigProperties(String path) - Loads a properties instance based on the data at the incoming config location.
|
static InputStream | getConfigStream(String path) - Open an InputStream to the URL represented by the incoming path.
|
static Reader | getConfigStreamReader(String path) - Open an Reader to the URL represented by the incoming path.
|
static InputStream | getResourceAsStream(String resource)
|
static InputStream | getUserResourceAsStream(String resource)
|
static URL | locateConfig(String path) - Try to locate a local URL representing the incoming path.
|
findAsResource
public static final URL findAsResource(String path)
Try to locate a local URL representing the incoming path.
This method only attempts to locate this URL as a
java system resource.
path
- The path representing the config location.
- An appropriate URL or null.
getConfigProperties
public static final Properties getConfigProperties(String path)
throws HibernateException
Loads a properties instance based on the data at the incoming config location.
path
- The path representing the config location.
- The loaded properties instance.
getConfigStream
public static final InputStream getConfigStream(String path)
throws HibernateException
Open an InputStream to the URL represented by the incoming path. First makes a call
to locateConfig(java.lang.String)
in order to find an appropriate URL.
java.net.URL.openStream()
is then called to obtain the stream.
path
- The path representing the config location.
- An input stream to the requested config resource.
getConfigStreamReader
public static final Reader getConfigStreamReader(String path)
throws HibernateException
Open an Reader to the URL represented by the incoming path. First makes a call
to locateConfig(java.lang.String)
in order to find an appropriate URL.
java.net.URL.openStream()
is then called to obtain a stream, which is then
wrapped in a Reader.
path
- The path representing the config location.
- An input stream to the requested config resource.
getResourceAsStream
public static InputStream getResourceAsStream(String resource)
getUserResourceAsStream
public static InputStream getUserResourceAsStream(String resource)
locateConfig
public static final URL locateConfig(String path)
Try to locate a local URL representing the incoming path. The first attempt
assumes that the incoming path is an actual URL string (file://, etc). If this
does not work, then the next attempts try to locate this UURL as a java system
resource.
path
- The path representing the config location.
- An appropriate URL or null.