Skip to content

Commit

Permalink
HHH-13210 Don't log about running a script of type ScriptSourceInputN…
Browse files Browse the repository at this point in the history
…onExistentImpl
  • Loading branch information
Sanne authored and gsmet committed Jan 17, 2019
1 parent e8b88f5 commit 9c63819
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
Expand Up @@ -463,7 +463,6 @@ private void applyImportSources(

if ( importScriptSetting != null ) {
final ScriptSourceInput importScriptInput = interpretScriptSourceSetting( importScriptSetting, classLoaderService, charsetName );
log.executingImportScript( importScriptInput.toString() );
importScriptInput.prepare();
try {
for ( String command : importScriptInput.read( commandExtractor ) ) {
Expand All @@ -490,7 +489,6 @@ private void applyImportSources(
final ScriptSourceInput importScriptInput = interpretLegacyImportScriptSetting( resourceName, classLoaderService, charsetName );
importScriptInput.prepare();
try {
log.executingImportScript( importScriptInput.toString() );
for ( String command : importScriptInput.read( commandExtractor ) ) {
applySqlString( command, formatter, options, targets );
}
Expand Down
Expand Up @@ -11,7 +11,10 @@
import java.util.Collections;
import java.util.List;

import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor;
import org.hibernate.tool.schema.internal.SchemaCreatorImpl;
import org.hibernate.tool.schema.spi.ScriptSourceInput;

/**
Expand All @@ -20,13 +23,18 @@
* @author Steve Ebersole
*/
public abstract class AbstractScriptSourceInput implements ScriptSourceInput {

private static final CoreMessageLogger log = CoreLogging.messageLogger( SchemaCreatorImpl.class );

protected abstract Reader reader();

@Override
public void prepare() {
// by default there is nothing to do
log.executingImportScript( getScriptDescription() );
}

protected abstract String getScriptDescription();

@Override
public List<String> read(ImportSqlCommandExtractor commandExtractor) {
final String[] commands = commandExtractor.extractCommands( reader() );
Expand Down
Expand Up @@ -56,6 +56,11 @@ public void prepare() {
this.reader = toReader( file, charsetName );
}

@Override
protected String getScriptDescription() {
return file.getAbsolutePath();
}

@SuppressWarnings("ResultOfMethodCallIgnored")
private static Reader toReader(File file, String charsetName) {
if ( ! file.exists() ) {
Expand Down
Expand Up @@ -32,6 +32,11 @@ protected Reader reader() {
return reader;
}

@Override
protected String getScriptDescription() {
return "[injected ScriptSourceInputFromReader script]";
}

@Override
public String toString() {
return "ScriptSourceInputFromReader()";
Expand Down
Expand Up @@ -65,6 +65,11 @@ public void prepare() {
}
}

@Override
protected String getScriptDescription() {
return url.toExternalForm();
}

@Override
public void release() {
try {
Expand Down
Expand Up @@ -17,8 +17,9 @@
* @author Steve Ebersole
*/
public interface ScriptSourceInput {

/**
* Prepare source for use.
* Prepare source for use, and log that this script is about to be imported.
*/
void prepare();

Expand Down

0 comments on commit 9c63819

Please sign in to comment.