8

現在のディレクトリに多数のログ ファイルをダンプする Atomikos を使用する J2SE アプリケーションを実行しています。これらのファイルの場所を「/tmp」に移動したいのですが、Spring XML 構成ファイル内から設定できる構成プロパティが見つかりません。

Atomikos のドキュメントでは、次のプロパティを参照しています。

com.atomikos.icatch.output_dir

これはまさに私が必要としているもののようですが、jta.properties ファイルなしで Spring から設定するにはどうすればよいですか? これが私のトランザクションマネージャーの設定です:

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
    <property name="transactionManager" ref="atomikosTransactionManager" />
    <property name="userTransaction" ref="atomikosUserTransaction" />
</bean>

<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
    init-method="init" destroy-method="close">
    <!-- When close is called, should we force transactions to terminate? -->
    <property name="forceShutdown" value="false" />
</bean>

<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
    <!-- Number of seconds before transaction timesout. -->
    <property name="transactionTimeout" value="30" />
</bean>
4

1 に答える 1

12

問題のプロパティは、transactionService のシングルトン インスタンス (通常はユーザー トランザクション マネージャーによってオンデマンドで作成されるオブジェクト) に設定する必要があります。

<bean id="userTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp"
    init-method="init" destroy-method="shutdownForce">
    <constructor-arg>
        <!-- IMPORTANT: specify all Atomikos properties here -->
        <props>
            <prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop>
            <prop key="com.atomikos.icatch.output_dir">target/</prop>
            <prop key="com.atomikos.icatch.log_base_dir">target/</prop>
        </props>
    </constructor-arg>
</bean>

これでプロパティが設定されました。ただし、2 つのトランザクション サービスが実行されないようにするために、次のようにユーザー トランザクション マネージャー Bean も変更する必要があります。

<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
    init-method="init" destroy-method="close" depends-on="userTransactionService">
    <!-- When close is called, should we force transactions to terminate? -->
    <property name="forceShutdown" value="false" />
    <!-- Do not create a transaction service as we have specified the bean in this file -->
    <property name="startupTransactionService" value="false" />
</bean>
于 2010-07-16T14:37:46.623 に答える