public void afterPropertiesSet() throws Exception {
    if (this.lobHandler != null) {
      // Make given LobHandler available for SqlMapClient configuration.
      // Do early because because mapping resource might refer to custom types.
      configTimeLobHandlerHolder.set(this.lobHandler);
    }

    try {
      this.sqlMapClient =
          buildSqlMapClient(
              this.configLocations, this.mappingLocations, this.sqlMapClientProperties);

      // Tell the SqlMapClient to use the given DataSource, if any.
      if (this.dataSource != null) {
        TransactionConfig transactionConfig =
            (TransactionConfig) this.transactionConfigClass.newInstance();
        DataSource dataSourceToUse = this.dataSource;
        if (this.useTransactionAwareDataSource
            && !(this.dataSource instanceof TransactionAwareDataSourceProxy)) {
          dataSourceToUse = new TransactionAwareDataSourceProxy(this.dataSource);
        }
        transactionConfig.setDataSource(dataSourceToUse);
        transactionConfig.initialize(this.transactionConfigProperties);
        applyTransactionConfig(this.sqlMapClient, transactionConfig);
      }
    } finally {
      if (this.lobHandler != null) {
        // Reset LobHandler holder.
        configTimeLobHandlerHolder.remove();
      }
    }
  }
 /**
  * Apply the given iBATIS TransactionConfig to the SqlMapClient.
  *
  * <p>The default implementation casts to ExtendedSqlMapClient, retrieves the maximum number of
  * concurrent transactions from the SqlMapExecutorDelegate, and sets an iBATIS TransactionManager
  * with the given TransactionConfig.
  *
  * @param sqlMapClient the SqlMapClient to apply the TransactionConfig to
  * @param transactionConfig the iBATIS TransactionConfig to apply
  * @see com.ibatis.sqlmap.engine.impl.ExtendedSqlMapClient
  * @see com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate#getMaxTransactions
  * @see com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate#setTxManager
  */
 protected void applyTransactionConfig(
     SqlMapClient sqlMapClient, TransactionConfig transactionConfig) {
   if (!(sqlMapClient instanceof ExtendedSqlMapClient)) {
     throw new IllegalArgumentException(
         "Cannot set TransactionConfig with DataSource for SqlMapClient if not of type "
             + "ExtendedSqlMapClient: "
             + sqlMapClient);
   }
   ExtendedSqlMapClient extendedClient = (ExtendedSqlMapClient) sqlMapClient;
   transactionConfig.setMaximumConcurrentTransactions(
       extendedClient.getDelegate().getMaxTransactions());
   extendedClient.getDelegate().setTxManager(new TransactionManager(transactionConfig));
 }