/** * Open an InputStream to the URL represented by the incoming path. First makes a call * to {@link #locateConfig(java.lang.String)} in order to find an appropriate URL. * {@link java.net.URL#openStream()} is then called to obtain the stream. * * @param path The path representing the config location. * * @return An input stream to the requested config resource. * * @throws HibernateException Unable to open stream to that resource. */ public static InputStream getConfigStream(final String path) throws HibernateException { final URL url = ConfigHelper.locateConfig( path ); if ( url == null ) { String msg = LOG.unableToLocateConfigFile( path ); LOG.error( msg ); throw new HibernateException( msg ); } try { return url.openStream(); } catch (IOException e) { throw new HibernateException( "Unable to open config file: " + path, e ); } }
/** Open an InputStream to the URL represented by the incoming path. First makes a call * to {@link #locateConfig(java.lang.String)} in order to find an appropriate URL. * {@link java.net.URL#openStream()} is then called to obtain the stream. * * @param path The path representing the config location. * @return An input stream to the requested config resource. * @throws HibernateException Unable to open stream to that resource. */ public static InputStream getConfigStream(final String path) throws HibernateException { final URL url = ConfigHelper.locateConfig(path); if (url == null) { String msg = LOG.unableToLocateConfigFile(path); LOG.error(msg); throw new HibernateException(msg); } try { return url.openStream(); } catch(IOException e) { throw new HibernateException("Unable to open config file: " + path, e); } }
/** Open an InputStream to the URL represented by the incoming path. First makes a call * to {@link #locateConfig(java.lang.String)} in order to find an appropriate URL. * {@link java.net.URL#openStream()} is then called to obtain the stream. * * @param path The path representing the config location. * @return An input stream to the requested config resource. * @throws HibernateException Unable to open stream to that resource. */ public static InputStream getConfigStream(final String path) throws HibernateException { final URL url = ConfigHelper.locateConfig(path); if (url == null) { String msg = LOG.unableToLocateConfigFile(path); LOG.error(msg); throw new HibernateException(msg); } try { return url.openStream(); } catch(IOException e) { throw new HibernateException("Unable to open config file: " + path, e); } }
/** * Open an InputStream to the URL represented by the incoming path. First makes a call * to {@link #locateConfig(java.lang.String)} in order to find an appropriate URL. * {@link java.net.URL#openStream()} is then called to obtain the stream. * * @param path The path representing the config location. * * @return An input stream to the requested config resource. * * @throws HibernateException Unable to open stream to that resource. */ public static InputStream getConfigStream(final String path) throws HibernateException { final URL url = ConfigHelper.locateConfig( path ); if ( url == null ) { String msg = LOG.unableToLocateConfigFile( path ); LOG.error( msg ); throw new HibernateException( msg ); } try { return url.openStream(); } catch (IOException e) { throw new HibernateException( "Unable to open config file: " + path, e ); } }
private void init() { Krausening krausening = Krausening.getInstance(); Properties hibernateProperties = krausening.getProperties("hibernate.properties"); if (hibernateProperties == null) { LOGGER.warn("A hibernate.properties file was not found in Krausening!"); } else if (hibernateProperties.isEmpty()) { LOGGER.warn("No properties are defined within the hibernate.properties file in Krausening!"); } URL configUrl = ConfigHelper.locateConfig(CONFIG); Configuration hibernateConfiguration = new Configuration(); hibernateConfiguration.configure(configUrl); hibernateConfiguration.addProperties(hibernateProperties); StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(); registryBuilder.applySettings(hibernateConfiguration.getProperties()); serviceRegistry = registryBuilder.build(); sessionFactory = hibernateConfiguration.buildSessionFactory(serviceRegistry); }