Java Doc for SqlMapClientFactoryBean.java in  » J2EE » spring-framework-2.0.6 » org » springframework » orm » ibatis » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.orm.ibatis 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.orm.ibatis.SqlMapClientFactoryBean

SqlMapClientFactoryBean
public class SqlMapClientFactoryBean implements FactoryBean,InitializingBean(Code)
org.springframework.beans.factory.FactoryBean that creates an iBATIS com.ibatis.sqlmap.client.SqlMapClient . This is the usual way to set up a shared iBATIS SqlMapClient in a Spring application context; the SqlMapClient can then be passed to iBATIS-based DAOs via dependency injection.

Either org.springframework.jdbc.datasource.DataSourceTransactionManager or org.springframework.transaction.jta.JtaTransactionManager can be used for transaction demarcation in combination with a SqlMapClient, with JTA only necessary for transactions which span multiple databases.

Allows for specifying a DataSource at the SqlMapClient level. This is preferable to per-DAO DataSource references, as it allows for lazy loading and avoids repeated DataSource references in every DAO.

Note: As of Spring 2.0.2, this class explicitly supports iBATIS 2.3. Backwards compatibility with iBATIS 2.1 and 2.2 is preserved for the time being, through corresponding reflective checks.
author:
   Juergen Hoeller
since:
   24.02.2004
See Also:   SqlMapClientFactoryBean.setConfigLocation
See Also:   SqlMapClientFactoryBean.setDataSource
See Also:   SqlMapClientTemplate.setSqlMapClient
See Also:   SqlMapClientTemplate.setDataSource




Constructor Summary
public  SqlMapClientFactoryBean()
    

Method Summary
public  voidafterPropertiesSet()
    
protected  voidapplyTransactionConfig(SqlMapClient sqlMapClient, TransactionConfig transactionConfig)
     Apply the given iBATIS TransactionConfig to the SqlMapClient.
protected  SqlMapClientbuildSqlMapClient(Resource configLocation, Properties properties)
     Build a SqlMapClient instance based on the given standard configuration.
public static  LobHandlergetConfigTimeLobHandler()
     Return the LobHandler for the currently configured iBATIS SqlMapClient, to be used by TypeHandler implementations like ClobStringTypeHandler.

This instance will be set before initialization of the corresponding SqlMapClient, and reset immediately afterwards.

public  ObjectgetObject()
    
public  ClassgetObjectType()
    
public  booleanisSingleton()
    
public  voidsetConfigLocation(Resource configLocation)
     Set the location of the iBATIS SqlMapClient config file.
public  voidsetDataSource(DataSource dataSource)
     Set the DataSource to be used by iBATIS SQL Maps.
public  voidsetLobHandler(LobHandler lobHandler)
     Set the LobHandler to be used by the SqlMapClient.
public  voidsetSqlMapClientProperties(Properties sqlMapClientProperties)
     Set optional properties to be passed into the SqlMapClientBuilder, as alternative to a <properties> tag in the sql-map-config.xml file.
public  voidsetTransactionConfigClass(Class transactionConfigClass)
     Set the iBATIS TransactionConfig class to use.
public  voidsetTransactionConfigProperties(Properties transactionConfigProperties)
     Set properties to be passed to the TransactionConfig instance used by this SqlMapClient.
public  voidsetUseTransactionAwareDataSource(boolean useTransactionAwareDataSource)
     Set whether to use a transaction-aware DataSource for the SqlMapClient, i.e.


Constructor Detail
SqlMapClientFactoryBean
public SqlMapClientFactoryBean()(Code)




Method Detail
afterPropertiesSet
public void afterPropertiesSet() throws Exception(Code)



applyTransactionConfig
protected void applyTransactionConfig(SqlMapClient sqlMapClient, TransactionConfig transactionConfig)(Code)
Apply the given iBATIS TransactionConfig to the SqlMapClient.

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.
Parameters:
  sqlMapClient - the SqlMapClient to apply the TransactionConfig to
Parameters:
  transactionConfig - the iBATIS TransactionConfig to apply
