S2学習
- セットアップ
- DIContainer
- AOP
- トランザクションの自動制御
まで行ったところで、
ここでいうトランザクションとはどういう意味なのかが、まだ未判明。
public void setMessage(String message) throws Exception { this.message = message; if (message == null) throw(new Exception("例外発生")); }
Hello hello2 = (Hello) container.getComponent("hello"); hello2.showMessage(); try { hello2.setMessage(null); } catch (Exception e) { System.out.println(e.getMessage()); } hello2.showMessage();
<component name="hello" class="examples.dicon.HelloConstructorInjection"> <arg>"Hello World!"</arg> <aspect>j2ee.requiredTx</aspect> </component>
な感じで試してみた。結果は
DEBUG 2004-08-28 12:39:24,035 [main] トランザクションを開始しました Hello World! DEBUG 2004-08-28 12:39:24,045 [main] トランザクションをコミットしました DEBUG 2004-08-28 12:39:24,045 [main] トランザクションを開始しました DEBUG 2004-08-28 12:39:24,055 [main] トランザクションをロールバックしました 例外発生 DEBUG 2004-08-28 12:39:24,055 [main] トランザクションを開始しました null DEBUG 2004-08-28 12:39:24,085 [main] トランザクションをコミットしました
????