Hatena::ブログ(Diary)

じゅんいち☆かとうの技術日誌 このページをアンテナに追加 RSSフィード


はてなブログに引っ越しました。

2009-04-01

[][][][] マージ完了

ブランチからトランクへのマージは規模がでかいと結構気合のいる作業ですね(汁

ということで、トランクにマージしてコミットしました。

(一応はUTはパスしているのですが、org.escafe.buri.common.participantprovider.implのUTが抜けていたのですがまだテストがパスしてませんが、明日にはなんとかします)

その他注意点

  • H2はDbLauncherを使って起動してください。落ち着いたらファイルベースに切り替えます。
  • テーブル名はS2JDBCの規約に合わせるため、すべてアンダースコア区切りの名前に変更しています。
  • Mavenについてはmvn eclipse:eclipseからQ4Eに変更となりました。事前にEclipseインストールが必要です。

2009-03-31

[][][][] S2Dao用のUnit Testもパスした

従来からあるS2DaoのUTもパスするようになりました。

これで、BuriがS2Daoでも、S2JDBCでも、DBFluteでも動作することが可能になりました。

いよいよ、Trunkへのマージを検討したいと思います。

2009-03-26

[][][][] BuriがS2JDBCに完全対応

先に紹介したS2JDBCToDataAccessRuleで既存のBuriでもS2JDBCのServiceクラスをS2DaoのDaoの変わりに使えることはすでに実現していましたが、Buri内部のテーブルのアクセスにはまだS2Daoを使っていました。BURI系のテーブルです。

今回、S2Daoを取り除きS2内部に含まれているS2JDBCに切り替えました。S2Daojarはもういりませんと。

とりあえず、

https://www.escafe.org/svn/escafeflow/branches/kato/buri-core

に上がっています。

S2JDBC-Genを使っていてプロジェクトのレイアウトに少し手間取ったのでUTは別プロジェクトに分けています。

https://www.escafe.org/svn/escafeflow/branches/kato/buri-core-test


もちろん、既存のS2Daoのユーザさんもちゃんと使えるようにburi-s2dao.jarを追加すると今までのコードもちゃんと動くようにしたいと思っています。こちらのほうはまだUT環境が用意できていないのですが、ぼちぼちすすめます。

S2Dao版もちゃんと動けば、trunkにマージかなーと思っています。よろ〜。

2009-03-24

[][][][] BuriをS2JDBC対応にしてみる その6

追記:

単なるテストケースの写し間違いだった。。。

		datas = billBao.getEndBill();
		assertEquals(0, datas.size());

が正解。。。とりあえず、BaoAnnotationTestは通るようになったがBuriSignalTestが通ってない。がんばるぞっっと。。。

-

沖縄から帰還して暇を見つけてはBuriの改修作業を続けています。

でまたUTは赤いところがあるのですが、BaoAnnotationTestを通すのに一息な感じがしてきました。

これがパスすればいろんなものが通りそうな気がする。

BaoAnnotationTest#testNomalOrderTxのテストログですが、、、

billBao.getEndBill()が1でないといけないのに0と。

このあたりを悪戦苦闘しておりますw。

		datas = billBao.getEndBill();
		assertEquals(1, datas.size());
junit.framework.AssertionFailedError: expected:<1> but was:<0>
	at junit.framework.Assert.fail(Assert.java:47)
	at junit.framework.Assert.failNotEquals(Assert.java:277)
	at junit.framework.Assert.assertEquals(Assert.java:64)
	at junit.framework.Assert.assertEquals(Assert.java:195)
	at junit.framework.Assert.assertEquals(Assert.java:201)
	at example.org.escafe.buri.annotation.bao.BaoAnnotationTest.testNomalOrderTx(BaoAnnotationTest.java:135)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at org.seasar.framework.unit.S2FrameworkTestCase.doRunTest(S2FrameworkTestCase.java:519)
	at org.seasar.extension.unit.S2TestCase.doRunTest(S2TestCase.java:103)
	at org.seasar.framework.unit.S2FrameworkTestCase.runBare(S2FrameworkTestCase.java:308)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

2009-03-17

[][][][] BuriをS2JDBC対応にしてみる その5

その4の問題は解消できました。他のUTも徐々に通るようになってきました。

で、今回は、

org.escafe.buri.dao.util.BuriStateUtilTest

のテストが全滅な件w

ログ見ると、

DEBUG 2009-03-17 11:08:03,204 [main] update BURI_TEST_INT set VALUE = 'hoge', VERSION_NO = VERSION_NO + 1 where TEST_ID = null and VERSION_NO = null

になっているのが原因みたい。TEST_ID, VERSION_NOが取れてないということは、BURI_TEST_INTが登録できていないとかかなー。

org.seasar.coffee.script.exception.ScriptExecuteException: [ESCS0002]OGNL値取得エラー:expression={data=org.escafe.buri.entity.BuriTestINT@192425a}:root=Method "update" failed for object org.escafe.buri.service.BuriTestINTService$$EnhancedByS2AOP$$2682d210@63b5a40a:context={3} {2}
	at org.seasar.coffee.script.ognl.impl.OgnlScriptImpl.eval(OgnlScriptImpl.java:57)
	at org.seasar.coffee.script.ognl.impl.OgnlScriptImpl.eval(OgnlScriptImpl.java:40)
	at org.seasar.coffee.script.ognl.impl.OgnlScriptImpl.getValue(OgnlScriptImpl.java:192)
	at org.seasar.coffee.script.ognl.impl.OgnlScriptImpl.processOgnl(OgnlScriptImpl.java:181)
	at org.seasar.coffee.script.ognl.impl.OgnlScriptImpl.processOgnls(OgnlScriptImpl.java:147)
	at org.seasar.coffee.script.ognl.impl.OgnlScriptImpl.run(OgnlScriptImpl.java:109)
	at org.escafe.buri.util.packages.abst.AbstDataAccessUtilLongKey.runScript(AbstDataAccessUtilLongKey.java:68)
	at wakanagoTest.wakanagoTest_wp1_org_escafe_buri_entity_BuriTestINT_DataAccessUtil.Store(wakanagoTest_wp1_org_escafe_buri_entity_BuriTestINT_DataAccessUtil.java:31)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl.storeData(BuriDataUtilImpl.java:294)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl$$EnhancedByS2AOP$$7aec898a.$$storeData$$invokeSuperMethod$$(BuriDataUtilImpl$$EnhancedByS2AOP$$7aec898a.java)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl$$EnhancedByS2AOP$$7aec898a$$MethodInvocation$$storeData5.proceed(MethodInvocationClassGenerator.java)
	at org.seasar.framework.aop.impl.NestedMethodInvocation.proceed(NestedMethodInvocation.java:55)
	at org.seasar.framework.aop.interceptors.TraceInterceptor.invoke(TraceInterceptor.java:73)
	at org.seasar.framework.aop.impl.NestedMethodInvocation.proceed(NestedMethodInvocation.java:53)
	at org.seasar.framework.aop.interceptors.InterceptorChain.invoke(InterceptorChain.java:49)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl$$EnhancedByS2AOP$$7aec898a$$MethodInvocation$$storeData5.proceed(MethodInvocationClassGenerator.java)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl$$EnhancedByS2AOP$$7aec898a.storeData(BuriDataUtilImpl$$EnhancedByS2AOP$$7aec898a.java)
	at org.escafe.buri.dao.util.impl.BuriStateUtilImpl.saveStatus(BuriStateUtilImpl.java:195)
	at org.escafe.buri.dao.util.impl.BuriStateUtilImpl$$EnhancedByS2AOP$$6b98e8b4.$$saveStatus$$invokeSuperMethod$$(BuriStateUtilImpl$$EnhancedByS2AOP$$6b98e8b4.java)
	at org.escafe.buri.dao.util.impl.BuriStateUtilImpl$$EnhancedByS2AOP$$6b98e8b4$$MethodInvocation$$saveStatus2.proceed(MethodInvocationClassGenerator.java)
	at org.seasar.framework.aop.impl.NestedMethodInvocation.proceed(NestedMethodInvocation.java:55)
	at org.seasar.framework.aop.interceptors.TraceInterceptor.invoke(TraceInterceptor.java:73)
	at org.seasar.framework.aop.impl.NestedMethodInvocation.proceed(NestedMethodInvocation.java:53)
	at org.seasar.framework.aop.interceptors.InterceptorChain.invoke(InterceptorChain.java:49)
	at org.escafe.buri.dao.util.impl.BuriStateUtilImpl$$EnhancedByS2AOP$$6b98e8b4$$MethodInvocation$$saveStatus2.proceed(MethodInvocationClassGenerator.java)
	at org.escafe.buri.dao.util.impl.BuriStateUtilImpl$$EnhancedByS2AOP$$6b98e8b4.saveStatus(BuriStateUtilImpl$$EnhancedByS2AOP$$6b98e8b4.java)
	at org.escafe.buri.dao.util.BuriStateUtilTest.testBuriStateProceedTx(BuriStateUtilTest.java:55)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at org.seasar.framework.unit.S2FrameworkTestCase.doRunTest(S2FrameworkTestCase.java:519)
	at org.seasar.extension.unit.S2TestCase.doRunTest(S2TestCase.java:103)
	at org.seasar.framework.unit.S2FrameworkTestCase.runBare(S2FrameworkTestCase.java:308)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: ognl.MethodFailedException: Method "update" failed for object org.escafe.buri.service.BuriTestINTService$$EnhancedByS2AOP$$2682d210@63b5a40a [org.seasar.extension.jdbc.exception.SOptimisticLockException: [ESSR0736]エンティティ(org.escafe.buri.entity.BuriTestINT@192425a)は既に変更されています。]
	at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:900)
	at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:61)
	at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:925)
	at ognl.ASTMethod.getValueBody(ASTMethod.java:73)
	at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171)
	at ognl.SimpleNode.getValue(SimpleNode.java:211)
	at ognl.ASTChain.getValueBody(ASTChain.java:109)
	at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171)
	at ognl.SimpleNode.getValue(SimpleNode.java:211)
	at ognl.Ognl.getValue(Ognl.java:333)
	at ognl.Ognl.getValue(Ognl.java:310)
	at org.seasar.coffee.script.ognl.impl.OgnlScriptImpl.eval(OgnlScriptImpl.java:53)
	... 47 more

ログはこんな感じ。

DEBUG 2009-03-17 11:08:02,008 [main] ファイル(env_ut.txt)がないため環境変数#Envに値(ut)が設定されました
DEBUG 2009-03-17 11:08:02,012 [main] S2Containerを作成します。path=convention.dicon
DEBUG 2009-03-17 11:08:02,020 [main] S2Containerを作成しました。path=convention.dicon
DEBUG 2009-03-17 11:08:02,020 [main] S2Containerを作成します。path=customizer.dicon
DEBUG 2009-03-17 11:08:02,023 [main] S2Containerを作成します。path=default-customizer.dicon
DEBUG 2009-03-17 11:08:02,025 [main] S2Containerを作成します。path=std-customizer.dicon
DEBUG 2009-03-17 11:08:02,044 [main] S2Containerを作成しました。path=std-customizer.dicon
DEBUG 2009-03-17 11:08:02,048 [main] S2Containerを作成しました。path=default-customizer.dicon
DEBUG 2009-03-17 11:08:02,049 [main] S2Containerを作成しました。path=customizer.dicon
DEBUG 2009-03-17 11:08:02,062 [main] S2Containerを作成します。path=creator.dicon
DEBUG 2009-03-17 11:08:02,070 [main] S2Containerを作成しました。path=creator.dicon
DEBUG 2009-03-17 11:08:02,077 [main] S2Containerを作成します。path=WakanagoCompile.dicon
DEBUG 2009-03-17 11:08:02,080 [main] S2Containerを作成します。path=org/escafe/buri/dicon/allTestService.dicon
DEBUG 2009-03-17 11:08:02,082 [main] S2Containerを作成します。path=convention.dicon
DEBUG 2009-03-17 11:08:02,086 [main] S2Containerを作成しました。path=convention.dicon
DEBUG 2009-03-17 11:08:02,087 [main] S2Containerを作成します。path=aop.dicon
DEBUG 2009-03-17 11:08:02,105 [main] S2Containerを作成しました。path=aop.dicon
DEBUG 2009-03-17 11:08:02,105 [main] S2Containerを作成します。path=s2jdbc.dicon
DEBUG 2009-03-17 11:08:02,109 [main] S2Containerを作成します。path=jdbc.dicon
DEBUG 2009-03-17 11:08:02,111 [main] S2Containerを作成します。path=jta.dicon
DEBUG 2009-03-17 11:08:02,116 [main] S2Containerを作成しました。path=jta.dicon
DEBUG 2009-03-17 11:08:02,116 [main] S2Containerを作成します。path=jdbc-extension.dicon
DEBUG 2009-03-17 11:08:02,121 [main] S2Containerを作成しました。path=jdbc-extension.dicon
DEBUG 2009-03-17 11:08:02,125 [main] S2Containerを作成しました。path=jdbc.dicon
DEBUG 2009-03-17 11:08:02,125 [main] S2Containerを作成します。path=s2jdbc-internal.dicon
DEBUG 2009-03-17 11:08:02,130 [main] S2Containerを作成しました。path=s2jdbc-internal.dicon
DEBUG 2009-03-17 11:08:02,132 [main] S2Containerを作成しました。path=s2jdbc.dicon
DEBUG 2009-03-17 11:08:02,134 [main] S2Containerを作成しました。path=org/escafe/buri/dicon/allTestService.dicon
DEBUG 2009-03-17 11:08:02,135 [main] S2Containerを作成します。path=buri/dicon/buriSimple.dicon
DEBUG 2009-03-17 11:08:02,138 [main] S2Containerを作成します。path=buri/dicon/buri-extension.dicon
DEBUG 2009-03-17 11:08:02,142 [main] S2Containerを作成しました。path=buri/dicon/buri-extension.dicon
DEBUG 2009-03-17 11:08:02,159 [main] S2Containerを作成します。path=buri/dicon/buri-user.dicon
DEBUG 2009-03-17 11:08:02,162 [main] S2Containerを作成します。path=buri/dicon/allService.dicon
DEBUG 2009-03-17 11:08:02,167 [main] S2Containerを作成します。path=j2ee.dicon
DEBUG 2009-03-17 11:08:02,171 [main] S2Containerを作成しました。path=j2ee.dicon
DEBUG 2009-03-17 11:08:02,174 [main] S2Containerを作成しました。path=buri/dicon/allService.dicon
DEBUG 2009-03-17 11:08:02,175 [main] S2Containerを作成します。path=StdTestPP.dicon
DEBUG 2009-03-17 11:08:02,180 [main] S2Containerを作成しました。path=StdTestPP.dicon
DEBUG 2009-03-17 11:08:02,266 [main] S2Containerを作成しました。path=buri/dicon/buri-user.dicon
DEBUG 2009-03-17 11:08:02,266 [main] S2Containerを作成します。path=buri/dicon/internalService.dicon
DEBUG 2009-03-17 11:08:02,302 [main] S2Containerを作成しました。path=buri/dicon/internalService.dicon
DEBUG 2009-03-17 11:08:02,302 [main] S2Containerを作成します。path=buri/dicon/buri-share.dicon
DEBUG 2009-03-17 11:08:02,305 [main] S2Containerを作成します。path=buri/dicon/OgnlScript.dicon
DEBUG 2009-03-17 11:08:02,311 [main] S2Containerを作成しました。path=buri/dicon/OgnlScript.dicon
DEBUG 2009-03-17 11:08:02,313 [main] S2Containerを作成します。path=buri/dicon/template.dicon
DEBUG 2009-03-17 11:08:02,317 [main] S2Containerを作成しました。path=buri/dicon/template.dicon
DEBUG 2009-03-17 11:08:02,317 [main] S2Containerを作成します。path=buri/dicon/event.dicon
DEBUG 2009-03-17 11:08:02,333 [main] S2Containerを作成しました。path=buri/dicon/event.dicon
DEBUG 2009-03-17 11:08:02,334 [main] S2Containerを作成します。path=s2mai.dicon
DEBUG 2009-03-17 11:08:02,337 [main] S2Containerを作成します。path=s2mai-core.dicon
DEBUG 2009-03-17 11:08:02,340 [main] S2Containerを作成します。path=org/seasar/mai/transport/transport.dicon
DEBUG 2009-03-17 11:08:02,345 [main] S2Containerを作成しました。path=org/seasar/mai/transport/transport.dicon
DEBUG 2009-03-17 11:08:02,346 [main] S2Containerを作成します。path=mailTemplate.dicon
DEBUG 2009-03-17 11:08:02,350 [main] S2Containerを作成します。path=org/seasar/mai/template/freemarker.dicon
DEBUG 2009-03-17 11:08:02,355 [main] S2Containerを作成します。path=mailProperties.dicon
DEBUG 2009-03-17 11:08:02,359 [main] S2Containerを作成しました。path=mailProperties.dicon
DEBUG 2009-03-17 11:08:02,360 [main] S2Containerを作成しました。path=org/seasar/mai/template/freemarker.dicon
DEBUG 2009-03-17 11:08:02,360 [main] S2Containerを作成しました。path=mailTemplate.dicon
DEBUG 2009-03-17 11:08:02,365 [main] S2Containerを作成しました。path=s2mai-core.dicon
DEBUG 2009-03-17 11:08:02,367 [main] S2Containerを作成しました。path=s2mai.dicon
DEBUG 2009-03-17 11:08:02,379 [main] S2Containerを作成しました。path=buri/dicon/buri-share.dicon
DEBUG 2009-03-17 11:08:02,392 [main] S2Containerを作成しました。path=buri/dicon/buriSimple.dicon
DEBUG 2009-03-17 11:08:02,392 [main] S2Containerを作成しました。path=WakanagoCompile.dicon
DEBUG 2009-03-17 11:08:02,970 [main] トランザクションを開始しました。tx=[FormatId=4360, GlobalId=1237255677474/3, BranchId=]
DEBUG 2009-03-17 11:08:02,971 [main] select T1_.BRANCH_ID as C1_, T1_.PARENT_BRANCH_ID as C2_, T1_.PATH_ID as C3_, T1_.DATA_ID as C4_, T1_.BT_ID as C5_, T1_.PROCESS_DATE as C6_, T1_.VERSION_NO as C7_ from BURI_BRANCH T1_
DEBUG 2009-03-17 11:08:03,022 [main] 物理的なコネクションを取得しました
DEBUG 2009-03-17 11:08:03,023 [main] 論理的なコネクションを取得しました。tx=[FormatId=4360, GlobalId=1237255677474/3, BranchId=]
INFO  2009-03-17 11:08:03,023 [main] wakanagoxpdl/wakanagoTest.xpdl読み込み開始
INFO  2009-03-17 11:08:03,031 [main] wakanagoxpdl/wakanagoTest.xpdlコンパイル開始
WARN  2009-03-17 11:08:03,044 [main] org.escafe.buri.util.packages.abst.AbstDataAccessUtilLongKeyのプロパティ(dataAccessScript)が見つからないので設定をスキップします
WARN  2009-03-17 11:08:03,044 [main] org.escafe.buri.util.packages.abst.AbstDataAccessUtilLongKeyのプロパティ(pkeyExpressionScript)が見つからないので設定をスキップします
WARN  2009-03-17 11:08:03,118 [main] org.escafe.buri.util.packages.abst.AbstDataAccessUtilManyKeyのプロパティ(dataAccessScript)が見つからないので設定をスキップします
WARN  2009-03-17 11:08:03,118 [main] org.escafe.buri.util.packages.abst.AbstDataAccessUtilManyKeyのプロパティ(pkeyExpressionScript)が見つからないので設定をスキップします
WARN  2009-03-17 11:08:03,174 [main] org.escafe.buri.util.packages.abst.AbstDataAccessUtilManyKeyのプロパティ(dataAccessScript)が見つからないので設定をスキップします
WARN  2009-03-17 11:08:03,174 [main] org.escafe.buri.util.packages.abst.AbstDataAccessUtilManyKeyのプロパティ(pkeyExpressionScript)が見つからないので設定をスキップします
WARN  2009-03-17 11:08:03,196 [main] org.escafe.buri.util.packages.abst.AbstDataAccessUtilLongKeyのプロパティ(dataAccessScript)が見つからないので設定をスキップします
WARN  2009-03-17 11:08:03,196 [main] org.escafe.buri.util.packages.abst.AbstDataAccessUtilLongKeyのプロパティ(pkeyExpressionScript)が見つからないので設定をスキップします
INFO  2009-03-17 11:08:03,196 [main] wakanagoxpdl/wakanagoTest.xpdlコンパイル終了
DEBUG 2009-03-17 11:08:03,196 [main] BEGIN org.escafe.buri.dao.util.impl.BuriStateUtilImpl#loadBranchWalker([userContext={action=null, userData=null, data=org.escafe.buri.entity.BuriTestINT@4856d149, callPath=wakanagoTest.ワカナゴテスト.開始[]}/callPath=wakanagoTest.ワカナゴテスト.開始[]/dataID=null/buriUserID=null/appUserId=null/statusID=null/targetDtoClass=null/startParticipantName=null/activityNames=null/afterCallMethods=[]/exception=null])
DEBUG 2009-03-17 11:08:03,196 [main] END org.escafe.buri.dao.util.impl.BuriStateUtilImpl#loadBranchWalker([userContext={action=null, userData=null, data=org.escafe.buri.entity.BuriTestINT@4856d149, callPath=wakanagoTest.ワカナゴテスト.開始[]}/callPath=wakanagoTest.ワカナゴテスト.開始[]/dataID=null/buriUserID=null/appUserId=null/statusID=null/targetDtoClass=null/startParticipantName=null/activityNames=null/afterCallMethods=[]/exception=null]) : [parentBranchID=0/branchID=0/parentPath=wakanagoTest.ワカナゴテスト[]/nowPath=null]
DEBUG 2009-03-17 11:08:03,196 [main] BEGIN org.escafe.buri.dao.util.impl.BuriStateUtilImpl#saveBranch([parentBranchID=0/branchID=0/parentPath=wakanagoTest.ワカナゴテスト.開始[]/nowPath=wakanagoTest.ワカナゴテスト.開始.開始[..wakanagoTest_wp1_act1]], org.escafe.buri.dataaccess.impl.BuriDataAccessFactoryImpl@3bc634b9, [userContext={action=null, userData=null, data=org.escafe.buri.entity.BuriTestINT@4856d149, callPath=wakanagoTest.ワカナゴテスト.開始[]}/callPath=wakanagoTest.ワカナゴテスト.開始[]/dataID=null/buriUserID=null/appUserId=null/statusID=null/targetDtoClass=null/startParticipantName=null/activityNames=null/afterCallMethods=[]/exception=null])
DEBUG 2009-03-17 11:08:03,196 [main] BEGIN org.escafe.buri.dao.util.impl.BTIDUtilImpl#getCurrentBtId()
DEBUG 2009-03-17 11:08:03,197 [main] BEGIN org.escafe.buri.dao.util.impl.BTIDUtilImpl#setBtId(0)
DEBUG 2009-03-17 11:08:03,197 [main] END org.escafe.buri.dao.util.impl.BTIDUtilImpl#setBtId(0) : null
DEBUG 2009-03-17 11:08:03,197 [main] END org.escafe.buri.dao.util.impl.BTIDUtilImpl#getCurrentBtId() : 0
DEBUG 2009-03-17 11:08:03,197 [main] BEGIN org.escafe.buri.dao.util.impl.BuriDataUtilImpl#getBuriDataId(org.escafe.buri.dataaccess.impl.BuriDataAccessFactoryImpl@3bc634b9, [userContext={action=null, userData=null, data=org.escafe.buri.entity.BuriTestINT@4856d149, callPath=wakanagoTest.ワカナゴテスト.開始[]}/callPath=wakanagoTest.ワカナゴテスト.開始[]/dataID=null/buriUserID=null/appUserId=null/statusID=null/targetDtoClass=null/startParticipantName=null/activityNames=null/afterCallMethods=[]/exception=null])
DEBUG 2009-03-17 11:08:03,198 [main] select T1_.DATA_ID as C1_, T1_.PKEY_VAL as C2_, T1_.PKEY_NUM as C3_, T1_.DATA_TYPE as C4_, T1_.TABLE_NAME as C5_, T1_.INSERT_USER_ID as C6_ from BURI_DATA T1_ where ((T1_.DATA_TYPE = 'org.escafe.buri.entity.BuriTestINT') and (T1_.PKEY_NUM = 0))
DEBUG 2009-03-17 11:08:03,199 [main] call next value for BURI_DATA_SEQ
DEBUG 2009-03-17 11:08:03,199 [main] insert into BURI_DATA (DATA_ID, PKEY_VAL, PKEY_NUM, DATA_TYPE, TABLE_NAME, INSERT_USER_ID) values (448, null, 0, 'org.escafe.buri.entity.BuriTestINT', 'BURI_TEST_INT', null)
DEBUG 2009-03-17 11:08:03,200 [main] END org.escafe.buri.dao.util.impl.BuriDataUtilImpl#getBuriDataId(org.escafe.buri.dataaccess.impl.BuriDataAccessFactoryImpl@3bc634b9, [userContext={action=null, userData=null, data=org.escafe.buri.entity.BuriTestINT@4856d149, callPath=wakanagoTest.ワカナゴテスト.開始[]}/callPath=wakanagoTest.ワカナゴテスト.開始[]/dataID=null/buriUserID=null/appUserId=null/statusID=null/targetDtoClass=null/startParticipantName=null/activityNames=null/afterCallMethods=[]/exception=null]) : 448
DEBUG 2009-03-17 11:08:03,200 [main] call next value for BURI_BRANCH_SEQ
DEBUG 2009-03-17 11:08:03,200 [main] insert into BURI_BRANCH (BRANCH_ID, PARENT_BRANCH_ID, PATH_ID, DATA_ID, BT_ID, PROCESS_DATE, VERSION_NO) values (556, 0, null, 448, 0, null, 1)
DEBUG 2009-03-17 11:08:03,201 [main] END org.escafe.buri.dao.util.impl.BuriStateUtilImpl#saveBranch([parentBranchID=0/branchID=0/parentPath=wakanagoTest.ワカナゴテスト.開始[]/nowPath=wakanagoTest.ワカナゴテスト.開始.開始[..wakanagoTest_wp1_act1]], org.escafe.buri.dataaccess.impl.BuriDataAccessFactoryImpl@3bc634b9, [userContext={action=null, userData=null, data=org.escafe.buri.entity.BuriTestINT@4856d149, callPath=wakanagoTest.ワカナゴテスト.開始[]}/callPath=wakanagoTest.ワカナゴテスト.開始[]/dataID=null/buriUserID=null/appUserId=null/statusID=null/targetDtoClass=null/startParticipantName=null/activityNames=null/afterCallMethods=[]/exception=null]) : null
DEBUG 2009-03-17 11:08:03,201 [main] BEGIN org.escafe.buri.dao.util.impl.BuriStateUtilImpl#saveStatus(org.escafe.buri.dataaccess.impl.BuriDataAccessFactoryImpl@3bc634b9, [userContext={action=null, userData=null, data=org.escafe.buri.entity.BuriTestINT@4856d149, callPath=wakanagoTest.ワカナゴテスト.開始[]}/callPath=wakanagoTest.ワカナゴテスト.開始[]/dataID=448/buriUserID=null/appUserId=null/statusID=null/targetDtoClass=null/startParticipantName=null/activityNames=null/afterCallMethods=[]/exception=null], [parentBranchID=0/branchID=556/parentPath=wakanagoTest.ワカナゴテスト.開始[]/nowPath=wakanagoTest.ワカナゴテスト.開始.開始[..wakanagoTest_wp1_act1]])
DEBUG 2009-03-17 11:08:03,201 [main] BEGIN org.escafe.buri.dao.util.impl.BuriDataUtilImpl#storeData(org.escafe.buri.dataaccess.impl.BuriDataAccessFactoryImpl@3bc634b9, [userContext={action=null, userData=null, data=org.escafe.buri.entity.BuriTestINT@4856d149, callPath=wakanagoTest.ワカナゴテスト.開始[]}/callPath=wakanagoTest.ワカナゴテスト.開始[]/dataID=448/buriUserID=null/appUserId=null/statusID=null/targetDtoClass=null/startParticipantName=null/activityNames=null/afterCallMethods=[]/exception=null])
DEBUG 2009-03-17 11:08:03,203 [main] BEGIN org.escafe.buri.service.BuriTestINTService#update(org.escafe.buri.entity.BuriTestINT@4856d149)
DEBUG 2009-03-17 11:08:03,204 [main] update BURI_TEST_INT set VALUE = 'hoge', VERSION_NO = VERSION_NO + 1 where TEST_ID = null and VERSION_NO = null
DEBUG 2009-03-17 11:08:03,205 [main] END org.escafe.buri.service.BuriTestINTService#update(org.escafe.buri.entity.BuriTestINT@4856d149) Throwable:org.seasar.extension.jdbc.exception.SOptimisticLockException: [ESSR0736]エンティティ(org.escafe.buri.entity.BuriTestINT@4856d149)は既に変更されています。
DEBUG 2009-03-17 11:08:03,205 [main] [OGNL ERROR]buriTestINTService.update(#data)ognl.MethodFailedException: Method "update" failed for object org.escafe.buri.service.BuriTestINTService$$EnhancedByS2AOP$$6b1ce2ad@580c5da6 [org.seasar.extension.jdbc.exception.SOptimisticLockException: [ESSR0736]エンティティ(org.escafe.buri.entity.BuriTestINT@4856d149)は既に変更されています。]
DEBUG 2009-03-17 11:08:03,205 [main] [Ljava.lang.StackTraceElement;@13d86a73
DEBUG 2009-03-17 11:08:03,206 [main] Line:0//式=[buriTestINTService.update(#data)] :null
DEBUG 2009-03-17 11:08:03,206 [main] END org.escafe.buri.dao.util.impl.BuriDataUtilImpl#storeData(org.escafe.buri.dataaccess.impl.BuriDataAccessFactoryImpl@3bc634b9, [userContext={action=null, userData=null, data=org.escafe.buri.entity.BuriTestINT@4856d149, callPath=wakanagoTest.ワカナゴテスト.開始[]}/callPath=wakanagoTest.ワカナゴテスト.開始[]/dataID=448/buriUserID=null/appUserId=null/statusID=null/targetDtoClass=null/startParticipantName=null/activityNames=null/afterCallMethods=[]/exception=null]) Throwable:org.seasar.coffee.script.exception.ScriptExecuteException: [ESCS0002]OGNL値取得エラー:expression={data=org.escafe.buri.entity.BuriTestINT@4856d149}:root=Method "update" failed for object org.escafe.buri.service.BuriTestINTService$$EnhancedByS2AOP$$6b1ce2ad@580c5da6:context={3} {2}
DEBUG 2009-03-17 11:08:03,206 [main] END org.escafe.buri.dao.util.impl.BuriStateUtilImpl#saveStatus(org.escafe.buri.dataaccess.impl.BuriDataAccessFactoryImpl@3bc634b9, [userContext={action=null, userData=null, data=org.escafe.buri.entity.BuriTestINT@4856d149, callPath=wakanagoTest.ワカナゴテスト.開始[]}/callPath=wakanagoTest.ワカナゴテスト.開始[]/dataID=448/buriUserID=null/appUserId=null/statusID=null/targetDtoClass=null/startParticipantName=null/activityNames=null/afterCallMethods=[]/exception=null], [parentBranchID=0/branchID=556/parentPath=wakanagoTest.ワカナゴテスト.開始[]/nowPath=wakanagoTest.ワカナゴテスト.開始.開始[..wakanagoTest_wp1_act1]]) Throwable:org.seasar.coffee.script.exception.ScriptExecuteException: [ESCS0002]OGNL値取得エラー:expression={data=org.escafe.buri.entity.BuriTestINT@4856d149}:root=Method "update" failed for object org.escafe.buri.service.BuriTestINTService$$EnhancedByS2AOP$$6b1ce2ad@580c5da6:context={3} {2}
DEBUG 2009-03-17 11:08:03,207 [main] トランザクションをロールバックしました。tx=[FormatId=4360, GlobalId=1237255677474/3, BranchId=]
DEBUG 2009-03-17 11:08:03,207 [main] 論理的なコネクションを閉じました。tx=[FormatId=4360, GlobalId=1237255677474/3, BranchId=]
DEBUG 2009-03-17 11:08:03,291 [main] 物理的なコネクションを閉じました

2009-03-15

[][][][] BuriをS2JDBC対応にしてみる その4

S2Daojarを取り除いてJUnitを通すことを目標にして、いろいろいじくっていますが当然デグってます。

org.escafe.buri.dao.util.BuriDataUtilTestのtestDataUtilTxで以下のような例外がでている状況。なんだろう原因w

setupPkeyでif (util instanceof DataAccessUtilLongKey) がtrueでないようです。これが原因?

ちなみに、utilの中身は、

wakanagoTest.wakanagoTest_wp1_org_escafe_buri_entity_BuriTestINT_DataAccessUtil

になってました。

id:imai78さん

log4j.propertiesをどう直せばいいんだっけ?

java.lang.NullPointerException
	at org.escafe.buri.util.packages.abst.AbstDataAccessUtilManyKey.getKey(AbstDataAccessUtilManyKey.java:19)
	at wakanagoTest.wakanagoTest_wp1_org_escafe_buri_entity_BuriTestINT_DataAccessUtil.getKey(wakanagoTest_wp1_org_escafe_buri_entity_BuriTestINT_DataAccessUtil.java:20)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl.setupPkey(BuriDataUtilImpl.java:274)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl.getBuriDataDto(BuriDataUtilImpl.java:233)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl.getBuriDataId(BuriDataUtilImpl.java:283)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl$$EnhancedByS2AOP$$969e65.$$getBuriDataId$$invokeSuperMethod$$(BuriDataUtilImpl$$EnhancedByS2AOP$$969e65.java)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl$$EnhancedByS2AOP$$969e65$$MethodInvocation$$getBuriDataId0.proceed(MethodInvocationClassGenerator.java)
	at org.seasar.framework.aop.impl.NestedMethodInvocation.proceed(NestedMethodInvocation.java:55)
	at org.seasar.framework.aop.interceptors.TraceInterceptor.invoke(TraceInterceptor.java:73)
	at org.seasar.framework.aop.impl.NestedMethodInvocation.proceed(NestedMethodInvocation.java:53)
	at org.seasar.framework.aop.interceptors.InterceptorChain.invoke(InterceptorChain.java:49)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl$$EnhancedByS2AOP$$969e65$$MethodInvocation$$getBuriDataId0.proceed(MethodInvocationClassGenerator.java)
	at org.escafe.buri.dao.util.impl.BuriDataUtilImpl$$EnhancedByS2AOP$$969e65.getBuriDataId(BuriDataUtilImpl$$EnhancedByS2AOP$$969e65.java)
	at org.escafe.buri.dao.util.BuriDataUtilTest.testDataUtilTx(BuriDataUtilTest.java:50)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at org.seasar.framework.unit.S2FrameworkTestCase.doRunTest(S2FrameworkTestCase.java:519)
	at org.seasar.extension.unit.S2TestCase.doRunTest(S2TestCase.java:103)
	at org.seasar.framework.unit.S2FrameworkTestCase.runBare(S2FrameworkTestCase.java:308)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

2009-03-07

[][][][] BuriをS2JDBC対応にしてみる その3

id:makotan、ありがとう!なんとかユニットテストが通るようになりました。

基本的には、S2JDBCのServiceクラスをDaoに見せるように修正した感じ。

次はサンプルアプリをS2JDBC用に書き換えてテストしてみる。最終的にはS2Daojarを依存関係から外して使えるようにしてしまおうっとw つまり、BuriをS2Dao非依存で使えるようにしたい。


package org.escafe.buri.compiler.util.impl.rules;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.TypeVariable;
import java.util.Iterator;
import java.util.List;

import javax.persistence.Id;
import javax.persistence.Table;

import org.escafe.buri.common.util.BuriConfiguration;
import org.escafe.buri.common.util.ClassDefUtil;
import org.escafe.buri.common.util.ClassDefUtilImpl;
import org.escafe.buri.event.util.caller.DataAccessRuleEventCaller;
import org.escafe.buri.oouo.internal.structure.BuriDataFieldType;

import org.seasar.framework.beans.BeanDesc;
import org.seasar.framework.beans.PropertyDesc;
import org.seasar.framework.beans.factory.BeanDescFactory;
import org.seasar.framework.container.S2Container;
import org.seasar.framework.log.Logger;
import org.seasar.framework.util.ClassUtil;
import org.seasar.framework.util.StringUtil;

/**
 * S2JDBC用Dao自動設定用クラス
 * 
 * @author j5ik2o
 * 
 */
public class S2JDBCToDataAccessRule extends AbstractBuriDataFieldProcRule {

	private static Logger logger = Logger
			.getLogger(S2JDBCToDataAccessRule.class);

	protected String serviceKeyName = "service";

	public final String serviceKEY = "service";

	private BuriConfiguration configuration;

	private S2Container container;

	private ClassDefUtil classDefUtil;

	private DataAccessRuleEventCaller dataAccessRuleEventCaller;

	@Override
	public boolean getRequiredRule(BuriDataFieldType src) {
		if (hasName(src, "preprocess")) {
			return false;
		}
		return true;
	}

	public boolean isRequiredNegotiate(BuriDataFieldType src) {
		if (src.getKeys().size() == 0) {
			return true;
		}
		if (!hasName(src, "select")) {
			return true;
		}
		if (!hasName(src, "insert")) {
			return true;
		}
		if (!hasName(src, "update")) {
			return true;
		}
		if (!hasName(src, "delete")) {
			return true;
		}
		if (!hasName(src, "tableName")) {
			return true;
		}
		return false;
	}

	@Override
	public boolean fstCheckProcess(BuriDataFieldType src) {
		if (!isRequiredNegotiate(src)) {
			return false;
		}
		if (src.getCache().containsKey(serviceKeyName)) {

		} else if (hasName(src, serviceKEY)) {
			src.getCache().put(serviceKeyName, getNameVal(src, serviceKEY));
		}
		dataAccessRuleEventCaller.determinedRule(this, src);
		return true;
	}

	@Override
	public boolean process(BuriDataFieldType src) {
		// if( ! src.getCache().containsKey(serviceKeyName) ) {
		// return false;
		// }
		if (src.getCache().containsKey(serviceKeyName + "_end")) {
			return false;
		}
		negotiateService(src);
		dataAccessRuleEventCaller.endNegotiateDao(this, src);
		src.getCache().put(serviceKeyName + "_end", Boolean.TRUE);
		return false;
	}

	protected void negotiateService(BuriDataFieldType src) {
		String dtoClassName = src.getId();
		String serviceName = getServiceName(src, dtoClassName);
		if (serviceName != null) {
			src.getCache().put(serviceKeyName, serviceName);
			Class serviceClass = container.getRoot().getComponentDef(
					serviceName).getComponentClass();
			pkeySetup(src);

			if (src.getKeys().size() == 1) {
				String keyName = src.getKeys().keySet().toArray()[0].toString();
				BeanDesc beanDesc = BeanDescFactory.getBeanDesc(ClassUtil
						.forName(dtoClassName));
				Class tgtClass = beanDesc.getPropertyDesc(keyName)
						.getPropertyType();
				src.getCache().put(serviceKeyName + "_KeyType", tgtClass);
				src.getCache().put(serviceKeyName + "_KeyName", keyName);
				findAndSetupAllMethod(src, beanDesc, serviceClass);
			}
		}

	}

	/**
	 * 自動設定を行います。
	 * 
	 * @param src
	 * @param beanDesc
	 * @param serviceClass
	 */
	protected void findAndSetupAllMethod(BuriDataFieldType src,
			BeanDesc beanDesc, Class<?> serviceClass) {
		Method methods[] = serviceClass.getMethods();
		for (Method method : methods) {
			String methodName = method.getName();
			selectSetup(src, method, methodName, beanDesc);
			updateSetup(src, method, methodName, beanDesc);
			deleteSetup(src, method, methodName, beanDesc);
			selectManySetup(src, method, methodName, beanDesc);
			insertSetup(src, method, methodName, beanDesc);
			tableNameSetup(src, method, methodName, beanDesc);
			selectNextValSetup(src, method, methodName, beanDesc);
		}
	}

	/**
	 * Sequence取得用メソッド実行OGNL文をセットします。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @param beanDesc
	 */
	protected void selectNextValSetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (isSelectNextValMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			String pkey = (String) src.getCache().get(
					serviceKeyName + "_KeyName");
			String selectNextVal = "#data." + pkey + " = " + serviceName + "."
					+ methodName + "()";
			if (!StringUtil.isEmpty(src.getInsert())) {
				String insertStr = src.getInsert();
				StringBuffer strBuff = new StringBuffer();
				strBuff.append(selectNextVal.toString());
				strBuff.append("\n");
				strBuff.append(insertStr);
				src.setInsert(strBuff.toString());
			} else {
				src.setInsert(selectNextVal.toString());
			}
		}
	}

	/**
	 * 引数のメソッドがSequence取得用か判定します。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @return
	 */
	protected boolean isSelectNextValMethod(BuriDataFieldType src,
			Method method, String methodName) {
		if (methodName.startsWith("selectNextVal")) {
			if (method.getParameterTypes().length == 0) {
				return true;
			}
		}
		return false;
	}

	/**
	 * テーブル名をセットします。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @param beanDesc
	 */
	protected void tableNameSetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getTableName())) {
			return;
		}
		Class<?> tgt = ClassUtil.forName(src.getId());
		String tableName = classDefUtil.getClazz(tgt).getSimpleName();
		Table table = (Table) tgt.getAnnotation(Table.class);
		if (table != null) {
			tableName = table.name();
		}
		if (!StringUtil.isEmpty(tableName)) {
			src.setTableName(tableName);
		}
	}

	/**
	 * 複数データ取得用メソッド実行OGNL文をセットします。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @param beanDesc
	 */
	protected void selectManySetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getSelectMany())) {
			return;
		}

		if (isSelectManyMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setSelectMany(serviceName + "." + methodName + "(#data)");
		}
	}

	/**
	 * 引数のメソッドが複数データ取得用か判定します。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @return
	 */
	protected boolean isSelectManyMethod(BuriDataFieldType src, Method method,
			String methodName) {
		if (methodName.startsWith("get") || methodName.startsWith("select")) {
			if (method.getParameterTypes().length == 1) {
				if (method.getParameterTypes()[0].isAssignableFrom(List.class)) {
					return true;
				}
			}
		}
		return false;
	}

	/**
	 * データ削除用メソッド実行OGNL文をセットします。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @param beanDesc
	 */
	protected void deleteSetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getDelete())) {
			return;
		}

		if (isDeleteMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setDelete(serviceName + "." + methodName + "(#data)");
		}
	}

	/**
	 * 引数のメソッドがデータ削除用か判定します。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @return
	 */
	protected boolean isDeleteMethod(BuriDataFieldType src, Method method,
			String methodName) {
		if (methodName.startsWith("del")) {
			if (method.getParameterTypes().length == 1) {
				return true;
			}
		}
		return false;
	}

	/**
	 * データ更新用メソッド実行OGNL文をセットします。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @param beanDesc
	 */
	protected void updateSetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getUpdate())) {
			return;
		}

		if (isUpdateMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setUpdate(serviceName + "." + methodName + "(#data)");
		}
	}

	/**
	 * 引数のメソッドがデータ更新用か判定します。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @return
	 */
	protected boolean isUpdateMethod(BuriDataFieldType src, Method method,
			String methodName) {
		if (methodName.startsWith("update")) {
			if (method.getParameterTypes().length == 1) {
				return true;
			}
		}
		return false;
	}

	/**
	 * データ作成用メソッド実行OGNL文をセットします。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @param beanDesc
	 */
	protected void insertSetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (isInsertMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			String insertOgnl = serviceName + "." + methodName + "(#data)";
			if (!StringUtil.isEmpty(src.getInsert())) {
				String insertStr = src.getInsert();
				StringBuffer strBuff = new StringBuffer();
				strBuff.append(insertStr);
				strBuff.append("\n");
				strBuff.append(insertOgnl);
				src.setInsert(strBuff.toString());
			} else {
				src.setInsert(insertOgnl);
			}
		}
	}

	/**
	 * 引数のメソッドがデータ作成用か判定します。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @return
	 */
	protected boolean isInsertMethod(BuriDataFieldType src, Method method,
			String methodName) {
		if (methodName.startsWith("insert")) {
			if (method.getParameterTypes().length == 1) {
				return true;
			}
		}
		return false;
	}

	/**
	 * 単一データ取得用メソッド実行OGNL文をセットします。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @param beanDesc
	 */
	protected void selectSetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getSelect())) {
			return;
		}

		if (isSelectMethod(src, method, methodName)) {
			String keyName = src.getCache().get(serviceKeyName + "_KeyName")
					.toString();
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setSelect(serviceName + "." + methodName + "(#data." + keyName
					+ ")");
		}
	}

	/**
	 * 引数のメソッドが単一データ取得用か判定します。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @return
	 */
	protected boolean isSelectMethod(BuriDataFieldType src, Method method,
			String methodName) {
		if (methodName.startsWith("get") || methodName.startsWith("select")) {
			if (method.getParameterTypes().length == 1) {
				Class tgtClass = (Class) src.getCache().get(
						serviceKeyName + "_KeyType");
				if (method.getParameterTypes()[0].equals(tgtClass)) {
					return true;
				}
			}
		}
		return false;
	}

	/**
	 * ID存在判定用OGNL文をセットします。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @param beanDesc
	 */
	protected void pkeySetup(BuriDataFieldType src) {
		if ((src.getKeys().size() > 0) || hasName(src, "pkey")) {
			return;
		}
		Class<?> entityClass = ClassUtil.forName(src.getId());
		BeanDesc bd = BeanDescFactory.getBeanDesc(entityClass);
		for (int i = 0; i < bd.getPropertyDescSize(); i++) {
			PropertyDesc pd = bd.getPropertyDesc(i);
			Field f = pd.getField();
			Id id = f.getAnnotation(Id.class);
			if (id != null) {
				String condition = createPkeyCondition(pd);
				src.getKeys().put(pd.getPropertyName(), condition);
			}
		}
	}

	/**
	 * IDアノテーションのフィールド型を判定し、ID存在判定OGNL文を返却します。
	 * 
	 * @param src
	 * @param method
	 * @param methodName
	 * @param beanDesc
	 */
	protected String createPkeyCondition(PropertyDesc pd) {
		String condition = null;
		String pkeyName = pd.getPropertyName();
		Class propType = pd.getPropertyType();
		if (propType.equals(Long.TYPE)) {
			condition = pkeyName + " != 0";
		} else if (propType.equals(Long.class)) {
			condition = pkeyName + " != null" + " && " + pkeyName + " != 0";
		} else if (propType.isAssignableFrom(Number.class)) {
			condition = pkeyName + " != 0";
		} else {
			condition = pkeyName + " != null";
		}
		return condition;
	}

	protected String getServiceName(BuriDataFieldType src, String dtoClassName) {
		String service = null;
		String shtName = createServiceName(src, dtoClassName);
		String shtName2 = shtName.substring(0, 1).toLowerCase()
				+ shtName.substring(1);
		if (container.getRoot().hasComponentDef(shtName)) {
			service = shtName;
		} else if (container.getRoot().hasComponentDef(shtName2)) {
			service = shtName2;
		} else {
			service = findserviceClass(shtName, dtoClassName);
		}
		if (service == null) {
			service = findserviceClassFromNamespace(shtName, dtoClassName);
		}
		return service;
	}

	protected String findserviceClassFromNamespace(String shtName,
			String dtoClassName) {
		String service = null;
		List serviceNamespace = configuration.getValList("Namespace");
		Iterator ite = serviceNamespace.iterator();
		while (ite.hasNext()) {
			String nameSpace = ite.next().toString();
			String componentName = nameSpace + "." + shtName;
			if (container.getRoot().hasComponentDef(componentName)) {
				return componentName;
			}
		}
		return service;
	}

	protected String findserviceClass(String shtName, String dtoClassName) {
		String service = null;
		List servicePackageName = configuration
				.getValList("servicePackageName");
		Iterator ite = servicePackageName.iterator();
		while (ite.hasNext()) {
			String pacName = ite.next().toString();
			String fullName = pacName + "." + shtName;
			service = classNameToservice(fullName);
			if (service != null) {
				break;
			}
		}
		/*
		 * if(service == null) { service =
		 * genarateserviceClass(shtName,dtoClassName); }
		 */
		return service;
	}

	/*
	 * protected String genarateserviceClass(String shtName,String dtoClassName)
	 * { Class tgtClass = ClassUtil.forName(dtoClassName); String packageName =
	 * tgtClass.getPackage().getName(); packageName =
	 * packageName.replaceAll("dto","service") + "." + shtName; packageName =
	 * classNameToservice(packageName); return packageName; }
	 */

	protected String classNameToservice(String fullName) {
		String service = null;
		if (ClassDefUtilImpl.isClassName(fullName)) {
			Class serviceClass = ClassUtil.forName(fullName);
			if (container.getRoot().hasComponentDef(serviceClass)) {
				service = container.getRoot().getComponentDef(serviceClass)
						.getComponentName();
			}
		}
		return service;
	}

	protected String createServiceName(BuriDataFieldType src,
			String dtoClassName) {
		if (hasName(src, serviceKEY)) {
			return getNameVal(src, serviceKEY);
		}
		if (dtoClassName.indexOf("$$") > -1) {
			int enhansPos = dtoClassName.indexOf("$$");
			dtoClassName = dtoClassName.substring(0, enhansPos);
		}
		Class tgtClass = ClassUtil.forName(dtoClassName);
		String shtName = ClassUtil.getShortClassName(tgtClass);
		if (shtName.length() > 3) {
			if (shtName.substring(shtName.length() - 3).equalsIgnoreCase("Dto")) {
				shtName = shtName.substring(0, shtName.length() - 3);
			}
		}
		if (shtName.length() > 6) {
			if (shtName.substring(shtName.length() - 6).equalsIgnoreCase(
					"Entity")) {
				shtName = shtName.substring(0, shtName.length() - 6);
			}
		}
		shtName = shtName + "Service";
		return shtName;
	}

	public S2Container getContainer() {
		return container;
	}

	public void setContainer(S2Container container) {
		this.container = container;
	}

	public BuriConfiguration getConfiguration() {
		return configuration;
	}

	public void setConfiguration(BuriConfiguration configuration) {
		this.configuration = configuration;
	}

	public ClassDefUtil getClassDefUtil() {
		return classDefUtil;
	}

	public void setClassDefUtil(ClassDefUtil classDefUtil) {
		this.classDefUtil = classDefUtil;
	}

	public DataAccessRuleEventCaller getDataAccessRuleEventCaller() {
		return dataAccessRuleEventCaller;
	}

	public void setDataAccessRuleEventCaller(
			DataAccessRuleEventCaller dataAccessRuleEventCaller) {
		this.dataAccessRuleEventCaller = dataAccessRuleEventCaller;
	}

}

