SpringでS2Daoを使う -その3-
かなり間が空いてしまいましたが、SpringでS2Daoを使うの3回目です。S2Daoで実装クラス(Employee2DaoImpl)にS2DaoInterceptorをかけた場合のエラーとS2のバージョンを2.4.xにしたものを下記におきました。
http://www.asahi-net.or.jp/~wh6n-icmr/spring-s2dao-example2.zip
変更のポイントは、下記のようにinterceptorのかけ方を変更したのとS2の2.4.xへの対応(JTAがらみ?のインタフェース変更)のために、dao.xmlを変更したことです。
Class targetClass = ClassUtil.forName(className);
Class enhancedClass;
AspectWeaver weaver = new AspectWeaver(targetClass, null);
Method methods = targetClass.getMethods();
for (int i = 0; i < methods.length; ++i) {
Method method = methods[i];
if (isBridgeMethod(method)) {
continue;
}
List interceptorList = new ArrayList();
for (int j = 0; j < interceptorNames.length; j++) {
MethodInterceptor interceptor = (MethodInterceptor) getBeanFactory()
.getBean(interceptorNames[j]);
interceptorList.add(interceptor);
}
if (!isApplicableAspect(method)) {
continue;
}
if (interceptorList.size() == 0) {
weaver.setInterceptors(method, new MethodInterceptor[0]);
} else {
weaver.setInterceptors(method,
(MethodInterceptor) interceptorList
.toArray(new MethodInterceptor[interceptorList.size()]));
}
}
enhancedClass = weaver.generateClass();
制限としては、FileSystemBeanAutoRegister.getRootDirの実装がS2と異なり手抜きをしているため、beanRefContext.xmlが存在することが前提となっています。これは、ちょっといけてないので本当は修正したかったのですが、S2のようにルートパスを取得する方法がわからなかったため、そのままになっています。あとは、各ライブラリが若干古いのですが、ちょっと整理する時間がなかったので、そのままあげています。その他、詳細はダウンロード後readme.txtを確認して下さい。