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 abstract 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 3714 2011-03-19 20:18:34Z simone.tripodi $

Constructor Summary
MyBatisModule()
           
 
Method Summary
protected  AliasBinder addAlias(String alias)
          Add a user defined binding.
protected  void addInterceptorClass(Class<? extends org.apache.ibatis.plugin.Interceptor> interceptorClass)
          Adds the user defined myBatis interceptor plugins type, letting google-guice creating it.
protected  void addInterceptorsClasses(Collection<Class<? extends org.apache.ibatis.plugin.Interceptor>> interceptorsClasses)
          Adds the user defined MyBatis interceptors plugins types, letting google-guice creating them.
protected  void addInterceptorsClasses(String packageName)
          Adds the user defined MyBatis interceptors plugins types in the given package, letting google-guice creating them.
protected  void addMapperClass(Class<?> mapperClass)
          Adds the user defined mapper classes.
protected  void addMapperClasses(Collection<Class<?>> mapperClasses)
          Adds the user defined mapper classes.
protected  void addMapperClasses(String packageName)
          Adds the user defined mapper classes.
protected  void addMapperClasses(String packageName, org.apache.ibatis.io.ResolverUtil.Test test)
          Adds the user defined mapper classes.
protected  void addSimpleAlias(Class<?> type)
          Adding simple aliases means that every specified class will be bound using the simple class name, i.e.
protected  void addSimpleAliases(Collection<Class<?>> types)
          Adding simple aliases means that every specified class will be bound using the simple class name, i.e.
protected  void addSimpleAliases(String packageName)
          Adds all Classes in the given package as a simple alias.
protected  void addSimpleAliases(String packageName, org.apache.ibatis.io.ResolverUtil.Test test)
          Adds all Classes in the given package as a simple alias.
protected  void aggressiveLazyLoading(boolean aggressiveLazyLoading)
           
protected  void autoMappingBehavior(org.apache.ibatis.session.AutoMappingBehavior autoMappingBehavior)
           
protected  void bindDataSourceProvider(javax.inject.Provider<DataSource> dataSourceProvider)
           
protected  void bindDataSourceProvider(com.google.inject.Provider<DataSource> dataSourceProvider)
           
protected  void bindDataSourceProviderType(Class<? extends javax.inject.Provider<DataSource>> dataSourceProviderType)
          Set the DataSource Provider type has to be bound.
protected  void bindObjectFactoryType(Class<? extends org.apache.ibatis.reflection.factory.ObjectFactory> objectFactoryType)
          Sets the ObjectFactory class.
protected  void bindTransactionFactory(javax.inject.Provider<org.apache.ibatis.transaction.TransactionFactory> transactionFactoryProvider)
           
protected  void bindTransactionFactory(com.google.inject.Provider<org.apache.ibatis.transaction.TransactionFactory> transactionFactoryProvider)
           
protected  void bindTransactionFactoryType(Class<? extends org.apache.ibatis.transaction.TransactionFactory> transactionFactoryType)
          Set the TransactionFactory type has to be bound.
protected  void configure()
          
protected  void environmentId(String environmentId)
          Set the MyBatis configuration environment id.
protected  void executorType(org.apache.ibatis.session.ExecutorType executorType)
           
protected  void failFast(boolean failFast)
           
protected  TypeHandlerBinder handleType(Class<?> type)
          Add a user defined Type Handler letting google-guice creating it.
protected abstract  void initialize()
           
protected  void lazyLoadingEnabled(boolean lazyLoadingEnabled)
           
protected  void multipleResultSetsEnabled(boolean multipleResultSetsEnabled)
           
protected  void useCacheEnabled(boolean useCacheEnabled)
           
protected  void useColumnLabel(boolean useColumnLabel)
           
protected  void useGeneratedKeys(boolean useGeneratedKeys)
           
 
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()
Method Detail

environmentId

protected final void environmentId(String environmentId)
Set the MyBatis configuration environment id.

Parameters:
environmentId - the MyBatis configuration environment id

lazyLoadingEnabled

protected final void lazyLoadingEnabled(boolean lazyLoadingEnabled)
Parameters:
lazyLoadingEnabled -

aggressiveLazyLoading

protected final void aggressiveLazyLoading(boolean aggressiveLazyLoading)
Parameters:
aggressiveLazyLoading -

multipleResultSetsEnabled

protected final void multipleResultSetsEnabled(boolean multipleResultSetsEnabled)
Parameters:
multipleResultSetsEnabled -

useGeneratedKeys

protected final void useGeneratedKeys(boolean useGeneratedKeys)
Parameters:
useGeneratedKeys -

useColumnLabel

protected final void useColumnLabel(boolean useColumnLabel)
Parameters:
useColumnLabel -

useCacheEnabled

protected final void useCacheEnabled(boolean useCacheEnabled)
Parameters:
useCacheEnabled -

failFast

protected final void failFast(boolean failFast)
Parameters:
failFast -

executorType

protected final void executorType(org.apache.ibatis.session.ExecutorType executorType)
Parameters:
executorType -

autoMappingBehavior

protected final void autoMappingBehavior(org.apache.ibatis.session.AutoMappingBehavior autoMappingBehavior)
Parameters:
autoMappingBehavior -

bindDataSourceProviderType

protected final void bindDataSourceProviderType(Class<? extends javax.inject.Provider<DataSource>> dataSourceProviderType)
Set the DataSource Provider type has to be bound.

Parameters:
dataSourceProviderType - the DataSource Provider type

bindDataSourceProvider

protected final void bindDataSourceProvider(javax.inject.Provider<DataSource> dataSourceProvider)
Parameters:
dataSourceProvider -

bindDataSourceProvider

protected final void bindDataSourceProvider(com.google.inject.Provider<DataSource> dataSourceProvider)
Parameters:
dataSourceProvider -

bindTransactionFactoryType

protected final void bindTransactionFactoryType(Class<? extends org.apache.ibatis.transaction.TransactionFactory> transactionFactoryType)
Set the TransactionFactory type has to be bound.

Parameters:
transactionFactoryType - the TransactionFactory type

bindTransactionFactory

protected final void bindTransactionFactory(javax.inject.Provider<org.apache.ibatis.transaction.TransactionFactory> transactionFactoryProvider)
Parameters:
transactionFactoryProvider -

bindTransactionFactory

protected final void bindTransactionFactory(com.google.inject.Provider<org.apache.ibatis.transaction.TransactionFactory> transactionFactoryProvider)
Parameters:
transactionFactoryProvider -

bindObjectFactoryType

protected final void bindObjectFactoryType(Class<? extends org.apache.ibatis.reflection.factory.ObjectFactory> objectFactoryType)
Sets the ObjectFactory class.

Parameters:
objectFactoryType - the ObjectFactory type

addAlias

protected final AliasBinder addAlias(String alias)
Add a user defined binding.

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

addSimpleAlias

protected final void addSimpleAlias(Class<?> type)
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 - the specified types have to be bind

addSimpleAliases

protected final void addSimpleAliases(Collection<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 - the specified types have to be bind

addSimpleAliases

protected final void addSimpleAliases(String packageName,
                                      org.apache.ibatis.io.ResolverUtil.Test test)
Adds all Classes in the given package as a simple alias. Adding simple aliases means that every specified class will be bound using the simple class name, i.e. com.acme.Foo becomes Foo.

Parameters:
packageName - the specified package to search for classes to alias.
test - a test to run against the objects found in the specified package

addSimpleAliases

protected final void addSimpleAliases(String packageName)
Adds all Classes in the given package as a simple alias. Adding simple aliases means that every specified class will be bound using the simple class name, i.e. com.acme.Foo becomes Foo.

Parameters:
packageName - the specified package to search for classes to alias

handleType

protected final TypeHandlerBinder handleType(Class<?> type)
Add a user defined Type Handler letting google-guice creating it.

Parameters:
type - the specified type has to be handled.
handler - the handler type.

addInterceptorClass

protected final void addInterceptorClass(Class<? extends org.apache.ibatis.plugin.Interceptor> interceptorClass)
Adds the user defined myBatis interceptor plugins type, letting google-guice creating it.

Parameters:
interceptorClasse - The user defined MyBatis interceptor plugin type

addInterceptorsClasses

protected final void addInterceptorsClasses(Collection<Class<? extends org.apache.ibatis.plugin.Interceptor>> interceptorsClasses)
Adds the user defined MyBatis interceptors plugins types, letting google-guice creating them.

Parameters:
interceptorsClasses - the user defined MyBatis Interceptors plugins types

addInterceptorsClasses

protected final void addInterceptorsClasses(String packageName)
Adds the user defined MyBatis interceptors plugins types in the given package, letting google-guice creating them.

Parameters:
packageName - the package where looking for Interceptors plugins types.

addMapperClass

protected final void addMapperClass(Class<?> mapperClass)
Adds the user defined mapper classes.

Parameters:
mapperClasses - the user defined mapper classes.

addMapperClasses

protected final void addMapperClasses(Collection<Class<?>> mapperClasses)
Adds the user defined mapper classes.

Parameters:
mapperClasses - the user defined mapper classes

addMapperClasses

protected final void addMapperClasses(String packageName)
Adds the user defined mapper classes.

Parameters:
packageName - the specified package to search for mappers to add.

addMapperClasses

protected final void addMapperClasses(String packageName,
                                      org.apache.ibatis.io.ResolverUtil.Test test)
Adds the user defined mapper classes.

Parameters:
packageName - the specified package to search for mappers to add.
test - a test to run against the objects found in the specified package.

configure

protected final void configure()

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

initialize

protected abstract void initialize()


Copyright © 2010-2011 MyBatis.org. All Rights Reserved.