2009-03-06

[][][][] BuriをS2JDBC対応にしてみる その2 

とりあえず、S2JDBCToDataAccessRule を実装してみたけど、testDataFieldType08と、testDataFieldType09で 以下の例外が発生してしまった。うーん、何がわるいんだろう。。。test用にs2jdbc.diconや、allTestService.diconを読み込むようにしたつもりですが、どこがいってしまっているかも。。。(ソースはhttps://sisioh.googlecode.com/svn/sandbox/trunk/buri-core はここ)


org.escafe.buri.exception.BuriDataFieldErrorException: [EBRI0001]DataField org.escafe.buri.entity.BuriTestINTでInsertが必要です。Daoを自動設定している場合は、Daoがあるかどうか、diconをincludeしているかどうかを確認してください
	at org.escafe.buri.compiler.util.impl.rules.DataAccessorProcRule.finishCheck(DataAccessorProcRule.java:41)
	at org.escafe.buri.compiler.util.impl.BuriDataFieldCompilePreprocessorImpl.finishProcess(BuriDataFieldCompilePreprocessorImpl.java:55)
	at org.escafe.buri.compiler.util.impl.BuriDataFieldCompilePreprocessorImpl.checkDataAccess(BuriDataFieldCompilePreprocessorImpl.java:48)
	at org.escafe.buri.compiler.util.impl.BuriDataFieldCompilePreprocessorImpl.preprocess(BuriDataFieldCompilePreprocessorImpl.java:33)
	at org.escafe.buri.compiler.util.impl.DataFieldS2JDBCTest.testDataFieldType08(DataFieldS2JDBCTest.java:120)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at org.seasar.framework.unit.S2FrameworkTestCase.doRunTest(S2FrameworkTestCase.java:519)
	at org.seasar.extension.unit.S2TestCase.doRunTest(S2TestCase.java:103)
	at org.seasar.framework.unit.S2FrameworkTestCase.runBare(S2FrameworkTestCase.java:308)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


package org.escafe.buri.compiler.util.impl.rules;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;

import javax.persistence.Id;
import javax.persistence.Table;

import org.escafe.buri.common.util.BuriConfiguration;
import org.escafe.buri.common.util.ClassDefUtil;
import org.escafe.buri.common.util.ClassDefUtilImpl;
import org.escafe.buri.event.util.caller.DataAccessRuleEventCaller;
import org.escafe.buri.oouo.internal.structure.BuriDataFieldType;
import org.seasar.framework.beans.BeanDesc;
import org.seasar.framework.beans.PropertyDesc;
import org.seasar.framework.beans.factory.BeanDescFactory;
import org.seasar.framework.container.S2Container;
import org.seasar.framework.log.Logger;
import org.seasar.framework.util.ClassUtil;
import org.seasar.framework.util.StringUtil;

public class S2JDBCToDataAccessRule extends AbstractBuriDataFieldProcRule {
	private static Logger logger =
	    Logger.getLogger(S2JDBCToDataAccessRule.class);

	protected String serviceKeyName = "service";

	public final String SERVICEKEY = "service";

	private BuriConfiguration configuration;

	private S2Container container;

	private ClassDefUtil classDefUtil;

	private DataAccessRuleEventCaller dataAccessRuleEventCaller;

	@Override
	public boolean getRequiredRule(BuriDataFieldType src) {
		if (hasName(src, "preprocess")) {
			return false;
		}
		return true;
	}

	public boolean isRequiredNegotiate(BuriDataFieldType src) {
		if (src.getKeys().size() == 0) {
			return true;
		}
		if (!hasName(src, "select")) {
			return true;
		}
		if (!hasName(src, "insert")) {
			return true;
		}
		if (!hasName(src, "update")) {
			return true;
		}
		if (!hasName(src, "delete")) {
			return true;
		}
		// if (!hasName(src, "tableName")) {
		// return true;
		// }
		return false;
	}

	@Override
	public boolean fstCheckProcess(BuriDataFieldType src) {
		if (!isRequiredNegotiate(src)) {
			return false;
		}
		if (src.getCache().containsKey(serviceKeyName)) {
		} else if (hasName(src, SERVICEKEY)) {
			src.getCache().put(serviceKeyName, getNameVal(src, SERVICEKEY));
		}
		dataAccessRuleEventCaller.determinedRule(this, src);
		return true;
	}

	@Override
	public boolean process(BuriDataFieldType src) {
		// if( ! src.getCache().containsKey(serviceKeyName) ) {
		// return false;
		// }
		if (src.getCache().containsKey(serviceKeyName + "_end")) {
			return false;
		}
		negotiateService(src);
		dataAccessRuleEventCaller.endNegotiateDao(this, src);
		src.getCache().put(serviceKeyName + "_end", Boolean.TRUE);
		return false;
	}

	protected void negotiateService(BuriDataFieldType src) {
		String dtoClassName = src.getId();
		String serviceName = getServiceName(src, dtoClassName);
		if (serviceName != null) {
			src.getCache().put(serviceKeyName, serviceName);
			Class serviceClass =
			    container
			        .getRoot()
			        .getComponentDef(serviceName)
			        .getComponentClass();
			pkeySetup(src);
			if (src.getKeys().size() == 1) {
				String keyName = src.getKeys().keySet().toArray()[0].toString();
				BeanDesc beanDesc =
				    BeanDescFactory
				        .getBeanDesc(ClassUtil.forName(dtoClassName));
				Class tgtClass =
				    beanDesc.getPropertyDesc(keyName).getPropertyType();
				src.getCache().put(serviceKeyName + "_KeyType", tgtClass);
				src.getCache().put(serviceKeyName + "_KeyName", keyName);
				findAndSetupAllMethod(src, beanDesc, serviceClass);
			}
		}
	}

	protected void findAndSetupAllMethod(BuriDataFieldType src,
	        BeanDesc beanDesc, Class serviceClass) {
		Method methods[] = serviceClass.getDeclaredMethods();
		for (Method method : methods) {
			String methodName = method.getName();
			selectSetup(src, method, methodName, beanDesc);
			updateSetup(src, method, methodName, beanDesc);
			deleteSetup(src, method, methodName, beanDesc);
			selectManySetup(src, method, methodName, beanDesc);
			insertSetup(src, method, methodName, beanDesc);
			tableNameSetup(src);
		}
	}

	protected void tableNameSetup(BuriDataFieldType src) {
		if (!StringUtil.isEmpty(src.getTableName())) {
			return;
		}
		Class tgt = ClassUtil.forName(src.getId());
		String tableName = tgt.getSimpleName();
		Table table = (Table) tgt.getAnnotation(Table.class);
		if (table != null) {
			tableName = table.name();
		}
		if (!StringUtil.isEmpty(tableName)) {
			src.setTableName(tableName);
		}
	}

	protected void selectManySetup(BuriDataFieldType src, Method method,
	        String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getSelectMany())) {
			return;
		}
		if (isSelectManyMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setSelectMany(serviceName + "." + methodName + "(#data)");
		}
	}

	protected boolean isSelectManyMethod(BuriDataFieldType src, Method method,
	        String methodName) {
		if (methodName.startsWith("get") || methodName.startsWith("select")) {
			if (method.getParameterTypes().length == 1) {
				if (method.getParameterTypes()[0].isAssignableFrom(List.class)) {
					return true;
				}
			}
		}
		return false;
	}

	protected void deleteSetup(BuriDataFieldType src, Method method,
	        String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getDelete())) {
			return;
		}
		if (isDeleteMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setDelete(serviceName + "." + methodName + "(#data)");
		}
	}

	protected boolean isDeleteMethod(BuriDataFieldType src, Method method,
	        String methodName) {
		if (methodName.startsWith("del")) {
			if (method.getParameterTypes().length == 1) {
				String clazzName =
				    classDefUtil.getClassName(method.getParameterTypes()[0]);
				if (clazzName.equals(src.getId())) {
					return true;
				}
			}
		}
		return false;
	}

	protected void updateSetup(BuriDataFieldType src, Method method,
	        String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getUpdate())) {
			return;
		}
		if (isUpdateMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setUpdate(serviceName + "." + methodName + "(#data)");
		}
	}

	protected boolean isUpdateMethod(BuriDataFieldType src, Method method,
	        String methodName) {
		if (methodName.startsWith("update")) {
			if (method.getParameterTypes().length == 1) {
				String clazzName =
				    classDefUtil.getClassName(method.getParameterTypes()[0]);
				if (clazzName.equals(src.getId())) {
					return true;
				}
			}
		}
		return false;
	}

	protected void insertSetup(BuriDataFieldType src, Method method,
	        String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getInsert())) {
			return;
		}
		if (isInsertMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setInsert(serviceName + "." + methodName + "(#data)");
		}
	}

	protected boolean isInsertMethod(BuriDataFieldType src, Method method,
	        String methodName) {
		if (methodName.startsWith("insert")) {
			if (method.getParameterTypes().length == 1) {
				String clazzName =
				    classDefUtil.getClassName(method.getParameterTypes()[0]);
				if (clazzName.equals(src.getId())) {
					return true;
				}
			}
		}
		return false;
	}

	protected void selectSetup(BuriDataFieldType src, Method method,
	        String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getSelect())) {
			return;
		}
		if (isSelectMethod(src, method, methodName)) {
			String keyName =
			    src.getCache().get(serviceKeyName + "_KeyName").toString();
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setSelect(serviceName
			    + "."
			    + methodName
			    + "(#data."
			    + keyName
			    + ")");
		}
	}

	protected boolean isSelectMethod(BuriDataFieldType src, Method method,
	        String methodName) {
		if (methodName.startsWith("get")
		    || methodName.startsWith("select")
		    || methodName.startsWith("find")) {
			if (method.getParameterTypes().length == 1) {
				Class tgtClass =
				    (Class) src.getCache().get(serviceKeyName + "_KeyType");
				if (method.getParameterTypes()[0].equals(tgtClass)) {
					return true;
				}
			}
		}
		return false;
	}

	protected void pkeySetup(BuriDataFieldType src) {
		if ((src.getKeys().size() > 0) || hasName(src, "pkey")) {
			return;
		}
		Class<?> entityClass = ClassUtil.forName(src.getId());
		BeanDesc bd = BeanDescFactory.getBeanDesc(entityClass);
		for (int i = 0; i < bd.getPropertyDescSize(); i++) {
			PropertyDesc pd = bd.getPropertyDesc(i);
			Field f = pd.getField();
			Id id = f.getAnnotation(Id.class);
			if (id != null) {
				String condition =
				    createPkeyCondition(pd.getPropertyName(), pd
				        .getPropertyType());
				src.getKeys().put(pd.getPropertyName(), condition);
			}
		}
	}

	protected String createPkeyCondition(String pkeyName, Class propType) {
		String condition = null;
		if (propType.equals(Long.TYPE)) {
			condition = pkeyName + " != 0";
		} else if (propType.isAssignableFrom(Number.class)) {
			condition = pkeyName + " != 0";
		} else {
			condition = pkeyName + " != null";
		}
		return condition;
	}

	protected String getServiceName(BuriDataFieldType src, String dtoClassName) {
		String dao = null;
		String shtName = createServiceName(src, dtoClassName);
		String shtName2 =
		    shtName.substring(0, 1).toLowerCase() + shtName.substring(1);
		if (container.getRoot().hasComponentDef(shtName)) {
			dao = shtName;
		} else if (container.getRoot().hasComponentDef(shtName2)) {
			dao = shtName2;
		} else {
			dao = findServiceClass(shtName, dtoClassName);
		}
		if (dao == null) {
			dao = findServiceClassFromNamespace(shtName, dtoClassName);
		}
		return dao;
	}

	protected String findServiceClassFromNamespace(String shtName,
	        String dtoClassName) {
		String service = null;
		List serviceNamespace = configuration.getValList("Namespace");
		Iterator ite = serviceNamespace.iterator();
		while (ite.hasNext()) {
			String nameSpace = ite.next().toString();
			String componentName = nameSpace + "." + shtName;
			if (container.getRoot().hasComponentDef(componentName)) {
				return componentName;
			}
		}
		return service;
	}

	protected String findServiceClass(String shtName, String dtoClassName) {
		String service = null;
		List servicePackageName =
		    configuration.getValList("ServicePackageName");
		Iterator ite = servicePackageName.iterator();
		while (ite.hasNext()) {
			String pacName = ite.next().toString();
			String fullName = pacName + "." + shtName;
			service = classNameToService(fullName);
			if (service != null) {
				break;
			}
		}
		/*
		 * if(dao == null) { dao = genarateDaoClass(shtName,dtoClassName); }
		 */
		return service;
	}

	/*
	 * protected String genarateDaoClass(String shtName,String dtoClassName) {
	 * Class tgtClass = ClassUtil.forName(dtoClassName); String packageName =
	 * tgtClass.getPackage().getName(); packageName =
	 * packageName.replaceAll("dto","dao") + "." + shtName; packageName =
	 * classNameToDao(packageName); return packageName; }
	 */
	protected String classNameToService(String fullName) {
		String service = null;
		if (ClassDefUtilImpl.isClassName(fullName)) {
			Class serviceClass = ClassUtil.forName(fullName);
			if (container.getRoot().hasComponentDef(serviceClass)) {
				service =
				    container
				        .getRoot()
				        .getComponentDef(serviceClass)
				        .getComponentName();
			}
		}
		return service;
	}

	protected String createServiceName(BuriDataFieldType src,
	        String dtoClassName) {
		if (hasName(src, SERVICEKEY)) {
			return getNameVal(src, SERVICEKEY);
		}
		if (dtoClassName.indexOf("$$") > -1) {
			int enhansPos = dtoClassName.indexOf("$$");
			dtoClassName = dtoClassName.substring(0, enhansPos);
		}
		Class tgtClass = ClassUtil.forName(dtoClassName);
		String shtName = ClassUtil.getShortClassName(tgtClass);
		if (shtName.length() > 3) {
			if (shtName.substring(shtName.length() - 3).equalsIgnoreCase("Dto")) {
				shtName = shtName.substring(0, shtName.length() - 3);
			}
		}
		if (shtName.length() > 6) {
			if (shtName.substring(shtName.length() - 6).equalsIgnoreCase(
			    "Entity")) {
				shtName = shtName.substring(0, shtName.length() - 6);
			}
		}
		shtName = shtName + "Service";
		return shtName;
	}

	public S2Container getContainer() {
		return container;
	}

	public void setContainer(S2Container container) {
		this.container = container;
	}

	public BuriConfiguration getConfiguration() {
		return configuration;
	}

	public void setConfiguration(BuriConfiguration configuration) {
		this.configuration = configuration;
	}

	public ClassDefUtil getClassDefUtil() {
		return classDefUtil;
	}

	public void setClassDefUtil(ClassDefUtil classDefUtil) {
		this.classDefUtil = classDefUtil;
	}

	public DataAccessRuleEventCaller getDataAccessRuleEventCaller() {
		return dataAccessRuleEventCaller;
	}

	public void setDataAccessRuleEventCaller(
	        DataAccessRuleEventCaller dataAccessRuleEventCaller) {
		this.dataAccessRuleEventCaller = dataAccessRuleEventCaller;
	}
}
/*
 * 作成日: 2006/07/05
 *
 */
