Authored by ping

update

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- secutity configs -->
<bean id="securityConfigMap" class="org.springframework.beans.factory.config.YamlMapFactoryBean">
<property name="resources">
<list>
<value>classpath:security-key.yml</value>
</list>
</property>
</bean>
<bean id="securityInterceptor" class="com.yoho.unions.interceptor.SecurityInterceptor">
<property name="keyConfigMap" ref="securityConfigMap" />
<property name="isDebugEnable" value="${is_debug_enable:true}" />
<property name="excludeUrls">
<list>
<value>/UnionRest/addUnion</value>
<value>/ActivateUnionRest/activateUnion</value>
</list>
</property>
<property name="excludeMethods">
<list>
</list>
</property>
</bean>
</beans>
... ...
client_keys:
- type: iphone
key: a85bb0674e08986c6b115d5e3a4884fa
- type: ipad
key: ad9fcda2e679cf9229e37feae2cdcf80
- type: android
key: fd4ad5fcfa0de589ef238c0e7331b585
- type: yoho
key: fd4ad5fcsa0de589af23234ks1923ks
- type: h5
key: fd4ad5fcfa0de589ef238c0e7331b585
- type: web
key: 0ed29744ed318fd28d2c07985d3ba633
\ No newline at end of file
... ...
... ... @@ -3,6 +3,9 @@
*/
package com.yoho.unions.server.restapi;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
... ... @@ -29,6 +32,8 @@ public class ActivateUnionRest {
static Logger log = LoggerFactory.getLogger(ActivateUnionRest.class);
static ExecutorService exe = Executors.newFixedThreadPool(50);
/**
* 激活联盟
* @param request
... ... @@ -39,27 +44,37 @@ public class ActivateUnionRest {
log.info("addUnion with param is {}", vo);
ActivateUnionRequestBO bo = new ActivateUnionRequestBO();
BeanUtils.copyProperties(vo, bo);
MainUnionService service = null;
//处理安卓的服务
for (String str : UnionConstant.andriodServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", vo);
}
}
//处理iOS的服务
for (String str : UnionConstant.iOSServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", vo);
//多线程处理
exe.execute(new Runnable() {
@Override
public void run() {
MainUnionService service = null;
//处理安卓的服务
for (String str : UnionConstant.andriodServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", vo);
}
}
//处理iOS的服务
for (String str : UnionConstant.iOSServiceList) {
//捕获异常,不影响后面的联盟
try {
service = SpringContextUtil.getBean(str, MainUnionService.class);
service.activeUnion(bo);
} catch (Exception e) {
log.warn("addUnion error with param is {}", vo);
}
}
}
}
});
return new ActiveUnionResponseBO(200, "success");
}
}
... ...
... ... @@ -58,7 +58,7 @@
</bean>
<mvc:interceptors>
<!-- <ref bean="securityInterceptor" /> -->
<ref bean="securityInterceptor" />
<ref bean="threadProfileInterceptor"/>
</mvc:interceptors>
</beans>
... ...