<?xml version="1.0" encoding="UTF-8"?> <document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> <properties> <title>Doma JPetStore</title> </properties> <body> <section name="目次"> <ul> <li><a href="#概è¦">概è¦</a></li> <li><a href="#セットアップ">セットアップ</a> <ul> <li><a href="#JDKã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«">JDKã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«</a></li> <li><a href="#Eclipseã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«">Eclipseã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«</a></li> <li><a href="#Tomcatã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«">Tomcatã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«</a></li> <li><a href="#SysdeoSQLI_Tomcat_Launcherã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«">Sysdeo/SQLI Tomcat Launcherã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«</a></li> <li><a href="#Doma_Toolsã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«">Doma Toolsã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«</a></li> <li><a href="#プãƒã‚¸ã‚§ã‚¯ãƒˆã®ã‚¤ãƒ³ãƒãƒ¼ãƒˆ">プãƒã‚¸ã‚§ã‚¯ãƒˆã®ã‚¤ãƒ³ãƒãƒ¼ãƒˆ</a></li> </ul> </li> <li><a href="#アプリケーションã®èµ·å‹•">アプリケーションã®èµ·å‹•</a> <ul> <li><a href="#制é™äº‹é …">制é™äº‹é …</a></li> </ul> </li> <li><a href="#Seasar2ã¨ã®é€£æº">Seasar2ã¨ã®é€£æº</a> <ul> <li><a href="#Seasar2ã§ç®¡ç†ã•ã‚ŒãŸãƒ‡ãƒ¼ã‚¿ã‚½ãƒ¼ã‚¹ã‚’利用ã™ã‚‹">Seasar2ã§ç®¡ç†ã•ã‚ŒãŸãƒ‡ãƒ¼ã‚¿ã‚½ãƒ¼ã‚¹ã‚’利用ã™ã‚‹</a></li> <li><a href="#Seasar2ã§ç®¡ç†ã•ã‚ŒãŸãƒˆãƒ©ãƒ³ã‚¶ã‚¯ã‚·ãƒ§ãƒ³ãƒžãƒã‚¸ãƒ£ãƒ¼ã‚’利用ã™ã‚‹">Seasar2ã§ç®¡ç†ã•ã‚ŒãŸãƒˆãƒ©ãƒ³ã‚¶ã‚¯ã‚·ãƒ§ãƒ³ãƒžãƒã‚¸ãƒ£ãƒ¼ã‚’利用ã™ã‚‹</a></li> <li><a href="#ãƒã‚°ç®¡ç†ã‚’çµ±åˆã™ã‚‹">ãƒã‚°ç®¡ç†ã‚’çµ±åˆã™ã‚‹</a></li> <li><a href="#HOT_deploy環境下ã§SQLファイルã®å¤‰æ›´ã‚’å³åº§ã«èªè˜ã•ã›ã‚‹">HOT deploy環境下ã§SQLファイルã®å¤‰æ›´ã‚’å³åº§ã«èªè˜ã•ã›ã‚‹</a></li> <li><a href="#Domaã®Daoã‚’SMART_deployã™ã‚‹">Domaã®Daoã‚’SMART deployã™ã‚‹</a></li> </ul> </li> <li><a href="#JPetStoreを他プãƒã‚¸ã‚§ã‚¯ãƒˆã®é››å½¢ã¨ã—ã¦ä½¿ç”¨ã™ã‚‹éš›ã®æ³¨æ„点">JPetStoreを他プãƒã‚¸ã‚§ã‚¯ãƒˆã®é››å½¢ã¨ã—ã¦ä½¿ç”¨ã™ã‚‹éš›ã®æ³¨æ„点</a> <ul> <li><a href="#convention.dicon">convention.dicon</a></li> <li><a href="#jdbc.dicon">jdbc.dicon</a></li> <li><a href="#struts-config.xml">struts-config.xml</a></li> </ul> </li> </ul> </section> <section name="概è¦"> <p> Doma JPetStoreã¯ã€<a href="http://sastruts.seasar.org/">SAStruts</a>ã¨ã®é€£æºæ–¹æ³•ã‚’示ã™ãƒ‡ãƒ¢ç”¨Webアプリケーションã§ã™ã€‚ ä»–ã®ãƒ—ãƒã‚¸ã‚§ã‚¯ãƒˆã®é››å½¢ã¨ã—ã¦ä½¿ç”¨ã•ã‚Œã‚‹ã“ã¨ã‚‚想定ã—ã¦ã„ã¾ã™ã€‚ </p> <p> ã“ã®ã‚¢ãƒ—リケーションã¯ã€<a href="http://ibatis.apache.org/java.cgi">iBATIS</a>ãŒæä¾›ã™ã‚‹ JPetStore 5.0 Example Application をベースã«ä½œæˆã•ã‚Œã¦ã„ã¾ã™ã€‚ </p> </section> <section name="セットアップ"> <subsection name="JDKã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«"> <p> ãƒãƒ¼ã‚¸ãƒ§ãƒ³6以上ã®JDKをインストールã—ã¾ã™ã€‚ JREã§ã¯ãªãJDKãŒå¿…è¦ã§ã‚ã‚‹ã“ã¨ã«æ³¨æ„ã—ã¦ãã ã•ã„。 JDK 6 ã¯ä»¥ä¸‹ã®URLã®ã‚µã‚¤ãƒˆã‹ã‚‰ãƒ€ã‚¦ãƒ³ãƒãƒ¼ãƒ‰ã§ãã¾ã™ã€‚ </p> <p> <a href="http://java.sun.com/javase/ja/6/download.html">http://java.sun.com/javase/ja/6/download.html</a> </p> </subsection> <subsection name="Eclipseã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«"> <p> ãƒãƒ¼ã‚¸ãƒ§ãƒ³3.5以上ã®Eclipseをインストールã—ã¾ã™ã€‚ <a href="http://jcp.org/en/jsr/detail?id=269">Pluggable Annotation Processing API</a> をサãƒãƒ¼ãƒˆã—ã¦ã„ã‚Œã°ã€Eclipse以外ã®IDEã§ã‚ã£ã¦ã‚‚ã‹ã¾ã„ã¾ã›ã‚“ãŒã€ ã“ã®ãƒ‰ã‚ュメントã§ã¯Eclipseを使ã†ã“ã¨ã‚’å‰æã«èª¬æ˜Žã‚’進ã‚ã¾ã™ã€‚ Eclipseã¯ä»¥ä¸‹ã®URLã®ã‚µã‚¤ãƒˆã‹ã‚‰ãƒ€ã‚¦ãƒ³ãƒãƒ¼ãƒ‰ã§ãã¾ã™ã€‚ </p> <p> <a href="http://www.eclipse.org/downloads/">http://www.eclipse.org/downloads/</a> </p> <p> Eclipseã¯ã€ãƒãƒ¼ã‚¸ãƒ§ãƒ³6以上ã®JDKã«å«ã¾ã‚Œã‚‹JREã§èµ·å‹•ã•ã‚Œã‚‹ã‚ˆã†ã«ã—ã¦ãã ã•ã„。 明示的ã«JREを指定ã™ã‚‹ã«ã¯ã€-vm オプションを使用ã—ã¾ã™ã€‚ </p> <pre>-vm %JAVA_HOME%\bin\javaw.exe</pre> </subsection> <subsection name="Tomcatã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«"> <p> Tomcatã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³6.xをインストールã—ã¾ã™ã€‚ Tomcatã¯ä»¥ä¸‹ã®URLã®ã‚µã‚¤ãƒˆã‹ã‚‰ãƒ€ã‚¦ãƒ³ãƒãƒ¼ãƒ‰ã§ãã¾ã™ã€‚ </p> <p> <a href="http://tomcat.apache.org/download-60.cgi">http://tomcat.apache.org/download-60.cgi</a> </p> </subsection> <subsection name="Sysdeo/SQLI Tomcat Launcherã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«"> <p> アプリケーションをEclipseã‹ã‚‰å‹•ä½œã•ã›ã‚‹ã«ã¯ã€Eclipseプラグインã®Sysdeo/SQLI Tomcat Launcher をインストールsã¾ã™ã€‚ Sysdeo/SQLI Tomcat Launcher ã¯ä»¥ä¸‹ã®æ›´æ–°ã‚µã‚¤ãƒˆã‹ã‚‰ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã§ãã¾ã™ã€‚ </p> <p> <a href="http://eclipse.seasar.org/updates/3.2/">http://eclipse.seasar.org/updates/3.2/</a> </p> <p> Sysdeo/SQLI Tomcat Launcher をインストールã—ãŸã‚‰ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®ã€ŒWindow〠- 「Preference〠ー「Tomcat〠よりTomcatã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã¨ãƒ›ãƒ¼ãƒ を指定ã—ã¦ãã ã•ã„。 </p> </subsection> <subsection name="Doma Toolsã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«"> <p> <a href="extension/doma_tools.html">Doma Tools</a>をインストールã—ã¾ã™ã€‚ </p> <p> Doma Toolsã¯ã€ä»¥ä¸‹ã®æ›´æ–°ã‚µã‚¤ãƒˆã‹ã‚‰ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã§ãã¾ã™ã€‚ </p> <ul> <li><a href="http://eclipse.seasar.org/updates/3.5/">http://eclipse.seasar.org/updates/3.5/</a></li> </ul> </subsection> <subsection name="プãƒã‚¸ã‚§ã‚¯ãƒˆã®ã‚¤ãƒ³ãƒãƒ¼ãƒˆ"> <p> <a href="../downloads.html">ダウンãƒãƒ¼ãƒ‰</a>ã®ãƒšãƒ¼ã‚¸ã‹ã‚‰doma-jpetstore-x.x.x.zipをダウンãƒãƒ¼ãƒ‰ã—〠Eclipseã¸ã‚¤ãƒ³ãƒãƒ¼ãƒˆã—ã¦ãã ã•ã„。インãƒãƒ¼ãƒˆã®å…·ä½“çš„ãªæ‰‹é †ã¯æ¬¡ã®ã¨ãŠã‚Šã§ã™ã€‚2ã¤ã®æ–¹æ³•ã‚’説明ã—ã¾ã™ã€‚ </p> <h4>通常ã®æ–¹æ³•</h4> <ul> <li>Eclipseã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‹ã‚‰ã€ŒFile〠- 「Importã€ã‚’é¸æŠžã—ã¾ã™ã€‚</li> <li>「Existing Projects to Workspaceã€ã‚’é¸æŠžã—ã€ã€ŒNextã€ãƒœã‚¿ãƒ³ã‚’押ã—ã¾ã™ã€‚</li> <li>「Select archive fileã€ã®ãƒ©ã‚¸ã‚ªãƒœã‚¿ãƒ³ã‚’ãƒã‚§ãƒƒã‚¯ã—ã€ãƒ€ã‚¦ãƒ³ãƒãƒ¼ãƒ‰ã—ãŸdoma-jpetstore-x.x.x.zipã‚’é¸æŠžã—ã¾ã™ã€‚</li> <li>「Projectsã€ã®é …ç›®ã«è¡¨ç¤ºã•ã‚Œã‚‹ã€Œdoma-jpetstoreã€ã®ãƒã‚§ãƒƒã‚¯ãƒœãƒƒã‚¯ã‚¹ã‚’ãƒã‚§ãƒƒã‚¯ã—ã€ã€ŒFinishã€ãƒœã‚¿ãƒ³ã‚’押ã—ã¾ã™ã€‚</li> </ul> <h4>m2eclipseを使ã£ã¦Maven Projectã¨ã—ã¦ã‚¤ãƒ³ãƒãƒ¼ãƒˆã™ã‚‹æ–¹æ³•</h4> <ul> <li>doma-jpetstore-x.x.x.zipを解å‡ã—ã¾ã™ã€‚</li> <li>Eclipseã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‹ã‚‰ã€ŒFile〠- 「Importã€ã‚’é¸æŠžã—ã¾ã™ã€‚</li> <li>「Existing Maven Projectsã€ã‚’é¸æŠžã—ã€ã€ŒNextã€ãƒœã‚¿ãƒ³ã‚’押ã—ã¾ã™ã€‚</li> <li>Root Directoryã®å…¥åŠ›æ¬„ã«doma-jpetstore-x.x.x.zipを解å‡ã—ãŸãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’指定ã—ã¾ã™ã€‚</li> <li>「Projectsã€ã®é …ç›®ã«è¡¨ç¤ºã•ã‚Œã‚‹pom.xmlã®ãƒã‚§ãƒƒã‚¯ãƒœãƒƒã‚¯ã‚¹ã‚’ãƒã‚§ãƒƒã‚¯ã—ã€ã€ŒFinishã€ãƒœã‚¿ãƒ³ã‚’押ã—ã¾ã™ã€‚</li> <li>インãƒãƒ¼ãƒˆãŒå®Œäº†ã—ãŸæ™‚点ã§ã¯ãƒ“ルドエラーãŒç™ºç”Ÿã—ã¾ã™ã€‚</li> <li>エラーを解消ã™ã‚‹ãŸã‚ã«ã€ãƒ—ãƒã‚¸ã‚§ã‚¯ãƒˆã®ãƒ—ãƒãƒ‘ティã‹ã‚‰Javaã®ãƒ“ルドパスã®ãƒ€ã‚¤ã‚¢ãƒã‚°ã‚’é–‹ãã¾ã™ã€‚</li> <li>Javaã®ãƒ“ルドパスã®ãƒ€ã‚¤ã‚¢ãƒã‚°ã§ã¯ã€src/main/resourcesã®ã‚½ãƒ¼ã‚¹ãƒ•ã‚©ãƒ«ãƒ€ã®ã€ŒExclude:**/*ã€ã¨ãªã£ã¦ã„ã‚‹é …ç›®ã‚’é¸æŠžã—ã¦ã€ŒRemoveã€ã‚’押ã—ã¾ã™ï¼ˆã€ŒExclude:(None)ã€ã«å¤‰ã‚ã‚Šã¾ã™ï¼‰ã€‚</li> <li>ã¾ãŸã€åŒã˜Javaã®ãƒ“ルドパスã®ãƒ€ã‚¤ã‚¢ãƒã‚°ã§ã€ŒAdd Folder...ã€ã‚’押ã—ã€ãƒ—ãƒã‚¸ã‚§ã‚¯ãƒˆç›´ä¸‹ã®.apt_generatedをソースフォルダã¨ã—ã¦ç™»éŒ²ã—ã¾ã™ã€‚</li> </ul> <p> 以上ã®æ‰‹é †ã‚’実行ã—終ãˆã‚‹ã¨ãƒ“ルドエラーã¯è§£æ¶ˆã•ã‚Œã¾ã™ã€‚ </p> </subsection> </section> <section name="アプリケーションã®èµ·å‹•"> <p> プãƒã‚¸ã‚§ã‚¯ãƒˆã‚’å³ã‚¯ãƒªãƒƒã‚¯ã—ã€ã‚³ãƒ³ãƒ†ã‚ストメニューã‹ã‚‰ã€ŒTomcatプãƒã‚¸ã‚§ã‚¯ãƒˆã€ - 「コンテã‚スト定義を更新〠を実行ã—ã¾ã™ã€‚ ãã—ã¦ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®ã€ŒTomcat〠- 「Tomcat起動〠を実行ã—ã¾ã™ã€‚ </p> <p> Tomcatã®èµ·å‹•ãŒå®Œäº†ã—ãŸã“ã¨ã‚’確èªã—ã€<a href="http://localhost:8080/doma-jpetstore/">http://localhost:8080/doma-jpetstore/</a> ã«ã‚¢ã‚¯ã‚»ã‚¹ã—ã¦ãã ã•ã„。 </p> <subsection name="制é™äº‹é …"> <p> Internet Explorerã§è¡¨ç¤ºã™ã‚‹ã¨ç”»é¢ãƒ¬ã‚¤ã‚¢ã‚¦ãƒˆãŒå´©ã‚Œã¾ã™ã€‚ オリジナルã®JPetStore 5.0 Example Applicationã®CSSãŒInternet Explorerã«å¯¾å¿œã§ãã¦ã„ãªã„よã†ã§ã™ã€‚ Internet Explorerã§ã‚‚レイアウトãŒå´©ã‚Œãªã„よã†ã«ç›´ã—ã¦ãれる方ãŒã„ãŸã‚‰æ“è¿Žã„ãŸã—ã¾ã™ã€‚ </p> </subsection> </section> <section name="Seasar2ã¨ã®é€£æº"> <p> Domaã¨Seasar2を連æºã•ã›ã‚‹ãŸã‚ã®Tipsを説明ã—ã¾ã™ã€‚ </p> <subsection name="Seasar2ã§ç®¡ç†ã•ã‚ŒãŸãƒ‡ãƒ¼ã‚¿ã‚½ãƒ¼ã‚¹ã‚’利用ã™ã‚‹"> <p> <a href="reference/config.html">è¨å®šã‚¯ãƒ©ã‚¹</a>ã®getDataSourceメソッドã§ã€ S2Containerã‹ã‚‰ãƒ‡ãƒ¼ã‚¿ã‚½ãƒ¼ã‚¹ã‚’å–り出ã—è¿”ã—ã¾ã™ã€‚ src/main/java/demo/config/AppConfig.javaã‚’å‚ç…§ã—ã¦ãã ã•ã„。 </p> <source><![CDATA[public class AppConfig implements Config { ... @Override public DataSource getDataSource() { return getDataSourceInternal(); } protected DataSource getDataSourceInternal() { S2Container container = SingletonS2ContainerFactory.getContainer(); return (DataSource) container.getComponent(DataSource.class); } ... }]]></source> <p> 別ã®æ–¹æ³•ã¨ã—ã¦ã¯ã€è¨å®šã‚¯ãƒ©ã‚¹ã®ã‚³ãƒ³ãƒãƒ¼ãƒãƒ³ãƒˆã‚’S2Containerã§ç®¡ç†ã—ã¦ãƒ‡ãƒ¼ã‚¿ã‚½ãƒ¼ã‚¹ã‚’DIã—ã€ãã‚Œã‹ã‚‰è¨å®šã‚¯ãƒ©ã‚¹ã®ã‚³ãƒ³ãƒãƒ¼ãƒãƒ³ãƒˆã‚’Daoã«DIã™ã‚‹ã¨ã„ã†æˆ¦ç•¥ã‚‚ã‚ã‚Šã¾ã™ã€‚ ã“ã¡ã‚‰æ–¹æ³•ã‚’使用ã—ãŸã„å ´åˆã¯ã€<a href="reference/config.html#DIコンテナを利用ã™ã‚‹å ´åˆã®è¨å®šä¾‹">DIコンテナを利用ã™ã‚‹å ´åˆã®è¨å®šä¾‹</a>ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 </p> </subsection> <subsection name="Seasar2ã§ç®¡ç†ã•ã‚ŒãŸãƒˆãƒ©ãƒ³ã‚¶ã‚¯ã‚·ãƒ§ãƒ³ãƒžãƒã‚¸ãƒ£ãƒ¼ã‚’利用ã™ã‚‹"> <p> Seasar2ã§ç®¡ç†ã•ã‚ŒãŸãƒ‡ãƒ¼ã‚¿ã‚½ãƒ¼ã‚¹ã‚’利用ã—ã¦ã„ã‚Œã°ã€ã»ã¨ã‚“ã©æ„è˜ã™ã‚‹ã“ã¨ãªãSeasar2ã§ç®¡ç†ã•ã‚ŒãŸãƒˆãƒ©ãƒ³ã‚¶ã‚¯ã‚·ãƒ§ãƒ³ãƒžãƒã‚¸ãƒ£ãƒ¼ã¨é€£æºã§ãã¾ã™ã€‚ Doma JPetStoreアプリケーションã§ã¯ã€ActionãŒãƒˆãƒ©ãƒ³ã‚¶ã‚¯ã‚·ãƒ§ãƒ³å¢ƒç•Œã«ãªã£ã¦ã„ã‚‹ãŸã‚ã€Action呼ã³å‡ºã—以é™ã§ã‚れ㰠Daoã§è¡Œã‚れるデータアクセスã¯Seasar2ã§ç®¡ç†ã•ã‚ŒãŸãƒˆãƒ©ãƒ³ã‚¶ã‚¯ã‚·ãƒ§ãƒ³ãƒžãƒã‚¸ãƒ£ãƒ¼ã®é…下ã§è¡Œã‚ã‚Œã¾ã™ã€‚ </p> <p> 通常ã€DomaãŒãƒˆãƒ©ãƒ³ã‚¶ã‚¯ã‚·ãƒ§ãƒ³ãƒžãƒã‚¸ãƒ£ãƒ¼ã‚’æ„è˜ã™ã‚‹å¿…è¦ã¯ãªã„ã®ã§ã™ãŒã€ãƒ†ãƒ¼ãƒ–ルを使ã£ãŸæŽ¡ç•ªã§è¡Œãƒãƒƒã‚¯ã‚’極力çŸãã™ã‚‹ãŸã‚ã«å±€æ‰€çš„ã«ãƒˆãƒ©ãƒ³ã‚¶ã‚¯ã‚·ãƒ§ãƒ³ãƒžãƒã‚¸ãƒ£ãƒ¼ã¨é€£æºã—ãŸã„ã“ã¨ãŒã‚ã‚Šã¾ã™ã€‚ ãã®ãŸã‚ã«ç”¨æ„ã•ã‚Œã¦ã„ã‚‹ã®ãŒã€<code>org.seasar.doma.jdbc.RequiresNewController</code>ã¨ã„ã†ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ã§ã™ã€‚ Seasar2用ã®å®Ÿè£…例ã¨ã—ã¦ã¯ã€src/main/java/demo/config/S2RequiresNewController.javaã‚’å‚ç…§ã—ã¦ãã ã•ã„。 </p> <source><![CDATA[public class S2RequiresNewController implements RequiresNewController { @SuppressWarnings("unchecked") @Override public <R> R requiresNew(final Callback<R> callback) throws Throwable { S2Container container = SingletonS2ContainerFactory.getContainer(); TransactionManagerAdapter txAdapter = (TransactionManagerAdapter) container .getComponent(TransactionManagerAdapter.class); Object result = txAdapter.requiresNew(new TransactionCallback() { public Object execute(final TransactionManagerAdapter adapter) throws Throwable { return callback.execute(); } }); return (R) result; } }]]></source> <p> <a href="reference/config.html">è¨å®šã‚¯ãƒ©ã‚¹</a>(src/main/java/demo/config/AppConfig.java)ã®getRequiresNewControllerメソッドã§ã¯ã€ä¸Šè¨˜ã®S2RequiresNewControllerã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã‚’è¿”ã™ã‚ˆã†ã«ã—ã¾ã™ã€‚ </p> </subsection> <subsection name="ãƒã‚°ç®¡ç†ã‚’çµ±åˆã™ã‚‹"> <p> Seasar2ã§ã¯ã€ãƒã‚°ç®¡ç†ã«Commons Loggingを使用ã—ã¦ã„ã¾ã™ã€‚ Domaã¯ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã§ã¯JDKã®Logging APIを使用ã—ã¦ã„ã¾ã™ãŒã€Seasar2ã«åˆã‚ã›ã¦Commons Loggingã«å‡ºåŠ›ã—ãŸã»ã†ãŒç®¡ç†ã—ã‚„ã™ã„ã§ã—ょã†ã€‚ </p> <p> Domaã®ãƒã‚°å‡ºåŠ›ã®å®Ÿè£…を切り替ãˆã‚‹ã«ã¯ã€<code>org.seasar.doma.jdbc.JdbcLogger</code>ã¨ã„ã†ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ã®å®Ÿè£…を用æ„ã—ã¾ã™ã€‚ 実装例ã¨ã—ã¦ã¯ã€src/main/java/demo/config/CommonsJdbcLogger.javaã‚’å‚ç…§ã—ã¦ãã ã•ã„。 </p> <source><![CDATA[public class CommonsJdbcLogger implements JdbcLogger { ... @Override public void logDaoMethodEntering(String callerClassName, String callerMethodName, Object... parameters) { Log log = LogFactory.getLog(callerClassName); log.info("START " + callerClassName + "#" + callerMethodName); } @Override public void logDaoMethodExiting(String callerClassName, String callerMethodName, Object result) { Log log = LogFactory.getLog(callerClassName); log.info("END " + callerClassName + "#" + callerMethodName); } ... @Override public void logSql(String callerClassName, String callerMethodName, Sql<?> sql) { Log log = LogFactory.getLog(callerClassName); String message = String.format("SQL log. sqlFilePath=[%s],%n%s", sql .getSqlFilePath(), sql.getFormattedSql()); log.info(message); } }]]></source> <p> <a href="reference/config.html">è¨å®šã‚¯ãƒ©ã‚¹</a>(src/main/java/demo/config/AppConfig.java)ã®getJdbcLoggerメソッドã§ã¯ã€ä¸Šè¨˜ã®CommonsJdbcLoggerã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã‚’è¿”ã™ã‚ˆã†ã«ã—ã¾ã™ã€‚ </p> </subsection> <subsection name="HOT deploy環境下ã§SQLファイルã®å¤‰æ›´ã‚’å³åº§ã«èªè˜ã•ã›ã‚‹"> <p> Seasar2ãŒæä¾›ã™ã‚‹HotdeployUtilã¨ã„ã†ãƒ¦ãƒ¼ãƒ†ã‚£ãƒªãƒ†ã‚£ã‚¯ãƒ©ã‚¹ã‚’使用ã—〠HOT deployã®å ´åˆã«ã¯SQLファイルをã‚ャッシュã—ãªã„よã†ã«ã—ã¾ã™ã€‚ 実装例ã¨ã—ã¦ã¯src/main/java/demo/config/SqlFileRepositoryProxy.javaã‚’å‚ç…§ã—ã¦ãã ã•ã„。 </p> <source><![CDATA[public class SqlFileRepositoryProxy extends AbstractSqlFileRepository { private final SqlFileRepository greedyCacheSqlFileRepository = new GreedyCacheSqlFileRepository(); private final SqlFileRepository noCacheSqlFileRepository = new NoCacheSqlFileRepository(); @Override protected SqlFile getSqlFileWithCacheControl(String path, Dialect dialect) { if (HotdeployUtil.isHotdeploy()) { return noCacheSqlFileRepository.getSqlFile(path, dialect); } return greedyCacheSqlFileRepository.getSqlFile(path, dialect); } }]]></source> <p> <a href="reference/config.html">è¨å®šã‚¯ãƒ©ã‚¹</a>(src/main/java/demo/config/AppConfig.java)ã®getSqlFileRepositoryメソッドã§ã¯ã€ä¸Šè¨˜ã®SqlFileRepositoryProxyã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã‚’è¿”ã™ã‚ˆã†ã«ã—ã¾ã™ã€‚ </p> </subsection> <subsection name="Domaã®Daoã‚’SMART deployã™ã‚‹"> <p> Domaã®aptãŒç”Ÿæˆã™ã‚‹ã‚¯ãƒ©ã‚¹ã¯ã€ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã§ã¯ã€Seasar2ã®SMART deployã®å‘½åè¦ç´„ã«å³ã—ã¦ã„ã¾ã›ã‚“。 SMART deployã«å¯¾å¿œã•ã›ã‚‹ã«ã¯ã€aptã§ç”Ÿæˆã•ã‚Œã‚‹Dao実装クラスã®åå‰ã‚’調整ã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ </p> <p> ãŸã¨ãˆã°ã€DaoインタフェースãŒ<code>demo.smart.dao.ProductDao</code>ã¨ã„ã†åå‰ã®å ´åˆã€ 生æˆã•ã‚Œã‚‹Dao実装クラスãŒ<code>demo.smart.dao.impl.ProductDaoImpl</code>ã¨ãªã‚‹ã‚ˆã†ã«ã—ã¾ã™ï¼ˆå‰æã¨ã—ã¦demo.smartãŒãƒ«ãƒ¼ãƒˆãƒ‘ッケージã§ãªã‘ã‚Œã°ã„ã‘ã¾ã›ã‚“)。 </p> <p> ã“ã®ã‚ˆã†ãªåå‰ã®èª¿æ•´ã¯<a href="reference/apt.html">注釈処ç†</a>ã®ã‚ªãƒ—ション指定ã§è¡Œã„ã¾ã™ã€‚ 具体的ã«ã¯ã€ã€Œdao.subpackageã€ã«ã¯ã€Œimplã€ã‚’ã€ã€Œdao.suffixã€ã«ã¯ã€ŒImplã€ã‚’指定ã—ã¾ã™ã€‚ Eclipseã®å ´åˆã€ãƒ—ãƒã‚¸ã‚§ã‚¯ãƒˆã®ãƒ—ãƒãƒ‘ティã®ã€ŒAnnotation Processingã€ã®é …ç›®ã§æ¬¡ã®ã‚ˆã†ã«æŒ‡å®šã—ã¾ã™ã€‚ </p> <img src="images/eclipse_apt_options.png" width="454" height="152" alt="Eclipseã§ã®ã‚ªãƒ—ション指定" /> </subsection> </section> <section name="JPetStoreを他プãƒã‚¸ã‚§ã‚¯ãƒˆã®é››å½¢ã¨ã—ã¦ä½¿ç”¨ã™ã‚‹éš›ã®æ³¨æ„点"> <p> JPetStoreを他プãƒã‚¸ã‚§ã‚¯ãƒˆã®é››å½¢ã¨ã—ã¦ä½¿ç”¨ã™ã‚‹éš›ã®æ³¨æ„点を述ã¹ã¾ã™ã€‚ </p> <subsection name="convention.dicon"> <p> src/main/resources/convention.diconã«ã¯ã€ãƒ«ãƒ¼ãƒˆãƒ‘ッケージを指定ã—ã¾ã™ã€‚ JPetStoreã§ã¯ã€ã€Œdemo.smartã€ã¨ã€Œdemoã€ã®2ã¤ã‚’指定ã—ã¦ã„ã¾ã™ãŒã€ã“ã®ãƒ‘ッケージåã‚’æ–°ã—ã„プãƒã‚¸ã‚§ã‚¯ãƒˆã®ãƒ‘ッケージ構æˆã«åˆã‚ã›ã¦å¤‰æ›´ã—ã¦ãã ã•ã„。 </p> <source><![CDATA[<components> <component class="org.seasar.framework.convention.impl.NamingConventionImpl"> <initMethod name="addRootPackageName"> <arg>"demo.smart"</arg> </initMethod> <initMethod name="addRootPackageName"> <arg>"demo"</arg> <arg>false</arg> </initMethod> </component> <component class="org.seasar.framework.convention.impl.PersistenceConventionImpl"/> </components>]]></source> </subsection> <subsection name="jdbc.dicon"> <p> src/main/resources/jdbc.diconã«ã¯ã€JDBCã®æŽ¥ç¶šæƒ…å ±ã‚’è¨˜è¿°ã—ã¾ã™ã€‚ JPetStoreã§ã¯ã€H2 Database Engineを使用ã—ã¦ã„ã¾ã™ãŒã€æ–°ã—ã„プãƒã‚¸ã‚§ã‚¯ãƒˆã§ä½¿ç”¨ã™ã‚‹ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã«åˆã‚ã›ã¦å¤‰æ›´ã—ã¦ãã ã•ã„。 </p> <source><![CDATA[<components namespace="jdbc"> <include path="jta.dicon"/> <!-- for H2 --> <component name="xaDataSource" class="org.seasar.extension.dbcp.impl.XADataSourceImpl"> <property name="driverClassName"> "org.h2.Driver" </property> <property name="URL"> "jdbc:h2:file:" + @org.seasar.framework.util.ResourceUtil@getBuildDir("jdbc.dicon").getCanonicalPath() + "/data-h2/demo;DB_CLOSE_ON_EXIT=FALSE" </property> <property name="user">"sa"</property> <property name="password">""</property> </component> ... </components>]]></source> </subsection> <subsection name="struts-config.xml"> <p> JPetStoreã§ã¯ã€ç‹¬è‡ªã®RequestProcessorを使用ã—ã¦ã„ã¾ã™ã€‚ SAStrutsã®RequestProcessorを使用ã™ã‚‹ã«ã¯ã€ src/main/webapp/WEB-INF/struts-config.xml内ã®controllerè¦ç´ ã®processorClass属性ã§<code>demo.action.JPetStoreRequestProcessor</code>ã®ã‹ã‚ã‚Šã«<code>org.seasar.struts.action.S2RequestProcessor</code>を指定ã—ã¦ãã ã•ã„。 </p> <source><![CDATA[<struts-config> ... <controller maxFileSize="1024K" bufferSize="1024" processorClass="demo.action.JPetStoreRequestProcessor" multipartClass="org.seasar.struts.upload.S2MultipartRequestHandler"/> ... </struts-config>]]></source> </subsection> </section> </body> </document>