package org.escafe.buri.compiler.util.impl;

import org.escafe.buri.common.util.BuriConfiguration;
import org.escafe.buri.compiler.util.BuriDataFieldCompilePreprocessor;
import org.escafe.buri.exception.BuriDataFieldErrorException;
import org.escafe.buri.oouo.internal.structure.BuriDataFieldType;
import org.escafe.buri.oouo.internal.structure.BuriExtendedAttributeType;
import org.seasar.extension.unit.S2TestCase;
import org.seasar.framework.beans.PropertyNotFoundRuntimeException;

public class DataFieldS2JDBCTest extends S2TestCase {
	private String PATH = "buri/dicon/buri-share.dicon";

	private BuriDataFieldCompilePreprocessor bdfcp;

	private BuriConfiguration configuration;

	public DataFieldS2JDBCTest(String name) {
		super(name);
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		include(PATH);
		include("org/escafe/buri/dicon/allTestService.dicon");
	}

	public void testDataFieldType01() {
		BuriDataFieldType dft = new BuriDataFieldType();
		dft.setId("org.escafe.buri.entity.BuriTestINT");
		setBuriDataFieldType(dft, "pkey", "testID,testID!=0");
		setBuriDataFieldType(dft, "insert", "service.insert(#data)");
		setBuriDataFieldType(dft, "update", "service.update(#data)");
		setBuriDataFieldType(dft, "select", "service.select(#data)");
		setBuriDataFieldType(dft, "delete", "service.delete(#data)");
		setBuriDataFieldType(dft, "tableName", "BuriTestINT");
		BuriDataFieldType dst = bdfcp.preprocess(dft);
		assertEquals(dst.getKeys().toString(), "{testID=testID!=0}");
		assertEquals(dst.getInsert(), "service.insert(#data)");
		assertEquals(dst.getUpdate(), "service.update(#data)");
		assertEquals(dst.getSelect(), "service.select(#data)");
		assertEquals(dst.getDelete(), "service.delete(#data)");
		assertEquals(dst.getTableName(), "BuriTestINT");
	}

