Last active
November 28, 2015 12:54
-
-
Save marcus-nl/7ba3d360ad399d07d431 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HibernateSchemaManagementTool implements SchemaManagementTool, ServiceRegistryAwareService { | |
private ServiceRegistry serviceRegistry; | |
@Override | |
public SchemaCreator getSchemaCreator(Map options) { | |
// TODO use AvailableSettings.SCHEMA_CREATE_FILTER | |
return new SchemaCreatorImpl( getSchemaFilter( options, "hibernate.schema.create.filter" ) ); | |
} | |
@Override | |
public SchemaDropper getSchemaDropper(Map options) { | |
return new SchemaDropperImpl( getSchemaFilter( options, "hibernate.schema.drop.filter" ) ); | |
} | |
@Override | |
public SchemaMigrator getSchemaMigrator(Map options) { | |
return new SchemaMigratorImpl( getSchemaFilter( options, "hibernate.schema.migrate.filter" ) ); | |
} | |
@Override | |
public SchemaValidator getSchemaValidator(Map options) { | |
final Dialect dialect = serviceRegistry.getService( JdbcServices.class ).getDialect(); | |
return new SchemaValidatorImpl(dialect); | |
} | |
private SchemaFilter getSchemaFilter(Map options, String key) { | |
return serviceRegistry.getService( StrategySelector.class ) | |
.resolveDefaultableStrategy( SchemaFilter.class, options.get( key ), DefaultSchemaFilter.INSTANCE ); | |
} | |
@Override | |
public void injectServices(ServiceRegistryImplementor serviceRegistry) { | |
this.serviceRegistry = serviceRegistry; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment