org.hibernate.util
Class ConfigHelper

java.lang.Object
  extended by 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.

Author:
Steve

Method Summary
static java.net.URL findAsResource(java.lang.String path)
          Try to locate a local URL representing the incoming path.
static java.util.Properties getConfigProperties(java.lang.String path)
          Loads a properties instance based on the data at the incoming config location.
static java.io.InputStream getConfigStream(java.lang.String path)
          Open an InputStream to the URL represented by the incoming path.
static java.io.Reader getConfigStreamReader(java.lang.String path)
          Open an Reader to the URL represented by the incoming path.
static java.io.InputStream getResourceAsStream(java.lang.String resource)
           
static java.io.InputStream getUserResourceAsStream(java.lang.String resource)
           
static java.net.URL locateConfig(java.lang.String path)
          Try to locate a local URL representing the incoming path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

locateConfig

public static final java.net.URL locateConfig(java.lang.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.

findAsResource

public static final java.net.URL findAsResource(java.lang.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.

getConfigStream

public static final java.io.InputStream getConfigStream(java.lang.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. 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.

getConfigStreamReader

public static final java.io.Reader getConfigStreamReader(java.lang.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. 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.

getConfigProperties

public static final java.util.Properties getConfigProperties(java.lang.String path)
                                                      throws HibernateException
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.

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String resource)

getUserResourceAsStream

public static java.io.InputStream getUserResourceAsStream(java.lang.String resource)


Copyright © 2008 Hibernate.org. All Rights Reserved.