	public void testDataFieldType04() {
		BuriDataFieldType dft = new BuriDataFieldType();
		dft.setId("org.escafe.buri.entity.BuriTestINT");
		setBuriDataFieldType(dft, "pkey", "id,id!=0");
		setBuriDataFieldType(dft, "insert", "service.insert(#data)");
		setBuriDataFieldType(dft, "update", "service.update(#data)");
		setBuriDataFieldType(dft, "select", "service.select(#data)");
		setBuriDataFieldType(dft, "delete", "service.delete(#data)");
		setBuriDataFieldType(dft, "tableName", "BuriTestINT");
		try {
			bdfcp.preprocess(dft);
			fail();
		} catch (BuriDataFieldErrorException ex) {
			assertTrue(true);
		} catch (PropertyNotFoundRuntimeException ex) {
			assertTrue(true);
		}
	}

	public void testDataFieldType05() {
		BuriDataFieldType dft = new BuriDataFieldType();
		dft.setId("org.escafe.buri.entity.BuriTestINT");
		setBuriDataFieldType(dft, "preprocess", "service.select(#data)");
		BuriDataFieldType dst = bdfcp.preprocess(dft);
		assertEquals(dst.getPreprocess(), "service.select(#data)");
	}

	public void testDataFieldType06() {
		BuriDataFieldType dft = new BuriDataFieldType();
		dft.setId("org.escafe.buri.entity.BuriTestINT");
		setBuriDataFieldType(dft, "preprocess", "service.select(#data)");
		setBuriDataFieldType(dft, "pkey", "testID,testID!=0");
		setBuriDataFieldType(dft, "insert", "service.insert(#data)");
		setBuriDataFieldType(dft, "update", "service.update(#data)");
		setBuriDataFieldType(dft, "select", "service.select(#data)");
		setBuriDataFieldType(dft, "delete", "service.delete(#data)");
		setBuriDataFieldType(dft, "tableName", "BuriTestINT");
		BuriDataFieldType dst = bdfcp.preprocess(dft);
		assertEquals(dst.getKeys().toString(), "{testID=testID!=0}");
		assertEquals(dst.getInsert(), "service.insert(#data)");
		assertEquals(dst.getUpdate(), "service.update(#data)");
		assertEquals(dst.getSelect(), "service.select(#data)");
		assertEquals(dst.getDelete(), "service.delete(#data)");
		assertEquals(dst.getPreprocess(), "service.select(#data)");
	}

	public void testDataFieldType07() {
		BuriDataFieldType dft = new BuriDataFieldType();
		configuration.addValue("DtoPackageName", "org.escafe.buri.entity");
		dft.setId("BuriTestINT");
		setBuriDataFieldType(dft, "pkey", "testID,testID!=0");
		setBuriDataFieldType(dft, "insert", "service.insert(#data)");
		setBuriDataFieldType(dft, "update", "service.update(#data)");
		setBuriDataFieldType(dft, "select", "service.select(#data)");
		setBuriDataFieldType(dft, "delete", "service.delete(#data)");
		setBuriDataFieldType(dft, "tableName", "BuriTestINT");
		BuriDataFieldType dst = bdfcp.preprocess(dft);
		assertEquals(dst.getKeys().toString(), "{testID=testID!=0}");
		assertEquals(dst.getInsert(), "service.insert(#data)");
		assertEquals(dst.getUpdate(), "service.update(#data)");
		assertEquals(dst.getSelect(), "service.select(#data)");
		assertEquals(dst.getDelete(), "service.delete(#data)");
	}

	public void testDataFieldType08() {
		BuriDataFieldType dft = new BuriDataFieldType();
		configuration.addValue("DtoPackageName", "org.escafe.buri.entity");
		configuration.addValue("ServicePackageName", "org.escafe.buri.service");
		dft.setId("BuriTestINT");
		BuriDataFieldType dst = bdfcp.preprocess(dft);
		System.out.println(dst.getKeys().toString());
		assertEquals(dst.getKeys().toString(), "{testID=testID != 0}");
		assertEquals(dst.getInsert(), "BuriTestINTService.insert(#data)");
		assertEquals(dst.getUpdate(), "BuriTestINTService.update(#data)");
		assertEquals(
		    dst.getSelect(),
		    "BuriTestINTService.getBuriTestINT(#data.testID)");
		assertEquals(dst.getDelete(), "BuriTestINTService.delete(#data)");
		assertEquals(
		    dst.getSelectMany(),
		    "BuriTestINTService.getBuriTestINTByIds(#data)");
	}

