net.leanix.dropkit.persistence.DropkitHibernateBundle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leanix-dropkit-persistence Show documentation
Show all versions of leanix-dropkit-persistence Show documentation
Base functionality for persistence in leanIX dropwizard-based services
package net.leanix.dropkit.persistence;
import com.google.common.collect.ImmutableList;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
import io.dropwizard.hibernate.HibernateBundle;
import io.dropwizard.hibernate.SessionFactoryFactory;
import org.hibernate.Interceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Implementation of HibernateBundle that set a Hibernate interceptor in
* the configure method.
* @param the dropizard configuration type
*/
public class DropkitHibernateBundle extends HibernateBundle {
private final Logger log = LoggerFactory.getLogger(DropkitHibernateBundle.class);
private final Interceptor interceptor;
public DropkitHibernateBundle(ImmutableList> entities, SessionFactoryFactory sessionFactoryFactory) {
super(entities, sessionFactoryFactory);
this.interceptor = null;
}
@Override
public DataSourceFactory getDataSourceFactory(T configuration) {
return configuration.getDataSourceFactory();
}
@Override
protected void configure(org.hibernate.cfg.Configuration configuration) {
if (interceptor != null) {
log.debug("setting hibernate interceptor");
configuration.setInterceptor(interceptor);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy