您的位置:首页 > 运维架构 > 网站架构

Java 架构的一些配置信息

2011-06-13 15:08 260 查看
(1)配置主 struts.xml 文件:

<include file="user/struts.xml"/>


完整 src/struts.xml 文件请参见(附录1)。

(2)配置 src/user/struts.xml

<!-- userJson -->
<package name="userJson" extends="json-default">

<!-- getUser.action 2011-0613 Livon -->
<action name="getUser" class="user.action.getUser">
<result type="json" />
</action>

</package>


完整 src/user/struts.xml 文件请参见(附录2)。

(3)配置 src/app-context.xml

<!-- 用户 -->
<bean id="user.action.getUser"
class="user.action.getUser"
scope="prototype">
<property name="userService">
<ref bean="userServiceImpl"/>
</property>
</bean>

<bean id="userServiceImpl"
class="user.service.UserServiceImpl"
scope="prototype">
<property name="userDao">
<ref bean="userDaoImpl"/>
</property>
</bean>
<bean id="userDaoImpl"
class="user.service.dao.UserDaoImpl"
parent="daoTemplate.flm" scope="prototype">
</bean>


完整 src/app-context.xml 文件请参见(附录3)。

(4)配置 src/user/action/getUser.java

/** 用户 Service 接口. */
private UserService userService = null;
public void setUserService(UserService userService) {
this.userService = userService;
}
public UserService getUserService() {
return userService;
}


完整 src/user/action/getUser.java 文件请参见(附录4)。

(5)以下文件配置略去,请参见项目:NLMRPII 中的相应文件:

src/user/service/dao/UserDao.java

src/user/service/dao/UserDaoImpl.java

src/user/service/UserService.java

src/user/service/UserServiceImpl.java

============================================

( 附录1:src/struts.xml )

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.custom.i18n.resources" value="Constants"></constant>

<include file="userManage/userManage-struts.xml"/>
<include file="loginManage/loginManage-struts.xml"/>
<include file="customerInfo/customerInfoManager-struts.xml"/>
<include file="areaCategory/areaCategory-struts.xml"/>
<include file="area/area-struts.xml"/>
<include file="serviceCategory/serviceCategory-struts.xml"/>
<include file="agreement/struts.xml"/>
<include file="productMaintainFrequency/struts.xml"/>
<include file="filterMaintainFrequency/struts.xml"/>
<include file="feesHistory/struts.xml"/>
<include file="customerService/struts.xml"/>
<include file="customerFilter/struts.xml"/>
<include file="customerAllService/struts.xml"/>
<include file="commonCategory/struts.xml"/>
<include file="comment/struts.xml"/>
<include file="bom/struts.xml"/>
<include file="mps/struts.xml"/>
<include file="item/struts.xml"/>
<include file="tag/struts.xml"/>
<include file="savedSearch/struts.xml"/>
<include file="stockBill/stockBill-struts.xml"/>
<include file="user/struts.xml"/>
</struts>


(附录2:src/user/struts.xml )

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- user -->
<package name="user" extends="struts-default">

<!-- getUser.action 2011-0613 Livon -->

</package>

<!-- userJson -->
<package name="userJson" extends="json-default">

<!-- getUser.action 2011-0613 Livon -->
<action name="getUser" class="user.action.getUser">
<result type="json" />
</action>

</package>

</struts>


( 附录3:src/app-context.xml )

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsp="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsp:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> 
<!-- 用户 -->
<bean id="user.action.getUser"
class="user.action.getUser"
scope="prototype">
<property name="userService">
<ref bean="userServiceImpl"/>
</property>
</bean>

<bean id="userServiceImpl"
class="user.service.UserServiceImpl"
scope="prototype">
<property name="userDao">
<ref bean="userDaoImpl"/>
</property>
</bean>
<bean id="userDaoImpl"
class="user.service.dao.UserDaoImpl"
parent="daoTemplate.flm" scope="prototype">
</bean>

</beans>


( 附录4:src/user/action/getUser.java )

/***********************************************************************
* System          : NEWLIFE_ONLINE_ORDER
* Date            : 2010/4/06
* Description     : 用户管理画面初始化Action
************************************************************************/
package user.action;
import java.util.HashMap;
import java.util.Map;
import user.service.UserService;
import jp.co.ana.fmc.fis.fid.common.json.JSON;
import common.action.AbstractCommonAction;
/**
* 用户管理画面初始化Action.
*/
@SuppressWarnings("serial")
public class getUser extends AbstractCommonAction {

/** 用户 Service 接口. */
private UserService userService = null;

/**
* Action处理执行.
*
* @return Action处理执行结果.
*/
public String doAction() throws Exception {

this.writeLog(this.getClass().getName(), ACTION_START);

Map<String, Object> jsonMap = new HashMap<String, Object>();

getResponse().setCharacterEncoding("UTF-8");
jsonMap.put("actionResult", "true");
jsonMap.put("errCode", "0");
jsonMap.put("errMsg", "");

getResponse().getWriter().write(JSON.serialize(jsonMap));

this.writeLog(this.getClass().getName(), ACTION_END);
return NONE;

}
public void setUserService(UserService userService) {
this.userService = userService;
}
public UserService getUserService() {
return userService;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: