P6SpyとSpringを組み合わせて使う

http://swik.net/Spring/Spring%27s+corner/Integrate+P6Spy+with+Spring/vq6にありましたが、一応備忘録。Springで既存のAPIとうまく折り合うコツみたいなのがわかる気がする。
#ああ、今さら今さら。


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
">http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<!--P6でラップする対象のデータソースを登録する--/>
<bean id="jdbcDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.apache.derby.jdbc.ClientDriver" />
<property name="url" value="jdbc:derby://localhost:1527/sampledb" />
<property name="username" value="admin" />
<property name="password" value="admin" />
</bean>

<!--P6のデータソースを登録--/>
<bean id="dataSource" class="com.p6spy.engine.spy.P6DataSource">
<constructor-arg>
<ref local="jdbcDataSource"/>
</constructor-arg>
</bean>

 <!--デフォルトのトランザクションマネージャを設定--/>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>

<tx:annotation-driven/>
<context:component-scan base-package="hello.spring.transaction"/>

</beans>

ところで、p6とあわせてspringにlog4j導入したんですが、なんかlog4j.xmlが反映されずにしばらくハマりました。なんかログを見ているとjxl.logという怪しいログができている。jxl…jExcelAPI?非常に怪しい…。みるとjExcelAPIのjarにlog4j.xmlが入ってる。ざけんな!jExcelAPIはもともとSpringをivyで引っ張ってきたときに入ってきたモノそのまま使っていただけなのでとりあえず削除った。jExcelさんは若干人騒がせな感じらしくてhttp://pcjuzeren.blogspot.com/2009/06/jxllog.htmlあたりにも、jExcel使ったときに勝手に出るjxl.logがウザいという話が出てるっぽい。読んでないけどたぶん空気的にそう書いてそう。jExcelは、API的には使い勝手悪くないだけにねー、残念な感じだねー。