	public void testDataFieldType09() {
		BuriDataFieldType dft = new BuriDataFieldType();
		dft.setId("org.escafe.buri.entity.BuriTestINT");
		BuriDataFieldType dst = bdfcp.preprocess(dft);
		System.out.println(dst.getKeys().toString());
		assertEquals(dst.getKeys().toString(), "{testID=testID != 0}");
		assertEquals(dst.getInsert(), "BuriTestINTService.insert(#data)");
		assertEquals(dst.getUpdate(), "BuriTestINTService.update(#data)");
		assertEquals(
		    dst.getSelect(),
		    "BuriTestINTService.getBuriTestINT(#data.testID)");
		assertEquals(dst.getDelete(), "BuriTestINTService.delete(#data)");
		assertEquals(
		    dst.getSelectMany(),
		    "BuriTestINTService.getBuriTestINTByIds(#data)");
	}

	private void setBuriDataFieldType(BuriDataFieldType dft, String name,
	        String val) {
		BuriExtendedAttributeType beat = new BuriExtendedAttributeType();
		beat.setName(name);
		beat.setValue(val);
		dft.addExtendedAttribute(beat);
	}
}

2009-03-05

[][][][] BuriをS2JDBC対応にしてみる その1

BuriはS2DaoもしくはDBFluteを前提としているのですが、S2JDBCも対応できんじゃね?というid:imai78せんせからアドバイス受けたのでいろいろ調べてみた。とりあえず、BuriDataFieldProcRuleインターフェイスの実装をS2JDBC用に作ればよいのかな。

S2DaoToDataAccessRuleクラスをS2JDBCのサービスクラス用に多少書き換えただけの、S2JDBCToDataAccessRuleを作った。

package org.escafe.buri.compiler.util.impl.rules;

import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;

import org.escafe.buri.common.util.BuriConfiguration;
import org.escafe.buri.common.util.ClassDefUtil;
import org.escafe.buri.common.util.ClassDefUtilImpl;
import org.escafe.buri.event.util.caller.DataAccessRuleEventCaller;
import org.escafe.buri.oouo.internal.structure.BuriDataFieldType;
import org.seasar.extension.jdbc.EntityMeta;
import org.seasar.extension.jdbc.PropertyMeta;
import org.seasar.extension.jdbc.manager.JdbcManagerImplementor;
import org.seasar.framework.beans.BeanDesc;
import org.seasar.framework.beans.factory.BeanDescFactory;
import org.seasar.framework.container.S2Container;
import org.seasar.framework.log.Logger;
import org.seasar.framework.util.ClassUtil;
import org.seasar.framework.util.StringUtil;

public class S2JDBCToDataAccessRule extends AbstractBuriDataFieldProcRule {
	private static Logger logger = Logger
			.getLogger(S2JDBCToDataAccessRule.class);

	protected String serviceKeyName = "service";
	public final String SERVICEKEY = "service";

	private BuriConfiguration configuration;
	private S2Container container;
	private ClassDefUtil classDefUtil;
	private DataAccessRuleEventCaller dataAccessRuleEventCaller;

	private JdbcManagerImplementor jdbcManagerImplementor;

	@Override
	public boolean getRequiredRule(BuriDataFieldType src) {
		if (hasName(src, "preprocess")) {
			return false;
		}
		return true;
	}

	public boolean isRequiredNegotiate(BuriDataFieldType src) {
		if (src.getKeys().size() == 0) {
			return true;
		}
		if (!hasName(src, "select")) {
			return true;
		}
		if (!hasName(src, "insert")) {
			return true;
		}
		if (!hasName(src, "update")) {
			return true;
		}
		if (!hasName(src, "delete")) {
			return true;
		}
		if (!hasName(src, "tableName")) {
			return true;
		}
		return false;
	}

	@Override
	public boolean fstCheckProcess(BuriDataFieldType src) {
		if (!isRequiredNegotiate(src)) {
			return false;
		}
		if (src.getCache().containsKey(serviceKeyName)) {

		} else if (hasName(src, SERVICEKEY)) {
			src.getCache().put(serviceKeyName, getNameVal(src, SERVICEKEY));
		}
		dataAccessRuleEventCaller.determinedRule(this, src);
		return true;
	}

	@Override
	public boolean process(BuriDataFieldType src) {
		// if( ! src.getCache().containsKey(serviceKeyName) ) {
		// return false;
		// }
		if (src.getCache().containsKey(serviceKeyName + "_end")) {
			return false;
		}
		negotiateService(src);

		dataAccessRuleEventCaller.endNegotiateDao(this, src);

		src.getCache().put(serviceKeyName + "_end", Boolean.TRUE);
		return false;
	}

