public class WebSphereDataSourceAdapter extends IsolationLevelDataSourceAdapter
DataSourceSE に委譲する DataSourceSE 実装。通常、JNDI から取得され、現在の分離レベルや現在のユーザー資格情報を、そこから取得されるすべての接続に適用します。IBM 固有の API を使用して、WebSphere DataSource(IBM コード例)から特定の分離レベル(および読み取り専用フラグ)の JDBC 接続を取得します。TransactionSynchronizationManager.getCurrentTransactionIsolationLevel() によって公開されるトランザクション固有の分離レベルをサポートします。また、デフォルトの分離レベルを指定して、現在の Spring 管理のトランザクションが特定の分離レベルを定義していない場合に適用することもできます。
ターゲット DataSource をインナー Bean JNDI ルックアップとして定義する使用例(もちろん、Bean 参照を介して任意の WebSphere DataSource にリンクできます):
<bean id="myDataSource" class="org.springframework.jdbc.datasource.WebSphereDataSourceAdapter">
<property name="targetDataSource">
<bean class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/myds"/>
</bean>
</property>
</bean> このアプローチの最初の実装を提出してくれた Ricardo Olivieri に感謝します。| コンストラクターと説明 |
|---|
WebSphereDataSourceAdapter() このコンストラクターは WebSphere JDBC 接続仕様 API を取得するため、リフレクションを使用して特定の WebSphere 接続を取得できます。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
void | afterPropertiesSet() 指定された "targetDataSource" が実際に WebSphere WSDataSource であるかどうかを確認します。 |
protected ObjectSE | createConnectionSpec(IntegerSE isolationLevel, BooleanSE readOnlyFlag, StringSE username, StringSE password) 指定された特性の WebSphere JDBCConnectionSpec オブジェクトを作成します。 |
protected ConnectionSE | doGetConnection(StringSE username, StringSE password) 現在の設定の WebSphere JDBCConnectionSpec オブジェクトを作成し、 WSDataSource.getConnection(JDBCConnectionSpec) を呼び出します。 |
getCurrentIsolationLevel, getCurrentReadOnlyFlag, getIsolationLevel, setIsolationLevel, setIsolationLevelNamegetConnection, getConnection, removeCredentialsFromCurrentThread, setCatalog, setCredentialsForCurrentThread, setPassword, setSchema, setUsernamegetLoginTimeout, getLogWriter, getParentLogger, getTargetDataSource, isWrapperFor, obtainTargetDataSource, setLoginTimeout, setLogWriter, setTargetDataSource, unwrapcloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEprotected final Log logger
public WebSphereDataSourceAdapter()
public void afterPropertiesSet()
InitializingBean の afterPropertiesSet DelegatingDataSource の afterPropertiesSet protected ConnectionSE doGetConnection(@Nullable StringSE username, @Nullable StringSE password) throws SQLExceptionSE
WSDataSource.getConnection(JDBCConnectionSpec) を呼び出します。IsolationLevelDataSourceAdapter の doGetConnection username - 使用するユーザー名 password - 使用するパスワード SQLExceptionSEcreateConnectionSpec(java.lang.Integer, java.lang.Boolean, java.lang.String, java.lang.String), WSDataSourceprotected ObjectSE createConnectionSpec(@Nullable IntegerSE isolationLevel, @Nullable BooleanSE readOnlyFlag, @Nullable StringSE username, @Nullable StringSE password) throws SQLExceptionSE
JDBCConnectionSpec オブジェクトを作成します。デフォルトの実装では、リフレクションを使用して特定の設定を適用します。サブクラスでオーバーライドして、JDBCConnectionSpec オブジェクト(JDBCConnectionSpec javadoc; IBM developerWorks の記事)をカスタマイズできます。
isolationLevel - 適用する分離レベル (または、存在しない場合は null )readOnlyFlag - 適用する読み取り専用フラグ (または、存在しない場合は null )username - 適用するユーザー名 (null または空はデフォルトを示します)password - 適用するパスワード (null または空の場合があります)SQLExceptionSE - JDBCConnectionSpec API メソッドによってスローされた場合 JDBCConnectionSpec