/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * Copyright (c) 2013, Red Hat Inc. or third-party contributors as
 * indicated by the @author tags or express copyright attribution
 * statements applied by the authors.  All third-party contributions are
 * distributed under license by Red Hat Inc.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package org.hibernate.jpa.internal.schemagen;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import javax.persistence.PersistenceException;

import org.jboss.logging.Logger;

ScriptSourceInput implementation for URL references. A reader is opened here and then explicitly closed on release.
Author:Christian Beikov, Steve Ebersole
/** * ScriptSourceInput implementation for URL references. A reader is opened here and then explicitly closed on * {@link #release}. * * @author Christian Beikov * @author Steve Ebersole */
public class ScriptSourceInputFromUrl extends ScriptSourceInputFromReader implements ScriptSourceInput { private static final Logger log = Logger.getLogger( ScriptSourceInputFromFile.class );
Constructs a ScriptSourceInputFromUrl instance
Params:
  • url – The url to read from
/** * Constructs a ScriptSourceInputFromUrl instance * * @param url The url to read from */
public ScriptSourceInputFromUrl(URL url) { super( toReader( url ) ); } @Override public void release() { try { reader().close(); } catch (IOException e) { log.warn( "Unable to close file reader for generation script source" ); } } private static Reader toReader(URL url) { try { return new InputStreamReader( url.openStream() ); } catch (IOException e) { throw new PersistenceException( "Unable to open specified script source url [" + url + "] for reading" ); } } }