org.hibernate.boot.archive.internal.UrlInputStreamAccess Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
Hibernate's core ORM functionality
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.boot.archive.internal;
import java.io.InputStream;
import java.net.URL;
import org.hibernate.HibernateException;
import org.hibernate.boot.archive.spi.InputStreamAccess;
/**
* @author Steve Ebersole
*/
public class UrlInputStreamAccess implements InputStreamAccess {
private final URL url;
public UrlInputStreamAccess(URL url) {
this.url = url;
}
@Override
public String getStreamName() {
return url.toExternalForm();
}
@Override
public InputStream accessInputStream() {
try {
return url.openStream();
}
catch (Exception e) {
throw new HibernateException( "Could not open url stream : " + url.toExternalForm() );
}
}
}