com.miragesql.miragesql.integration.guice.MirageModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of miragesql-integration Show documentation
Show all versions of miragesql-integration Show documentation
Mirage-SQL Integration is an easy way to integrate Mirage-SQL with Spring, Guice or Seasar2
package com.miragesql.miragesql.integration.guice;
import com.miragesql.miragesql.SqlManager;
import com.miragesql.miragesql.session.Session;
import com.miragesql.miragesql.session.SessionFactory;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.matcher.Matchers;
/**
* The Module implementation to use Mirage-SQL with Google Guice.
*
* @author Naoki Takezoe
*/
public class MirageModule extends AbstractModule {
// @Override
protected void configure() {
bindInterceptor(
Matchers.any(),
Matchers.annotatedWith(Transactional.class),
new TransactionInterceptor());
}
@Provides
@Singleton
public Session getSession(){
return SessionFactory.getSession();
}
@Provides
@Singleton
public SqlManager getSqlManager(Session session){
return session.getSqlManager();
}
}