	protected void negotiateService(BuriDataFieldType src) {
		String dtoClassName = src.getId();
		String serviceName = getServiceName(src, dtoClassName);
		if (serviceName != null) {
			src.getCache().put(serviceKeyName, serviceName);
			Class daoClass = container.getRoot().getComponentDef(serviceName)
					.getComponentClass();
			pkeySetup(src);

			if (src.getKeys().size() == 1) {
				String keyName = src.getKeys().keySet().toArray()[0].toString();
				BeanDesc beanDesc = BeanDescFactory.getBeanDesc(ClassUtil
						.forName(dtoClassName));
				Class tgtClass = beanDesc.getPropertyDesc(keyName)
						.getPropertyType();
				src.getCache().put(serviceKeyName + "_KeyType", tgtClass);
				src.getCache().put(serviceKeyName + "_KeyName", keyName);
				findAndSetupAllMethod(src, beanDesc, daoClass);
			}
		}

	}

	protected void findAndSetupAllMethod(BuriDataFieldType src,
			BeanDesc beanDesc, Class serviceClass) {
		Method methods[] = serviceClass.getMethods();
		for (Method method : methods) {
			String methodName = method.getName();
			selectSetup(src, method, methodName, beanDesc);
			updateSetup(src, method, methodName, beanDesc);
			deleteSetup(src, method, methodName, beanDesc);
			selectManySetup(src, method, methodName, beanDesc);
			insertSetup(src, method, methodName, beanDesc);
			tableNameSetup(src, method, methodName, beanDesc);
		}
	}

	protected void tableNameSetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getTableName())) {
			return;
		}
		Class tgt = ClassUtil.forName(src.getId());

		EntityMeta entityMeta = jdbcManagerImplementor.getEntityMetaFactory()
				.getEntityMeta(tgt);
		String tableName = entityMeta.getTableMeta().getName();
		if (!StringUtil.isEmpty(tableName)) {
			src.setTableName(tableName);
		}
	}

	protected void selectManySetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getSelectMany())) {
			return;
		}

		if (isSelectManyMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setSelectMany(serviceName + "." + methodName + "(#data)");
		}
	}

	protected boolean isSelectManyMethod(BuriDataFieldType src, Method method,
			String methodName) {
		if (methodName.startsWith("get") || methodName.startsWith("select")) {
			if (method.getParameterTypes().length == 1) {
				if (method.getParameterTypes()[0].isAssignableFrom(List.class)) {
					return true;
				}
			}
		}
		return false;
	}

	protected void deleteSetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getDelete())) {
			return;
		}

		if (isDeleteMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setDelete(serviceName + "." + methodName + "(#data)");
		}
	}

	protected boolean isDeleteMethod(BuriDataFieldType src, Method method,
			String methodName) {
		if (methodName.startsWith("del")) {
			if (method.getParameterTypes().length == 1) {
				String clazzName = classDefUtil.getClassName(method
						.getParameterTypes()[0]);
				if (clazzName.equals(src.getId())) {
					return true;
				}
			}
		}
		return false;
	}

	protected void updateSetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getUpdate())) {
			return;
		}

		if (isUpdateMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setUpdate(serviceName + "." + methodName + "(#data)");
		}
	}

	protected boolean isUpdateMethod(BuriDataFieldType src, Method method,
			String methodName) {
		if (methodName.startsWith("update")) {
			if (method.getParameterTypes().length == 1) {
				String clazzName = classDefUtil.getClassName(method
						.getParameterTypes()[0]);
				if (clazzName.equals(src.getId())) {
					return true;
				}
			}
		}
		return false;
	}

	protected void insertSetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getInsert())) {
			return;
		}

		if (isInsertMethod(src, method, methodName)) {
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setInsert(serviceName + "." + methodName + "(#data)");
		}
	}

	protected boolean isInsertMethod(BuriDataFieldType src, Method method,
			String methodName) {
		if (methodName.startsWith("insert")) {
			if (method.getParameterTypes().length == 1) {
				String clazzName = classDefUtil.getClassName(method
						.getParameterTypes()[0]);
				if (clazzName.equals(src.getId())) {
					return true;
				}
			}
		}
		return false;
	}

	protected void selectSetup(BuriDataFieldType src, Method method,
			String methodName, BeanDesc beanDesc) {
		if (!StringUtil.isEmpty(src.getSelect())) {
			return;
		}

		if (isSelectMethod(src, method, methodName)) {
			String keyName = src.getCache().get(serviceKeyName + "_KeyName")
					.toString();
			String serviceName = src.getCache().get(serviceKeyName).toString();
			src.setSelect(serviceName + "." + methodName + "(#data." + keyName
					+ ")");
		}
	}

	protected boolean isSelectMethod(BuriDataFieldType src, Method method,
			String methodName) {
		if (methodName.startsWith("get") || methodName.startsWith("select")) {
			if (method.getParameterTypes().length == 1) {
				Class tgtClass = (Class) src.getCache().get(
						serviceKeyName + "_KeyType");
				if (method.getParameterTypes()[0].equals(tgtClass)) {
					return true;
				}
			}
		}
		return false;
	}

	protected void pkeySetup(BuriDataFieldType src) {
		if ((src.getKeys().size() > 0) || hasName(src, "pkey")) {
			return;
		}
		Class tgt = ClassUtil.forName(src.getId());

		EntityMeta entityMeta = jdbcManagerImplementor.getEntityMetaFactory()
				.getEntityMeta(tgt);
		for (PropertyMeta pm : entityMeta.getIdPropertyMetaList()) {
			String condition = createPkeyCondition(pm);
			src.getKeys().put(pm.getName(), condition);

		}
	}

	protected String createPkeyCondition(PropertyMeta pm) {
		String condition = null;
		String pkeyName = pm.getName();
		Class propType = pm.getPropertyClass();
		if (propType.equals(Long.TYPE)) {
			condition = pkeyName + " != 0";
		} else if (propType.isAssignableFrom(Number.class)) {
			condition = pkeyName + " != 0";
		} else {
			condition = pkeyName + " != null";
		}
		return condition;
	}

	protected String getServiceName(BuriDataFieldType src, String dtoClassName) {
		String dao = null;
		String shtName = createServiceName(src, dtoClassName);
		String shtName2 = shtName.substring(0, 1).toLowerCase()
				+ shtName.substring(1);
		if (container.getRoot().hasComponentDef(shtName)) {
			dao = shtName;
		} else if (container.getRoot().hasComponentDef(shtName2)) {
			dao = shtName2;
		} else {
			dao = findServiceClass(shtName, dtoClassName);
		}
		if (dao == null) {
			dao = findServiceClassFromNamespace(shtName, dtoClassName);
		}
		return dao;
	}

	protected String findServiceClassFromNamespace(String shtName,
			String dtoClassName) {
		String service = null;
		List serviceNamespace = configuration.getValList("Namespace");
		Iterator ite = serviceNamespace.iterator();
		while (ite.hasNext()) {
			String nameSpace = ite.next().toString();
			String componentName = nameSpace + "." + shtName;
			if (container.getRoot().hasComponentDef(componentName)) {
				return componentName;
			}
		}
		return service;
	}

	protected String findServiceClass(String shtName, String dtoClassName) {
		String service = null;
		List servicePackageName = configuration
				.getValList("ServicePackageName");
		Iterator ite = servicePackageName.iterator();
		while (ite.hasNext()) {
			String pacName = ite.next().toString();
			String fullName = pacName + "." + shtName;
			service = classNameToService(fullName);
			if (service != null) {
				break;
			}
		}
		/*
		 * if(dao == null) { dao = genarateDaoClass(shtName,dtoClassName); }
		 */
		return service;
	}

	/*
	 * protected String genarateDaoClass(String shtName,String dtoClassName) {
	 * Class tgtClass = ClassUtil.forName(dtoClassName); String packageName =
	 * tgtClass.getPackage().getName(); packageName =
	 * packageName.replaceAll("dto","dao") + "." + shtName; packageName =
	 * classNameToDao(packageName); return packageName; }
	 */

	protected String classNameToService(String fullName) {
		String service = null;
		if (ClassDefUtilImpl.isClassName(fullName)) {
			Class serviceClass = ClassUtil.forName(fullName);
			if (container.getRoot().hasComponentDef(serviceClass)) {
				service = container.getRoot().getComponentDef(serviceClass)
						.getComponentName();
			}
		}
		return service;
	}

	protected String createServiceName(BuriDataFieldType src,
			String dtoClassName) {
		if (hasName(src, SERVICEKEY)) {
			return getNameVal(src, SERVICEKEY);
		}
		if (dtoClassName.indexOf("$$") > -1) {
			int enhansPos = dtoClassName.indexOf("$$");
			dtoClassName = dtoClassName.substring(0, enhansPos);
		}
		Class tgtClass = ClassUtil.forName(dtoClassName);
		String shtName = ClassUtil.getShortClassName(tgtClass);
		if (shtName.length() > 3) {
			if (shtName.substring(shtName.length() - 3).equalsIgnoreCase("Dto")) {
				shtName = shtName.substring(0, shtName.length() - 3);
			}
		}
		if (shtName.length() > 6) {
			if (shtName.substring(shtName.length() - 6).equalsIgnoreCase(
					"Entity")) {
				shtName = shtName.substring(0, shtName.length() - 6);
			}
		}
		shtName = shtName + "Service";
		return shtName;
	}

	public S2Container getContainer() {
		return container;
	}

	public void setContainer(S2Container container) {
		this.container = container;
	}

	public BuriConfiguration getConfiguration() {
		return configuration;
	}

	public void setConfiguration(BuriConfiguration configuration) {
		this.configuration = configuration;
	}

	public ClassDefUtil getClassDefUtil() {
		return classDefUtil;
	}

	public void setClassDefUtil(ClassDefUtil classDefUtil) {
		this.classDefUtil = classDefUtil;
	}

	public DataAccessRuleEventCaller getDataAccessRuleEventCaller() {
		return dataAccessRuleEventCaller;
	}

	public void setDataAccessRuleEventCaller(
			DataAccessRuleEventCaller dataAccessRuleEventCaller) {
		this.dataAccessRuleEventCaller = dataAccessRuleEventCaller;
	}

	public JdbcManagerImplementor getJdbcManagerImplementor() {
		return jdbcManagerImplementor;
	}

	public void setJdbcManagerImplementor(
			JdbcManagerImplementor jdbcManagerImplementor) {
		this.jdbcManagerImplementor = jdbcManagerImplementor;
	}
}

そして、buri-share.dicon上に以下のようにすればよいのかなと。思ったりしたりしなかったりというわけで、まだデバッグもしてないのでした。まこたんせんせから、なにか指摘があることを期待して、そろそろ寝る〜w

	<component name="s2JdbcToDataAccessRule" class="org.escafe.buri.compiler.util.impl.rules.S2JDBCToDataAccessRule">
	</component>

	<component class="org.escafe.buri.compiler.util.impl.BuriDataFieldCompilePreprocessorImpl">
		
		<initMethod name="addDataAccessRules">
			<arg>s2JdbcToDataAccessRule</arg>
		</initMethod>
		
	</component>