本文承接《Spring+Maven+Dubbo+MyBatis+Linner+Handlebars—Web开发环境搭建》,以下对相关的Maven配置和详细的Spring配置文件进行简单介绍。
整个开发框架大体结构如下:
1) 核心业务逻辑工程用于处理系统自身的核心业务逻辑;
2) 桥梁工程用于关联页面工程和后台处理逻辑;
3) 公共业务逻辑对公共的业务逻辑进行处理;
4) Maven父工程用于对整个开发环境进行配置,包括jar包的定义与管理,系统基本环境的配置(例:数据库连接的管理);
5) 客户端接口工程用于发布服务给桥梁工程或可信任的第三方调用;
6) 客户端接口实现工程用于具体实现服务接口;
7) 任务调度工程用于处理相关任务调度;
8) 总的框架工程用于对前面的后台工程进行统一的管理。
以下我将对各个工程进行逐一介绍:
1.核心业务逻辑mkhl-biz:
mkhl-biz工程的具体结构如下图:
1)biz工程的pom文件:
- <?xml version="1.0"?>
- <project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>mkhl-parent</artifactId>
- <groupId>com.ouc.mkhl.supplier</groupId>
- <version>1.0</version>
- <relativePath>../mkhl-parent/pom.xml</relativePath>
- </parent>
- <artifactId>mkhl-biz</artifactId>
- <name>mkhl-biz</name>
- <url>http://maven.apache.org</url>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
- <dependencies>
- <!-- oop开放平台核心业务(此jar包须具有相关开发权限) -->
- <dependency>
- <groupId>com.ouc</groupId>
- <artifactId>oop-core</artifactId>
- </dependency>
- <dependency>
- <groupId>weblogic</groupId>
- <artifactId>wlfullclient</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo</artifactId>
- </dependency>
- <!--
- <dependency>
- <groupId>redis.clients</groupId>
- <artifactId>jedis</artifactId>
- </dependency>
- -->
- <dependency>
- <groupId>com.ouc.mkhl.supplier</groupId>
- <artifactId>mkhl-service-client</artifactId>
- <exclusions>
- <exclusion>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.ouc.mkhl.supplier</groupId>
- <artifactId>mkhl-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis-spring</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mybatis.generator</groupId>
- <artifactId>mybatis-generator-core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.github.sgroschupf</groupId>
- <artifactId>zkclient</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.jms</groupId>
- <artifactId>jms-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jms</artifactId>
- </dependency>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc14</artifactId>
- </dependency>
- <!-- mysql连接 -->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <!-- <version>5.1.34</version> -->
- </dependency>
- <dependency>
- <groupId>commons-pool</groupId>
- <artifactId>commons-pool</artifactId>
- <!-- <version>1.6</version> -->
- </dependency>
- <dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <!-- <version>1.4</version> -->
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjweaver</artifactId>
- </dependency>
- <dependency>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- </dependency>
- <dependency>
- <groupId>aopalliance</groupId>
- <artifactId>aopalliance</artifactId>
- </dependency>
- <!-- XStream -->
- <dependency>
- <groupId>com.thoughtworks.xstream</groupId>
- <artifactId>xstream</artifactId>
- </dependency>
- <dependency>
- <groupId>xpp3</groupId>
- <artifactId>xpp3_min</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.poi</groupId>
- <artifactId>poi-ooxml</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.quartz-scheduler</groupId>
- <artifactId>quartz</artifactId>
- </dependency>
- <dependency>
- <groupId>org.terracotta.quartz</groupId>
- <artifactId>quartz-terracotta</artifactId>
- </dependency>
- <dependency>
- <groupId>org.freemarker</groupId>
- <artifactId>freemarker</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- </dependency>
- <dependency>
- <groupId>net.sf.ehcache</groupId>
- <artifactId>ehcache</artifactId>
- <type>pom</type>
- </dependency>
- <dependency>
- <groupId>com.haier.openplatform.hfs</groupId>
- <artifactId>hfs-service-client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- <dependency>
- <groupId>com.ouc.openplatform</groupId>
- <artifactId>monitor-service-client</artifactId>
- </dependency>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>druid</artifactId>
- </dependency>
- <dependency>
- <groupId>com.dangdang</groupId>
- <artifactId>config-toolkit-easyzk</artifactId>
- </dependency>
- <dependency>
- <groupId>mx4j</groupId>
- <artifactId>mx4j</artifactId>
- </dependency>
- <dependency>
- <groupId>mx4j</groupId>
- <artifactId>mx4j-tools</artifactId>
- </dependency>
- <dependency>
- <groupId>com.ouc</groupId>
- <artifactId>openapi-auth</artifactId>
- </dependency>
- <dependency>
- <groupId>com.ouc</groupId>
- <artifactId>openapi-service-client</artifactId>
- </dependency>
- </dependencies>
- </project>
2)以安全模块为例,对单一模块的编写进行简单介绍。
单一模块结构如下图:
(1)advice实例:OperationLogAdvice
- package com.ouc.mkhl.supplier.security.advice;
- import java.util.Date;
- import org.aspectj.lang.ProceedingJoinPoint;
- import com.ouc.openplatform.log.advice.DefaultOperationLogAdvice;
- import com.ouc.openplatform.log.config.LogConfiguration;
- import com.ouc.openplatform.log.domain.OperationLog;
- import com.ouc.openplatform.security.LoginContext;
- import com.ouc.openplatform.security.LoginContextHolder;
- import com.ouc.openplatform.util.OOPConstant;
- import com.ouc.mkhl.supplier.security.service.OperationLogService;
- /**
- * @author Tom
- */
- public class OperationLogAdvice extends DefaultOperationLogAdvice {
- private OperationLogService operationLogService;
- @Override
- protected void saveLog(OperationLog operationLog) {
- operationLogService.save(operationLog);
- }
- public void setOperationLogService(OperationLogService operationLogService) {
- this.operationLogService = operationLogService;
- }
- protected OperationLog createOperationLog(ProceedingJoinPoint thisJoinPoint,LogConfiguration logConfiguration){
- LoginContext loginContext = LoginContextHolder.get();
- if(loginContext == null){
- loginContext = new LoginContext();
- loginContext.setUserId(-999L);
- loginContext.setUserName("-SYSTEM-");
- }
- OperationLog operationLog = new OperationLog();
- operationLog.setAppName(HOPConstant.getAppName());
- operationLog.setGmtCreate(new Date());
- operationLog.setGmtModified(new Date());
- operationLog.setUserId(loginContext.getUserId());
- operationLog.setUserName(loginContext.getUserName());
- operationLog.setOperationType(logConfiguration.getType());
- operationLog.setModule(logConfiguration.getModule());
- operationLog.setDescription(executeTemplate(getMessage(logConfiguration.getMessageMap()),thisJoinPoint));
- return operationLog;
- }
- }
- package com.ouc.mkhl.supplier.security.dao;
- import java.util.List;
- import com.ouc.mkhl.supplier.security.model.SupplyUser;
- public interface SupplyUserDAO {
- public int deleteByPrimaryKey(String supplycode);
- public int insert(SupplyUser record);
- public int insertSelective(SupplyUser record);
- public SupplyUser selectByPrimaryKey(String supplycode);
- public int updateByPrimaryKeySelective(SupplyUser record);
- public int updateByPrimaryKey(SupplyUser record);
- public List<SupplyUser> selectAllSupplyUser();
- public SupplyUser selectByVCode(String supplycode);
- }
(3)domain实例:OrderNum
- package com.ouc.mkhl.supplier.security.domain;
- public class OrderNum {
- private String itemName; // 项目名
- private int myOrderNum; // 我的订单
- private int proOrderNum; // 订单生产
- private int tstOrderNum; // 订单检测
- private int subOrderNum; // 订单交付
- private String percentage; // 完成率
- public String getItemName() {
- return itemName;
- }
- public void setItemName(String itemName) {
- this.itemName = itemName == null ? null : itemName.trim();
- }
- public int getMyOrderNum() {
- return myOrderNum;
- }
- public void setMyOrderNum(int myOrderNum) {
- this.myOrderNum = myOrderNum;
- }
- public int getProOrderNum() {
- return proOrderNum;
- }
- public void setProOrderNum(int proOrderNum) {
- this.proOrderNum = proOrderNum;
- }
- public int getTstOrderNum() {
- return tstOrderNum;
- }
- public void setTstOrderNum(int tstOrderNum) {
- this.tstOrderNum = tstOrderNum;
- }
- public int getSubOrderNum() {
- return subOrderNum;
- }
- public void setSubOrderNum(int subOrderNum) {
- this.subOrderNum = subOrderNum;
- }
- public String getPercentage() {
- return percentage;
- }
- public void setPercentage(String percentage) {
- this.percentage = percentage == null ? null : percentage.trim();
- }
- }
- package com.ouc.mkhl.supplier.security.model;
- import java.io.Serializable;
- public class SupplyUser implements Serializable{
- private static final long serialVersionUID = -123120032141L;
- private String supplycode;
- private String supplypass;
- private String supplyname;
- public String getSupplycode() {
- return supplycode;
- }
- public void setSupplycode(String supplycode) {
- this.supplycode = supplycode == null ? null : supplycode.trim();
- }
- public String getSupplypass() {
- return supplypass;
- }
- public void setSupplypass(String supplypass) {
- this.supplypass = supplypass == null ? null : supplypass.trim();
- }
- public String getSupplyname() {
- return supplyname;
- }
- public void setSupplyname(String supplyname) {
- this.supplyname = supplyname == null ? null : supplyname.trim();
- }
- }
- package com.ouc.mkhl.supplier.security.service;
- import java.util.List;
- import com.ouc.mkhl.supplier.security.model.SupplyUser;
- public interface SupplyUserService {
- public int saveSupplyUser(SupplyUser supplyUser);
- public List<SupplyUser> getAllSupplyUser();
- public SupplyUser getSupplyUserByVCode(String supplycode);
- }
- package com.ouc.mkhl.supplier.security.service.impl;
- import java.util.List;
- import org.springframework.stereotype.Service;
- import com.ouc.mkhl.supplier.security.dao.SupplyUserDAO;
- import com.ouc.mkhl.supplier.security.model.SupplyUser;
- import com.ouc.mkhl.supplier.security.service.SupplyUserService;
- @Service
- public class SupplyUserServiceImpl implements SupplyUserService {
- private SupplyUserDAO supplyUserDAO;
- public SupplyUserDAO getSupplyUserDAO() {
- return supplyUserDAO;
- }
- public void setSupplyUserDAO(SupplyUserDAO supplyUserDAO) {
- this.supplyUserDAO = supplyUserDAO;
- }
- @Override
- public int saveSupplyUser(SupplyUser supplyUser) {
- int a = supplyUserDAO.insert(supplyUser);
- return a;
- }
- @Override
- public List<SupplyUser> getAllSupplyUser() {
- System.out.println("进入了biz层impl的getAllSupplyUser");
- List<SupplyUser> supplyUserList = null;
- try {
- supplyUserList = supplyUserDAO.selectAllSupplyUser();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return supplyUserList;
- }
- @Override
- public SupplyUser getSupplyUserByVCode(String supplycode) {
- SupplyUser supplyUser = null;
- try {
- supplyUser = supplyUserDAO.selectByVCode(supplycode);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return supplyUser;
- }
- }
3)MyBatis配置:
(1)sqlMapConfig.xml
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE configuration
- PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-config.dtd">
- <configuration>
- <settings>
- <setting name="cacheEnabled" value="true" />
- <setting name="lazyLoadingEnabled" value="true" />
- <setting name="multipleResultSetsEnabled" value="true" />
- <setting name="useColumnLabel" value="true" />
- <setting name="useGeneratedKeys" value="false" />
- <setting name="autoMappingBehavior" value="PARTIAL" />
- <setting name="defaultExecutorType" value="SIMPLE" /><!-- SIMPLE REUSE BATCH -->
- <!-- <setting name="defaultExecutorType" value="BATCH" /> -->
- <setting name="defaultStatementTimeout" value="25000" />
- <setting name="safeRowBoundsEnabled" value="false" />
- <setting name="mapUnderscoreToCamelCase" value="false" />
- <setting name="localCacheScope" value="SESSION" />
- <!-- <setting name="jdbcTypeForNull" value="OTHER" /> -->
- <setting name="jdbcTypeForNull" value="NULL" />
- <setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString" />
- </settings>
- <typeAliases>
- <!-- =========================================================== -->
- <!-- security模块 -->
- <!-- =========================================================== -->
- <typeAlias alias="supplyUser" type="com.ouc.mkhl.supplier.security.model.SupplyUser"/>
- </typeAliases>
- <typeHandlers>
- <typeHandler handler="com.ouc.openplatform.dao.mybatis.SerializableTypeHandler"/>
- </typeHandlers>
- </configuration>
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
- <mapper namespace="com.ouc.mkhl.supplier.security.dao.SupplyUserDAO" >
- <resultMap id="SupplyUserMap" type="supplyUser" >
- <id column="SupplyCode" property="supplycode" jdbcType="VARCHAR" />
- <result column="SupplyPass" property="supplypass" jdbcType="VARCHAR" />
- <result column="SupplyName" property="supplyname" jdbcType="VARCHAR" />
- </resultMap>
- <sql id="Base_Column_List" >
- SupplyCode, SupplyPass, SupplyName
- </sql>
- <select id="selectAllSupplyUser" resultMap="SupplyUserMap">
- select * from supplyuser
- </select>
- <select id="selectByVCode" resultType="supplyUser" parameterType="java.lang.String" >
- select * from supplyuser
- where SupplyCode = #{supplycode,jdbcType=VARCHAR}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
- delete from supplyuser
- where SupplyCode = #{supplycode,jdbcType=VARCHAR}
- </delete>
- <insert id="insert" parameterType="supplyUser" >
- insert into supplyuser (SupplyCode, SupplyPass, SupplyName
- )
- values (#{supplycode,jdbcType=VARCHAR}, #{supplypass,jdbcType=VARCHAR}, #{supplyname,jdbcType=VARCHAR}
- )
- </insert>
- <insert id="insertSelective" parameterType="supplyUser" >
- insert into supplyuser
- <trim prefix="(" suffix=")" suffixOverrides="," >
- <if test="supplycode != null" >
- SupplyCode,
- </if>
- <if test="supplypass != null" >
- SupplyPass,
- </if>
- <if test="supplyname != null" >
- SupplyName,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides="," >
- <if test="supplycode != null" >
- #{supplycode,jdbcType=VARCHAR},
- </if>
- <if test="supplypass != null" >
- #{supplypass,jdbcType=VARCHAR},
- </if>
- <if test="supplyname != null" >
- #{supplyname,jdbcType=VARCHAR},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="supplyUser" >
- update supplyuser
- <set >
- <if test="supplypass != null" >
- SupplyPass = #{supplypass,jdbcType=VARCHAR},
- </if>
- <if test="supplyname != null" >
- SupplyName = #{supplyname,jdbcType=VARCHAR},
- </if>
- </set>
- where SupplyCode = #{supplycode,jdbcType=VARCHAR}
- </update>
- <update id="updateByPrimaryKey" parameterType="supplyUser" >
- update supplyuser
- set SupplyPass = #{supplypass,jdbcType=VARCHAR},
- SupplyName = #{supplyname,jdbcType=VARCHAR}
- where SupplyCode = #{supplycode,jdbcType=VARCHAR}
- </update>
- </mapper>
4)Spring相关配置:
(1)spring/spring-common.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"
- xmlns:lang="http://www.springframework.org/schema/lang" xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
- http://www.springframework.org/schema/jee
- http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/lang
- http://www.springframework.org/schema/lang/spring-lang-3.1.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util-3.1.xsd">
- <bean class="com.ouc.mkhl.supplier.util.SystemBootstrap" init-method="init">
- <property name="httpAdaptor" ref="httpAdaptor" />
- </bean>
- <bean class="com.ouc.openplatform.util.SpringApplicationContextHolder"/>
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource" />
- <property name="configLocation" value="classpath:/mybatis/sqlMapConfig.xml" />
- <property name="mapperLocations" value="classpath:/mybatis/**/*Mapper.xml" />
- <property name="typeAliasesPackage" value="com.ouc.mkhl.supplier.security.model" />
- </bean>
- <bean id="baseDAO" class="org.mybatis.spring.mapper.MapperFactoryBean" abstract="true" lazy-init="true">
- <property name="sqlSessionFactory" ref="sqlSessionFactory" />
- </bean>
- <!-- email template config -->
- <bean id="templateEngine" class="com.ouc.openplatform.template.FreemarkerTemplateEngine">
- <property name="freeMarkerconfiguration" ref="freeMarkerconfiguration"/>
- </bean>
- <bean id="freeMarkerconfiguration" class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">
- <property name="templateLoaderPath" value="classpath:/email"/>
- <property name="freemarkerSettings">
- <props>
- <prop key="template_update_delay">1800</prop><!-- 模板更新延时 -->
- <prop key="default_encoding">UTF-8</prop>
- <prop key="locale">zh_CN</prop>
- <prop key="number_format">0.######</prop>
- </props>
- </property>
- </bean>
- <bean id="emailBuilder" class="com.ouc.openplatform.hmc.sender.email.DefaultEmailBuilder">
- <property name="templateEngine" ref="templateEngine"/>
- </bean>
- <!-- <bean class="com.ouc.openplatform.jmx.JmxMBeanServiceInit">
- <property name="httpAdapterName" value="httpAdaptor" />
- </bean> -->
- <bean id="profileAdvice" class="com.ouc.openplatform.console.audit.ProfileAdvice"></bean>
- <aop:config>
- <aop:pointcut id="profileAudit" expression="execution(* com.ouc..service.impl.*ServiceImpl.*(..)) or execution(* com.ouc..dao.impl.*DAOImpl.*(..))"/>
- <aop:aspect ref="profileAdvice" order="5">
- <aop:before pointcut-ref="profileAudit" method="beforeExecute"/>
- <aop:after pointcut-ref="profileAudit" method="afterExecute" />
- </aop:aspect>
- </aop:config>
- </beans>
- package com.ouc.mkhl.supplier.util;
- import java.io.IOException;
- import java.io.InputStream;
- import java.util.Properties;
- import mx4j.tools.adaptor.http.HttpAdaptor;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import org.springframework.beans.factory.InitializingBean;
- import org.springframework.core.env.AbstractEnvironment;
- import com.ouc.openplatform.SysException;
- import com.ouc.openplatform.console.audit.AuditInfoCollector;
- import com.ouc.openplatform.session.listener.MaxSessionUtil;
- import com.ouc.openplatform.util.Env;
- import com.ouc.openplatform.util.HOPConstant;
- /**
- * @author Tom
- */
- public class SystemBootstrap implements InitializingBean {
- /**
- * CONFIG_FILE_PATH 系统变量配置文件路径
- */
- private static final String CONFIG_FILE_PATH = "/env.properties";
- private static final Log LOG = LogFactory.getLog(SystemBootstrap.class);
- private HttpAdaptor httpAdaptor;
- public static void init() {
- InputStream inputStream = null;
- Properties properties = new Properties();
- try{
- inputStream = SystemBootstrap.class.getResourceAsStream(CONFIG_FILE_PATH);
- properties.load(inputStream);
- LOG.info("系统配置项:"+properties);
- }catch (Exception e) {
- LOG.error("读取系统配置文件时发生错误:",e);
- throw new SysException(e);
- }finally{
- if(inputStream != null){
- try {
- inputStream.close();
- } catch (IOException e) {
- LOG.error("关闭文件输入流失败:",e);
- }
- }
- }
- Env.init(properties);
- AuditInfoCollector.setAppNM(Env.getProperty(Env.KEY_SERVER_NAME));
- HOPConstant.setAppName(Env.getProperty(Env.KEY_SERVER_NAME));
- //设置一些全局参数
- MaxSessionUtil.setMaxSessionKey(Env.getProperty(Env.KEY_SERVER_NAME)+"_MAX_SESSION_KEYS");
- //使用spring的profile
- System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, Env.getProperty(Env.ENV_TYPE));
- }
- @Override
- public void afterPropertiesSet() throws Exception {
- httpAdaptor.start();
- }
- public void setHttpAdaptor(HttpAdaptor httpAdaptor) {
- this.httpAdaptor = httpAdaptor;
- }
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:lang="http://www.springframework.org/schema/lang" xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/lang
- http://www.springframework.org/schema/lang/spring-lang-3.1.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util-3.1.xsd">
- <bean id="configFactory" class="com.dangdang.config.service.easyzk.ConfigFactory">
- <constructor-arg name="connectStr" value="${service.config.center.address}" />
- <constructor-arg name="rootNode" value="/config-center/common" />
- <constructor-arg name="version" value="1.0" />
- </bean>
- <bean id="zookeeperSources" class="com.dangdang.config.service.easyzk.support.spring.ZookeeperSourceFactoryProxy" factory-method="create">
- <constructor-arg name="appName" value="${server.name}" />
- <constructor-arg name="configFactory" ref="configFactory" />
- <constructor-arg name="nodes" value=""/>
- </bean>
- <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
- <property name="order" value="1" />
- <property name="ignoreUnresolvablePlaceholders" value="true" />
- <property name="location" value="classpath:/application.properties"/>
- </bean>
- <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
- <property name="order" value="2" />
- <property name="ignoreUnresolvablePlaceholders" value="true" />
- <property name="propertySources" ref="zookeeperSources" />
- </bean>
- </beans>
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"
- xmlns:lang="http://www.springframework.org/schema/lang"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
- http://www.springframework.org/schema/jee
- http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/lang
- http://www.springframework.org/schema/lang/spring-lang-3.1.xsd">
- <bean id="druidStatLoggerProxy" class="com.ouc.openplatform.console.audit.DruidStatLoggerProxy">
- <property name="sendMessageClient" ref="sendMessageClient" />
- <property name="enabled" value="${druid.monitor.enable}" />
- </bean>
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
- <property name="url" value="${datasource.url}" />
- <property name="username" value="${datasource.name}" />
- <property name="password" value="${datasource.password}" />
- <property name="connectionProperties" value="config.decrypt=false" />
- <property name="filters" value="config,log4j" />
- <property name="maxActive" value="${datasource.maxActive}" />
- <property name="initialSize" value="${datasource.initialiSize}" />
- <property name="maxWait" value="60000" />
- <property name="minIdle" value="8" />
- <property name="timeBetweenEvictionRunsMillis" value="10000" />
- <property name="minEvictableIdleTimeMillis" value="300000" />
- <property name="validationQuery" value="SELECT 'x' from dual " />
- <property name="testWhileIdle" value="true" />
- <property name="testOnBorrow" value="false" />
- <property name="testOnReturn" value="false" />
- <property name="poolPreparedStatements" value="true" />
- <property name="maxPoolPreparedStatementPerConnectionSize" value="20" />
- <property name="timeBetweenLogStatsMillis" value="${time.between.logstats.millis}" />
- <property name="statLogger" ref="druidStatLoggerProxy" />
- </bean>
- <!-- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="com.ouc.mkhl.supplier.security.dao" />
- <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
- </bean> -->
- </beans>
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://code.alibabatech.com/schema/dubbo
- http://code.alibabatech.com/schema/dubbo/dubbo.xsd
- ">
- <dubbo:application name="${app.name}" />
- <!-- <dubbo:protocol name="dubbo" port="${dubbo.port}" /> -->
- <!-- <dubbo:protocol name="rmi" port="1099" /> -->
- <!-- <dubbo:protocol name="hessian" port="8089" /> -->
- <!-- <dubbo:protocol name="webservice" port="9999" server="jetty"/> -->
- <!-- 多注册中心配置 -->
- <dubbo:registry id="qingdaoRegistry" protocol="zookeeper"
- address="${dubbo.registry.address}" timeout="60000" />
- <!--
- <dubbo:registry id="hangzhouRegistry" address="10.21.131.151:9010" default="false" />
- -->
- <!-- 调用方添加参数 -->
- <dubbo:consumer>
- <dubbo:parameter key="almId" value="S00001" />
- </dubbo:consumer>
- <!-- 发送监控信息的dubbo服务 -->
- <dubbo:reference id="sendDubboMessageClient" registry="qingdaoRegistry"
- owner="hop" interface="com.ouc.openplatform.hmc.client.send.SendMessageClient"
- version="1.0" protocol="dubbo" timeout="100000" init="true" />
- </beans>
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://code.alibabatech.com/schema/dubbo
- http://code.alibabatech.com/schema/dubbo/dubbo.xsd
- ">
- <!-- oop 框架必须接口 begin-->
- <!-- 文件存储服务 -->
- <dubbo:reference id="fileServiceClient" registry="qingdaoRegistry" owner="oop" interface="com.ouc.openplatform.hfs.client.service.FileServiceClient" version="1.0.0" protocol="dubbo" timeout="100000" init="true"/>
- <dubbo:reference id="projectServiceClientAdapter" registry="qingdaoRegistry" owner="oop" interface="com.ouc.openplatform.console.project.spi.MonitorServiceClient" version="1.0" protocol="dubbo" timeout="100000" init="false" />
- <!-- oop 框架必须接口 end-->
- </beans>
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"
- xmlns:lang="http://www.springframework.org/schema/lang" xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
- http://www.springframework.org/schema/jee
- http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/lang
- http://www.springframework.org/schema/lang/spring-lang-3.1.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util-3.1.xsd">
- <!-- 业务日志 -->
- <bean id="logConfigurationReader" class="com.ouc.openplatform.log.config.LogConfigurationReader">
- <property name="fileNames">
- <array>
- <value>classpath*:/logs/**/log-*.xml</value>
- </array>
- </property>
- </bean>
- <bean id="logAdvice" class="com.ouc.mkhl.supplier.security.advice.OperationLogAdvice">
- <property name="logConfigurationMap">
- <bean factory-bean="logConfigurationReader" factory-method="getLogConfigurationMap"/>
- </property>
- <property name="operationLogService" ref="operationLogService"/>
- </bean>
- <bean id="operationLogService" class="com.ouc.mkhl.supplier.security.service.impl.OperationLogServiceImpl">
- <property name="operationLogDAO" ref="operationLogDAO"/>
- </bean>
- <bean id="operationLogDAO" class="org.mybatis.spring.mapper.MapperFactoryBean" parent="baseDAO">
- <property name="mapperInterface" value="com.ouc.mkhl.supplier.security.dao.OperationLogDAO" />
- </bean>
- <aop:config>
- <aop:pointcut id="daoLog" expression="execution(* com.ouc..service.impl.*ServiceImpl.*(..)) && !execution(* com.ouc..service.impl.OperationLogServiceImpl.*(..))"/>
- <aop:aspect ref="logAdvice">
- <aop:around method="advice" pointcut-ref="daoLog"/>
- </aop:aspect>
- </aop:config>
- </beans>
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:jee="http://www.springframework.org/schema/jee"
- xmlns:lang="http://www.springframework.org/schema/lang"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
- http://www.springframework.org/schema/jee
- http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/lang
- http://www.springframework.org/schema/lang/spring-lang-3.1.xsd">
- <!-- quartz监控 -->
- <bean class="com.ouc.openplatform.console.project.spi.support.OopProjectContextListener">
- <property name="monitorServiceClient" ref="projectServiceClientAdapter"/>
- </bean>
- </beans>
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:jee="http://www.springframework.org/schema/jee"
- xmlns:lang="http://www.springframework.org/schema/lang"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
- http://www.springframework.org/schema/jee
- http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/lang
- http://www.springframework.org/schema/lang/spring-lang-3.1.xsd">
- <!-- Transaction Manager -->
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource" />
- </bean>
- <!-- 支持 @Transactional 标记 -->
- <tx:annotation-driven />
- <tx:advice id="txAdvice" transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name="find*" propagation="REQUIRED" read-only="true" />
- <tx:method name="query*" propagation="REQUIRED" read-only="true" />
- <tx:method name="list*" propagation="REQUIRED" read-only="true" />
- <tx:method name="search*" propagation="REQUIRED" read-only="true" />
- <tx:method name="get*" propagation="REQUIRED" read-only="true" />
- <tx:method name="save*" propagation="REQUIRED" />
- <tx:method name="update*" propagation="REQUIRED" />
- <tx:method name="delete*" propagation="REQUIRED" />
- <tx:method name="create*" propagation="REQUIRED" />
- <tx:method name="*" propagation="SUPPORTS" />
- </tx:attributes>
- </tx:advice>
- <aop:config proxy-target-class="true">
- <aop:pointcut id="interceptorPointCuts"
- expression="execution(* com.ouc..service.impl.*ServiceImpl.*(..))" />
- <aop:advisor advice-ref="txAdvice" pointcut-ref="interceptorPointCuts" />
- </aop:config>
- </beans>
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:jee="http://www.springframework.org/schema/jee"
- xmlns:lang="http://www.springframework.org/schema/lang"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
- http://www.springframework.org/schema/jee
- http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/lang
- http://www.springframework.org/schema/lang/spring-lang-3.1.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util-3.1.xsd">
- <!-- DAO -->
- <bean id="fileUploadDAO" class="org.mybatis.spring.mapper.MapperFactoryBean" parent="baseDAO">
- <property name="mapperInterface" value="com.ouc.mkhl.supplier.security.dao.FileUploadDAO" />
- </bean>
- <!-- Service -->
- <bean id="fileUploadService"
- class="com.ouc.mkhl.supplier.security.service.impl.FileUploadServiceImpl">
- <property name="fileUploadDAO" ref="fileUploadDAO"/>
- <property name="fileConstants" ref="fileConstants"/>
- <property name="fileServiceClientAdapter" ref="fileServiceClientAdapter"/>
- </bean>
- <bean id="fileConstants" class="com.ouc.mkhl.supplier.util.FileConstants">
- <property name="fileSavePath" value="${file.save.path}"/>
- </bean>
- <bean id="fileServiceClientAdapter"
- class="com.ouc.mkhl.supplier.security.service.impl.FileServiceClientAdapterImpl">
- <property name="fileServiceClient" ref="fileServiceClient"/>
- <property name="appName" value="MKHL" />
- <property name="storeSystemAddress" value="${store.system.address}" />
- <!-- <property name="appName" value="${app.name}" /> -->
- </bean>
- <bean id="fileUploadServiceAop" class="com.ouc.mkhl.supplier.security.util.FileUploadServiceAop"></bean>
- <aop:config>
- <aop:pointcut id="fileUploadAudit" expression="execution(* com.ouc..service.impl.FileUploadServiceImpl.*(..))"/>
- <aop:aspect ref="fileUploadServiceAop" order="5">
- <aop:before pointcut-ref="fileUploadAudit" method="beforeExecute"/>
- <aop:after pointcut-ref="fileUploadAudit" method="afterExecute" />
- </aop:aspect>
- </aop:config>
- </beans>