See Also:   com.ibatis.sqlmap.engine.impl.ExtendedSqlMapClient
See Also:   com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMaxTransactions
See Also:   com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.setTxManager




buildSqlMapClient
protected SqlMapClient buildSqlMapClient(Resource configLocation, Properties properties) throws IOException(Code)
Build a SqlMapClient instance based on the given standard configuration.

The default implementation uses the standard iBATIS SqlMapClientBuilder API to build a SqlMapClient instance based on an InputStream (if possible, on iBATIS 2.3 and higher) or on a Reader (on iBATIS up to version 2.2).
Parameters:
  configLocation - the config file to load from
Parameters:
  properties - the SqlMapClient properties (if any) the SqlMapClient instance (never null)
throws:
  IOException - if loading the config file failed
See Also:   com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient




getConfigTimeLobHandler
public static LobHandler getConfigTimeLobHandler()(Code)
Return the LobHandler for the currently configured iBATIS SqlMapClient, to be used by TypeHandler implementations like ClobStringTypeHandler.

This instance will be set before initialization of the corresponding SqlMapClient, and reset immediately afterwards. It is thus only available during configuration.
See Also:   SqlMapClientFactoryBean.setLobHandler
See Also:   org.springframework.orm.ibatis.support.ClobStringTypeHandler
See Also:   org.springframework.orm.ibatis.support.BlobByteArrayTypeHandler
See Also:   org.springframework.orm.ibatis.support.BlobSerializableTypeHandler




getObject
public Object getObject()(Code)



getObjectType
public Class getObjectType()(Code)



isSingleton
public boolean isSingleton()(Code)



setConfigLocation
public void setConfigLocation(Resource configLocation)(Code)
Set the location of the iBATIS SqlMapClient config file. A typical value is "WEB-INF/sql-map-config.xml".



setDataSource
public void setDataSource(DataSource dataSource)(Code)
Set the DataSource to be used by iBATIS SQL Maps. This will be passed to the SqlMapClient as part of a TransactionConfig instance.

If specified, this will override corresponding settings in the SqlMapClient properties. Usually, you will specify DataSource and transaction configuration either here or in SqlMapClient properties.

Specifying a DataSource for the SqlMapClient rather than for each individual DAO allows for lazy loading, for example when using PaginatedList results.

With a DataSource passed in here, you don't need to specify one for each DAO. Passing the SqlMapClient to the DAOs is enough, as it already carries a DataSource. Thus, it's recommended to specify the DataSource at this central location only.

Thanks to Brandon Goodin from the iBATIS team for the hint on how to make this work with Spring's integration strategy!
See Also:   SqlMapClientFactoryBean.setTransactionConfigClass
See Also:   SqlMapClientFactoryBean.setTransactionConfigProperties
See Also:   com.ibatis.sqlmap.client.SqlMapClient.getDataSource
See Also:   SqlMapClientTemplate.setDataSource
See Also:   SqlMapClientTemplate.queryForPaginatedList




setLobHandler
public void setLobHandler(LobHandler lobHandler)(Code)
Set the LobHandler to be used by the SqlMapClient. Will be exposed at config time for TypeHandler implementations.
See Also:   SqlMapClientFactoryBean.getConfigTimeLobHandler
See Also:   com.ibatis.sqlmap.engine.type.TypeHandler
See Also:   org.springframework.orm.ibatis.support.ClobStringTypeHandler
See Also:   org.springframework.orm.ibatis.support.BlobByteArrayTypeHandler
See Also:   org.springframework.orm.ibatis.support.BlobSerializableTypeHandler



setSqlMapClientProperties
public void setSqlMapClientProperties(Properties sqlMapClientProperties)(Code)
Set optional properties to be passed into the SqlMapClientBuilder, as alternative to a <properties> tag in the sql-map-config.xml file. Will be used to resolve placeholders in the config file.
See Also:   SqlMapClientFactoryBean.setConfigLocation
See Also:   com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(java.io.Readerjava.util.Properties)



