org.mybatis.guice
Class MyBatisModule

java.lang.Object
  extended by com.google.inject.AbstractModule
      extended by org.mybatis.guice.MyBatisModule
All Implemented Interfaces:
com.google.inject.Module

public final class MyBatisModule
extends com.google.inject.AbstractModule

Easy to use helper Module that alleviates users to write the boilerplate google-guice bindings to create the SqlSessionFactory.

Version:
$Id: MyBatisModule.java 2231 2010-08-03 20:01:52Z simone.tripodi $

Constructor Summary
MyBatisModule(Class<? extends com.google.inject.Provider<DataSource>> dataSourceProviderClass)
          Creates a new module that binds all the needed modules to create the SqlSessionFactory, injecting all the required components, using the JdbcTransactionFactoryProvider as default transaction factory provider.
MyBatisModule(Class<? extends com.google.inject.Provider<DataSource>> dataSourceProviderClass, Class<? extends com.google.inject.Provider<org.apache.ibatis.transaction.TransactionFactory>> transactionFactoryProviderClass)
          Creates a new module that binds all the needed modules to create the SqlSessionFactory, injecting all the required components.
 
Method Summary
 MyBatisModule addAlias(String alias, Class<?> clazz)
          Add a user defined binding.
 MyBatisModule addInterceptorsClasses(Class<? extends org.apache.ibatis.plugin.Interceptor>... interceptorsClasses)
          Adds the user defined iBatis interceptors plugins types, letting google-guice creating them.
 MyBatisModule addMapperClasses(Class<?>... mapperClasses)
          Adds the user defined mapper classes.
 MyBatisModule addSimpleAliases(Class<?>... types)
          Adding simple aliases means that every specified class will be bound using the simple class name, i.e.
 MyBatisModule addTypeHandler(Class<?> type, Class<? extends org.apache.ibatis.type.TypeHandler> handler)
          Add a user defined Type Handler letting google-guice creating it.
protected  void configure()
          
 MyBatisModule setObjectFactoryProviderClass(Class<? extends com.google.inject.Provider<org.apache.ibatis.reflection.factory.ObjectFactory>> objectFactoryProviderClass)
          Sets the ObjectFactory provider class.
 
Methods inherited from class com.google.inject.AbstractModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindScope, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyBatisModule

public MyBatisModule(Class<? extends com.google.inject.Provider<DataSource>> dataSourceProviderClass)
Creates a new module that binds all the needed modules to create the SqlSessionFactory, injecting all the required components, using the JdbcTransactionFactoryProvider as default transaction factory provider.

Parameters:
dataSourceProviderClass - the DataSource Provider class reference.

MyBatisModule

public MyBatisModule(Class<? extends com.google.inject.Provider<DataSource>> dataSourceProviderClass,
                     Class<? extends com.google.inject.Provider<org.apache.ibatis.transaction.TransactionFactory>> transactionFactoryProviderClass)
Creates a new module that binds all the needed modules to create the SqlSessionFactory, injecting all the required components.

Parameters:
dataSourceProviderClass - the DataSource Provider class reference.
transactionFactoryProviderClass - the TransactionFactory Provider class reference.
Method Detail

addSimpleAliases

public MyBatisModule addSimpleAliases(Class<?>... types)
Adding simple aliases means that every specified class will be bound using the simple class name, i.e. com.acme.Foo becomes Foo.

Parameters:
types - he specified types have to be bind.
Returns:
this SqlSessionFactoryModule instance.

addAlias

public MyBatisModule addAlias(String alias,
                              Class<?> clazz)
Add a user defined binding.

Parameters:
alias - the string type alias
clazz - the type has to be bound.

addTypeHandler

public MyBatisModule addTypeHandler(Class<?> type,
                                    Class<? extends org.apache.ibatis.type.TypeHandler> handler)
Add a user defined Type Handler letting google-guice creating it.

Parameters:
type - the specified type has to be handled.
handler - the handler type.
Returns:
this SqlSessionFactoryModule instance.

addInterceptorsClasses

public MyBatisModule addInterceptorsClasses(Class<? extends org.apache.ibatis.plugin.Interceptor>... interceptorsClasses)
Adds the user defined iBatis interceptors plugins types, letting google-guice creating them.

Parameters:
interceptorsClasses - the user defined iBatis interceptors plugins types.
Returns:
this SqlSessionFactoryModule instance.

addMapperClasses

public MyBatisModule addMapperClasses(Class<?>... mapperClasses)
Adds the user defined mapper classes.

Parameters:
mapperClasses - the user defined mapper classes.
Returns:
this SqlSessionFactoryModule instance.

setObjectFactoryProviderClass

public MyBatisModule setObjectFactoryProviderClass(Class<? extends com.google.inject.Provider<org.apache.ibatis.reflection.factory.ObjectFactory>> objectFactoryProviderClass)
Sets the ObjectFactory provider class.

Parameters:
objectFactoryProviderClass - the ObjectFactory provider class.
Returns:
this SqlSessionFactoryModule instance.

configure

protected void configure()

Specified by:
configure in class com.google.inject.AbstractModule


Copyright © 2010 MyBatis.org. All Rights Reserved.