刚刚参加完公司的i.frame的培训,现在总结一下
1. web.xml 文件中并没有太多的变化,注意一下要配置多个struts-config-***.xml
2. i.frame 比struts多了command-config-***.xml,是以plugin的方式和sturts一起工作的,配置在struts-default.xml文件
<plug-in className="com.ncs.iframe.base.ejb.command.action.CommandPlugIn">
<set-property property="config"
value="/WEB-INF/command/command-config-default.xml"/>
<set-property property="config/custdir"
value="/WEB-INF/command/command-config-custdir.xml"/>
</plug-in>
而command-config-default.xml 的作用就是定义类似BM的东西,不过这里叫commoand罢了
<command-config>
<command-mappings>
<command name="/custdir/searchprocess"
type="com.ncs.iframe.sample.custdir.command.SCDCustomerCommand"
service="searchCustomer">
<param name="name" type="java.lang.String"/>
<result name="result" type="java.util.ArrayList"/>
</command>
</command-mappings>
</command-config>
其中/custdir/searchprocess 表示custdir模块下的searchprocess 这个action,type表示action指向的command, service为要执行的方法,定义在command里面.
可是, command又怎么调用DAO呢???
别着急, 轮到pfw出场了,汗!
2. pfw
pfw-config.xml的一般定义如下:
<pfw-config>
<database id="iconnect">
<!-- use either one-->
<!-- for BEA -->
<!-- <data-source jndi="iconnectDS" /> -->
<!-- for Tomcat -->
<data-source jndi="java:comp/env/jdbc/iconnectDS" />
<mapping href="/WEB-INF/pfw/pfw-mapping-custdir.xml" />
<mapping href="/WEB-INF/pfw/pfw-mapping-iextend.xml" />
<mapping href="/WEB-INF/pfw/pfw-itrust-aa-sql.xml" />
</database>
</pfw-config>
定义了一个jndi,这个需要在服务器配置. 其他的就是映射到了几个子模块的pfw配置,提供一个看看(很恐怖, 太长了):
作用: 提供DAO到数据库的映射. 包含SQL语句
<pfw-mapping>
<map-class id="com.ncs.iframe.sample.custdir.to.SCDCustomerTO">
<db-table name="TBL_SAMPLE_CUSTOMER"/>
<field name="customerID" type="java.lang.String">
<sql name="CUSTOMER_ID" type="CHAR"/>
</field>
<field name="name" type="java.lang.String">
<sql name="NAME" type="CHAR"/>
</field>
<field name="telMain" type="java.lang.String">
<sql name="TEL_MAIN" type="CHAR"/>
</field>
<field name="industry.codeId" type="java.lang.String">
<sql name="INDUSTRY_CD" type="CHAR"/>
</field>
<field name="remarks" type="java.lang.String">
<sql name="REMARKS" type="CHAR"/>
</field>
<field name="version" type="java.lang.Integer">
<sql name="VERSION" type="INTEGER"/>
</field>
<field name="updatedDt" type="java.sql.Timestamp">
<sql name="UPDATED_DT" type="TIMESTAMP"/>
</field>
<primary-key name="CUSTOMER_ID"/>
<version name="UPDATED_DT"/>
<cache-group name="TBL_SAMPLE_CUSTOMER"/>
</map-class>
<!-- Start of param-map -->
<param-map id="/custdir/getSearchCustomerCountParams">
<property name="name" sqlType="CHAR"/>
</param-map>
<param-map id="/custdir/getSearchCustomerParams">
<property name="name" sqlType="CHAR"/>
<property name="sortOrder" sqlType="CHAR"/>
<property name="orderType" sqlType="CHAR"/>
</param-map>
<!-- Start of result-map -->
<result-map id="/custdir/getSearchCustomerResults"
mapClassId="com.ncs.iframe.sample.custdir.to.SCDCustomerTO">
</result-map>
<!-- Start of map-sql -->
<map-sql id="/custdir/searchCustomer" type="query"
param-map="/custdir/getSearchCustomerParams"
result-map="/custdir/getSearchCustomerResults"> <![CDATA[
select CUSTOMER_ID, NAME, TEL_MAIN, VERSION, UPDATED_DT
from TBL_SAMPLE_CUSTOMER
<dynamic prepend="where">
<isNotEmpty property="name">
NAME like '%#name#%'
</isNotEmpty>
</dynamic>
<dynamic prepend="order by">
<isNotEmpty property="sortOrder">
#sortOrder# #orderType#
</isNotEmpty>
</dynamic>
]]>
<cache-group name="TBL_SAMPLE_CUSTOMER"/>
</map-sql>
<map-sql id="/custdir/getMatchingCustomerCount" type="query"
param-map="/custdir/getSearchCustomerCountParams"
result-class="java.lang.Integer"> <![CDATA[
select count(NAME)
from TBL_SAMPLE_CUSTOMER
<dynamic prepend="where">
<isNotEmpty property="name">
NAME like '%#name#%'
</isNotEmpty>
</dynamic>
]]> <cache-group name="TBL_SAMPLE_CUSTOMER"/> </map-sql>
<map-sql id="/custdir/getExactMatchingCustomerCount" type="query"
param-map="/custdir/getSearchCustomerCountParams"
result-class="java.lang.Integer"> <![CDATA[
select count(NAME)
from TBL_SAMPLE_CUSTOMER
where NAME = '#name#'
]]> <cache-group name="TBL_SAMPLE_CUSTOMER"/> </map-sql>
<map-sql id="/custdir/getAllCustomerList" type="query"
result-map="/custdir/getSearchCustomerResults"> <![CDATA[
select CUSTOMER_ID, NAME, TEL_MAIN, VERSION
from TBL_SAMPLE_CUSTOMER
order by NAME
]]> </map-sql>
<!-- Start of testing pfw -->
<param-map id="/test/getCustomerParams">
<property name="custId" sqlType="CHAR"/>
</param-map>
<result-map id="/test/getCustomerResults"
mapClassId="com.ncs.iframe.sample.custdir.to.SCDCustomerTO">
</result-map>
<map-sql id="/test/getCustomer" type="query"
param-map="/test/getCustomerParams" result-map="/test/getCustomerResults"> <![CDATA[
select CUSTOMER_ID, NAME, TEL_MAIN, INDUSTRY_CD, REMARKS, VERSION, UPDATED_DT, TMP_DATE, TMP_INT, TMP_DBL
from TBL_SAMPLE_CUSTOMER
<dynamic prepend="where">
<isNotEmpty property="name">
CUSTOMER_ID = '%#custId#%'
</isNotEmpty>
</dynamic>
]]>
<cache-group name="TBL_SAMPLE_CUSTOMER"/>
</map-sql>
<!--- Declarative SQL to showcase Stored-procedure -->
<param-map id="/test/proce_getCustomerParams">
<property name="In_version" sqlType="INTEGER" storedProcType="IN" />
<property name="customerID" sqlType="CHAR" storedProcType="INOUT"/>
<property name="name" sqlType="CHAR" storedProcType="OUT"/>
<property name="telMain" sqlType="CHAR" storedProcType="OUT"/>
<property name="industry.codeId" sqlType="CHAR" storedProcType="OUT"/>
<property name="remarks" sqlType="CHAR" storedProcType="OUT"/>
<property name="version" sqlType="INTEGER" storedProcType="OUT"/>
</param-map>
<result-map id="/test/proce_getCustomerResults"
mapClassId="com.ncs.iframe.sample.custdir.to.SCDCustomerTO">
</result-map>
<!-- ALL output (out, INOUT) must be delaredin the result-map
with the same result-map -->
<map-sql id="/test/proce_getCustomer" type="stored_procedure"
param-map="/test/proce_getCustomerParams"
result-map="/test/proce_getCustomerResults"> <![CDATA[
{ call
PROCE_GET_CUSTDIR(##In_version##,##customerID##,##name##,##telMain##, ##industry.codeId##, ##remarks##, ##version##)
}
]]> </map-sql>
<!--
begin
PROCE_GET_CUSTDIR(##In_version##,##customerID##,##name##,##telMain##, ##industry.codeId##, ##remarks##, ##version##);
end;
-->
<param-map id="/test/getSearchCustomerParams">
<property name="name" sqlType="CHAR" storedProcType="IN" />
<property name="sortOrder" sqlType="CHAR" storedProcType="IN" />
<property name="resultSet" sqlType="OTHER" storedProcType="OUT"
storedProcTypeClass="com.ncs.iframe.sample.OracleStoredProcTypeClass"/>
</param-map>
<!-- Start of result-map -->
<result-map id="/test/getSearchCustomerResults"
mapClassId="com.ncs.iframe.sample.custdir.to.SCDCustomerTO">
</result-map>
<!-- Start of map-sql -->
<map-sql id="/test/searchCustomer" type="stored_procedure"
param-map="/test/getSearchCustomerParams"
result-map="/test/getSearchCustomerResults"> <![CDATA[
{ call
PROCE_SEARCH_CUSTDIR(##name##,##sortOrder##,##resultSet##)
}
]]>
</map-sql>
</pfw-mapping>
汗啊, 以后就要手这些了, 想起来就害怕.
posted on 2006-05-09 23:28
Oliver Zhang 阅读(710)
评论(2) 编辑 收藏