public final class

ConfigHelper

extends Object
java.lang.Object
   ↳ org.hibernate.util.ConfigHelper

Class Overview

A simple class to centralize logic needed to locate config files on the system.

Summary

Public Methods
final static URL findAsResource(String path)
Try to locate a local URL representing the incoming path.
final static Properties getConfigProperties(String path)
Loads a properties instance based on the data at the incoming config location.
final static InputStream getConfigStream(String path)
Open an InputStream to the URL represented by the incoming path.
final 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)
final static URL locateConfig(String path)
Try to locate a local URL representing the incoming path.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

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.

Parameters
path The path representing the config location.
Returns
  • An appropriate URL or null.

public static final Properties getConfigProperties (String path)

Loads a properties instance based on the data at the incoming config location.

Parameters
path The path representing the config location.
Returns
  • The loaded properties instance.
Throws
HibernateException Unable to load properties from that resource.

public static final InputStream getConfigStream (String path)

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. openStream() is then called to obtain the stream.

Parameters
path The path representing the config location.
Returns
  • An input stream to the requested config resource.
Throws
HibernateException Unable to open stream to that resource.

public static final Reader getConfigStreamReader (String path)

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. openStream() is then called to obtain a stream, which is then wrapped in a Reader.

Parameters
path The path representing the config location.
Returns
  • An input stream to the requested config resource.
Throws
HibernateException Unable to open reader to that resource.

public static InputStream getResourceAsStream (String resource)

public static InputStream getUserResourceAsStream (String resource)

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.

Parameters
path The path representing the config location.
Returns
  • An appropriate URL or null.