ec.gob.senescyt.sniese.commons.applications.AplicacionPersistente Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sniese-commons Show documentation
Show all versions of sniese-commons Show documentation
Librería que contiene clases de uso comun para sniese hechos en dropwizard
package ec.gob.senescyt.sniese.commons.applications;
import com.google.common.annotations.VisibleForTesting;
import ec.gob.senescyt.sniese.commons.bundles.DBMigrationsBundle;
import ec.gob.senescyt.sniese.commons.configurations.ConfiguracionSnieseBase;
import ec.gob.senescyt.sniese.commons.exceptions.mappers.DBConstraintViolationMapper;
import ec.gob.senescyt.sniese.commons.exceptions.mappers.TransientPropertyValueExceptionMapper;
import io.dropwizard.hibernate.HibernateBundle;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.hibernate.SessionFactory;
public class AplicacionPersistente extends DecoradorAplicacion {
private HibernateBundle hibernateBundle;
public AplicacionPersistente(DecoradorAplicacion siguiente, HibernateBundle hibernateBundle) {
super(siguiente);
this.hibernateBundle = hibernateBundle;
}
@Override
public void inicializar(Bootstrap bootstrap) {
bootstrap.addBundle(hibernateBundle);
bootstrap.addBundle(new DBMigrationsBundle());
}
@Override
public void ejecutar(ConfiguracionSnieseBase configuracion, Environment ambiente) {
ambiente.jersey().register(new DBConstraintViolationMapper());
ambiente.jersey().register(new TransientPropertyValueExceptionMapper());
}
@VisibleForTesting
public SessionFactory getSessionFactory() {
return hibernateBundle.getSessionFactory();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy