seasarのFramworkを利用して、拡張共通モジュールを実装してて、
それをJARにして別のプロジェクトで使おうとしてるところ、
setter-injectionがうまくいかなかった。
問題はFileSystemComponentAutoRegisterは
diconファイルが存在するクラスパス(/WEB-INF/classes)をみるが、
jarの中にあるクラスは参照しきれなくてOUT!!
diconファイルの記述を変更し、JarComponentAutoRegister
に変更して問題解決。
修正前
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
"http://www.seasar.org/dtd/components24.dtd">
<components>
<include path="convention.dicon"/>
<include path="s2jdbc.dicon"/>
<component
class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister">
<property name="instanceDef">
@org.seasar.framework.container.deployer.InstanceDefFactory@PROTOTYPE
</property>
<property name="autoNaming">
<component class="org.seasar.framework.container.autoregister.DefaultAutoNaming"/>
</property>
<initMethod name="addClassPattern">
<arg>"hoge.hoge..framework.service"</arg>
<arg>".*Service"</arg>
</initMethod>
</component>
<component
class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister">
<property name="instanceDef">
@org.seasar.framework.container.deployer.InstanceDefFactory@PROTOTYPE
</property>
<property name="autoNaming">
<component class="org.seasar.framework.container.autoregister.DefaultAutoNaming"/>
</property>
<initMethod name="addClassPattern">
<arg>"hoge.hoge..framework.helper"</arg>
<arg>".*Helper"</arg>
</initMethod>
</component>
<component
class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister">
<property name="instanceDef">
@org.seasar.framework.container.deployer.InstanceDefFactory@SESSION
</property>
<property name="autoNaming">
<component class="org.seasar.framework.container.autoregister.DefaultAutoNaming"/>
</property>
<initMethod name="addClassPattern">
<arg>"hoge.hoge..framework.dto"</arg>
<arg>".*Dto"</arg>
</initMethod>
</component>
</components>
修正後
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
"http://www.seasar.org/dtd/components24.dtd">
<components>
<include path="convention.dicon"/>
<include path="s2jdbc.dicon"/>
<component
class="org.seasar.framework.container.autoregister.JarComponentAutoRegister">
<property name="instanceDef">
@org.seasar.framework.container.deployer.InstanceDefFactory@PROTOTYPE
</property>
<property name="autoNaming">
<component class="org.seasar.framework.container.autoregister.DefaultAutoNaming"/>
</property>
<property name="referenceClass">
@hoge.hoge..framework.service.FwAbstractService@class
</property>
<property name="jarFileNames">"hoge-framework.*"</property>
<initMethod name="addClassPattern">
<arg>"hoge.hoge..framework.service"</arg>
<arg>".*Service"</arg>
</initMethod>
</component>
<component
class="org.seasar.framework.container.autoregister.JarComponentAutoRegister">
<property name="instanceDef">
@org.seasar.framework.container.deployer.InstanceDefFactory@PROTOTYPE
</property>
<property name="autoNaming">
<component class="org.seasar.framework.container.autoregister.DefaultAutoNaming"/>
</property>
<property name="referenceClass">
@hoge.hoge..framework.helper.FwConverterHelper@class
</property>
<property name="jarFileNames">"hoge-framework.*"</property>
<initMethod name="addClassPattern">
<arg>"hoge.hoge..framework.helper"</arg>
<arg>".*Helper"</arg>
</initMethod>
</component>
<property name="jarFileNames">"hoge-framework.*"</property>
<initMethod name="addClassPattern">
<arg>"hoge.hoge..framework.dto"</arg>
<arg>".*Dto"</arg>
</initMethod>
</component>
<component
class="org.seasar.framework.container.autoregister.JarComponentAutoRegister">
<property name="instanceDef">
@org.seasar.framework.container.deployer.InstanceDefFactory@SESSION
</property>
<property name="autoNaming">
<component class="org.seasar.framework.container.autoregister.DefaultAutoNaming"/>
</property>
<property name="referenceClass">
@hoge.hoge..framework.dto.LoginUserDto@class
</property>
<property name="jarFileNames">"hoge-framework.*"</property>
<initMethod name="addClassPattern">
<arg>"hoge.hoge..framework.dto"</arg>
<arg>".*Dto"</arg>
</initMethod>
</component>
</components>
댓글 없음:
댓글 쓰기