setTransactionConfigClass
public void setTransactionConfigClass(Class transactionConfigClass)(Code)
Set the iBATIS TransactionConfig class to use. Default is com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig.

Will only get applied when using a Spring-managed DataSource. An instance of this class will get populated with the given DataSource and initialized with the given properties.

The default ExternalTransactionConfig is appropriate if there is external transaction management that the SqlMapClient should participate in: be it Spring transaction management, EJB CMT or plain JTA. This should be the typical scenario. If there is no active transaction, SqlMapClient operations will execute SQL statements non-transactionally.

JdbcTransactionConfig or JtaTransactionConfig is only necessary when using the iBATIS SqlMapTransactionManager API instead of external transactions. If there is no explicit transaction, SqlMapClient operations will automatically start a transaction for their own scope (in contrast to the external transaction mode, see above).

It is strongly recommended to use iBATIS SQL Maps with Spring transaction management (or EJB CMT). In this case, the default ExternalTransactionConfig is fine. Lazy loading and SQL Maps operations without explicit transaction demarcation will execute non-transactionally.

Even with Spring transaction management, it might be desirable to specify JdbcTransactionConfig: This will still participate in existing Spring-managed transactions, but lazy loading and operations without explicit transaction demaration will execute in their own auto-started transactions. However, this is usually not necessary.
See Also:   SqlMapClientFactoryBean.setDataSource
See Also:   SqlMapClientFactoryBean.setTransactionConfigProperties
See Also:   com.ibatis.sqlmap.engine.transaction.TransactionConfig
See Also:   com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig
See Also:   com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransactionConfig
See Also:   com.ibatis.sqlmap.engine.transaction.jta.JtaTransactionConfig
See Also:   com.ibatis.sqlmap.client.SqlMapTransactionManager




setTransactionConfigProperties
public void setTransactionConfigProperties(Properties transactionConfigProperties)(Code)
Set properties to be passed to the TransactionConfig instance used by this SqlMapClient. Supported properties depend on the concrete TransactionConfig implementation used:

  • ExternalTransactionConfig supports "DefaultAutoCommit" (default: false) and "SetAutoCommitAllowed" (default: true). Note that Spring uses SetAutoCommitAllowed = false as default, in contrast to the iBATIS default, to always keep the original autoCommit value as provided by the connection pool.
  • JdbcTransactionConfig does not supported any properties.
  • JtaTransactionConfig supports "UserTransaction" (no default), specifying the JNDI location of the JTA UserTransaction (usually "java:comp/UserTransaction").

See Also:   com.ibatis.sqlmap.engine.transaction.TransactionConfig.initialize
See Also:   com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig
See Also:   com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransactionConfig
See Also:   com.ibatis.sqlmap.engine.transaction.jta.JtaTransactionConfig



setUseTransactionAwareDataSource
public void setUseTransactionAwareDataSource(boolean useTransactionAwareDataSource)(Code)
Set whether to use a transaction-aware DataSource for the SqlMapClient, i.e. whether to automatically wrap the passed-in DataSource with Spring's TransactionAwareDataSourceProxy.

Default is "true": When the SqlMapClient performs direct database operations outside of Spring's SqlMapClientTemplate (for example, lazy loading or direct SqlMapClient access), it will still participate in active Spring-managed transactions.

As a further effect, using a transaction-aware DataSource will apply remaining transaction timeouts to all created JDBC Statements. This means that all operations performed by the SqlMapClient will automatically participate in Spring-managed transaction timeouts.

Turn this flag off to get raw DataSource handling, without Spring transaction checks. Operations on Spring's SqlMapClientTemplate will still detect Spring-managed transactions, but lazy loading or direct SqlMapClient access won't.
See Also:   SqlMapClientFactoryBean.setDataSource
See Also:   org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy
See Also:   org.springframework.jdbc.datasource.DataSourceTransactionManager
See Also:   SqlMapClientTemplate
See Also:   com.ibatis.sqlmap.client.SqlMapClient




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.