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

io.robe.admin.guice.module.HibernateModule Maven / Gradle / Ivy

There is a newer version: 0.5.0.0-1039
Show newest version
package io.robe.admin.guice.module;

import com.google.inject.AbstractModule;
import com.google.inject.Provider;
import io.robe.hibernate.RobeHibernateBundle;
import org.hibernate.SessionFactory;

/**
 * Default Guice bindings are done at this class.
 */
public class HibernateModule extends AbstractModule {

    private final RobeHibernateBundle bundle;

    public HibernateModule(RobeHibernateBundle bundle) {
        this.bundle = bundle;
    }

    @Override
    protected void configure() {

        bind(RobeHibernateBundle.class).toProvider(new Provider() {
            @Override
            public RobeHibernateBundle get() {
                return bundle;
            }
        });

        bind(SessionFactory.class).toProvider(new Provider() {
            @Override
            public SessionFactory get() {
                return bundle.getSessionFactory();
            }
        });
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy