mybatis/spring — pull request #40 by nguyenvanthan (2014-07-29 16:41:31+00:00)
Title: add custom factory bean on MapperScan annotation

Hi !!
Can you have a look to this little contribution :-)

## Use case
We want to use our custom annotation on mapper interfaces to select the correct datasource at bean creation phase. Our datasource instances are not present in spring context.

## Problem
We use several datasources for our application but we want to scan all our mapper by convention with a spring java config. I see some attribute like *sqlSessionFactoryRef* or *sqlSessionTemplateRef* but it will make us have to declare a sqlSessionFactory for each datasource and declare a MapperScan for each different database.

## Resolve with this PR
We will be able to use this:
```java
@MapperScan(basePackages = "org.mybatis.spring.mapper", factoryBean = OurCustomFactoryBean.class)
```
*OurCustomFactoryBean* will override *getObject()* to choose the right datasource and return a mapper proxy with the selected sqlSessionFactory. The session factory is built by some custom internal stuffs.