All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ec.gob.senescyt.sniese.commons.applications.AplicacionPersistente Maven / Gradle / Ivy

There is a newer version: 2.0.5
Show newest version
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