如何移动Atomikos的tm.out和* .epoch文件的位置?

时间:2010-07-15 14:18:29

标签: spring configuration logging temporary-files atomikos

我正在运行一个使用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>

1 个答案:

答案 0 :(得分: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>

现在该属性已设置。但是为了确保您没有运行两个事务服务,您还必须按如下方式修改用户事务管理器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>