Skip to content

Commit 1a7eca9

Browse files
committed
Merge remote-tracking branch 'remotes/origin/develop'
2 parents 61c7442 + ba8a3e3 commit 1a7eca9

File tree

9 files changed

+121
-12
lines changed

9 files changed

+121
-12
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* itextpdf
2525

2626
> ## github:[https://github.com/netbuffer/ssmbootstrap_table](https://github.com/netbuffer/ssmbootstrap_table)
27-
> ## git@osc:[http://git.oschina.net/gradle/medoo_bootstrap_table](http://git.oschina.net/gradle/medoo_bootstrap_table)
27+
> ## git@osc:[https://git.oschina.net/gradle/ssmbootstrap_table](https://git.oschina.net/gradle/ssmbootstrap_table)
2828
2929
## How to run
3030
The project constructed by `maven`, please execute under the `src/main/java` `SQL script` to your `MySQL` database operation, and then modify the database configuration information `jdbc.properties` under the path `src/main/resource` configuration file in the project directory, enter, execute `mvn tomcat7:run` to run
@@ -45,6 +45,17 @@ metrics | @Timed
4545

4646
#![springfox](src/main/webapp/image/swagger.png)
4747

48+
49+
> `sssbootstrap_table(spring+springmvc+spring data jpa)` github:[https://github.com/netbuffer/sssbootstrap_table](https://github.com/netbuffer/sssbootstrap_table)`/`git@osc:[https://git.oschina.net/netbuffer/sssbootstrap_table](https://git.oschina.net/netbuffer/sssbootstrap_table)
50+
51+
> `sshbootstrap_table(spring+struts2+hibernate)` github:[https://github.com/netbuffer/sshbootstrap-table](https://github.com/netbuffer/sshbootstrap-table)`/`git@osc:[https://git.oschina.net/netbuffer/sshbootstrap-table](https://git.oschina.net/netbuffer/sshbootstrap-table)
52+
53+
> `spring-boot-bootstrap_table(springboot)` github:[https://github.com/netbuffer/spring-boot-bootstrap_table](https://github.com/netbuffer/spring-boot-bootstrap_table)`/`git@osc:[https://git.oschina.net/netbuffer/spring-boot-bootstrap_table](https://git.oschina.net/netbuffer/spring-boot-bootstrap_table)
54+
55+
> `jfinal-bootstrap-table(jfinal)`github:[https://github.com/netbuffer/jfinal-bootstrap-table](https://github.com/netbuffer/jfinal-bootstrap-table)`/`git@osc:[http://git.oschina.net/gradle/jfinal-bootstrap-table](http://git.oschina.net/gradle/jfinal-bootstrap-table)
56+
57+
> `medoo_bootstrap_table(php5)`github:[https://github.com/netbuffer/medoo_bootstrap_table](https://github.com/netbuffer/medoo_bootstrap_table)`/`git@osc:[http://git.oschina.net/gradle/medoo_bootstrap_table](http://git.oschina.net/gradle/medoo_bootstrap_table)
58+
4859
---
4960
>
5061
> * develop开发分支

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@
295295
<dependency>
296296
<groupId>net.sf.ehcache</groupId>
297297
<artifactId>ehcache</artifactId>
298-
<version>2.10.2.2.21</version>
298+
<version>2.10.4</version>
299299
</dependency>
300300
<dependency>
301301
<groupId>net.sf.ehcache</groupId>

src/main/java/cn/com/ttblog/ssmbootstrap_table/controller/EhcacheController.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
import java.util.Arrays;
44

5+
import net.sf.ehcache.Element;
56
import org.slf4j.Logger;
67
import org.slf4j.LoggerFactory;
78
import org.springframework.beans.factory.annotation.Autowired;
8-
import org.springframework.context.ApplicationContext;
99
import org.springframework.stereotype.Controller;
1010
import org.springframework.ui.ModelMap;
1111
import org.springframework.web.bind.annotation.PathVariable;
1212
import org.springframework.web.bind.annotation.RequestMapping;
1313
import net.sf.ehcache.Cache;
1414
import net.sf.ehcache.CacheManager;
15+
import org.springframework.web.bind.annotation.ResponseBody;
1516

1617
/**
1718
* 浏览ehcache状态
@@ -24,14 +25,15 @@ public class EhcacheController {
2425
// private ApplicationContext applicationContext;
2526
@Autowired
2627
private CacheManager cacheManager;
28+
2729
@RequestMapping(value = {"/index/{cache}" })
2830
public String index(@PathVariable("cache") String cache, ModelMap m) {
2931
logger.debug("cache:{}", cache);
3032
if(cacheManager!=null){
3133
m.put("caches",Arrays.deepToString(cacheManager.getCacheNames()));
3234
m.put("getDiskStorePath", cacheManager.getDiskStorePath());
3335
m.put("getName", cacheManager.getName());
34-
// m.put("getOriginalConfigurationText", cacheManager.getOriginalConfigurationText());
36+
m.put("getOriginalConfigurationText", cacheManager.getOriginalConfigurationText());
3537
m.put("getStatus", cacheManager.getStatus());
3638
Cache c=cacheManager.getCache(cache);
3739
if(c!=null){
@@ -42,4 +44,33 @@ public String index(@PathVariable("cache") String cache, ModelMap m) {
4244
logger.debug("ehcache model:{}",m);
4345
return "ehcache";
4446
}
47+
48+
/**
49+
* put到指定cache下
50+
* @param cacheName
51+
* @param key
52+
* @param val
53+
* @return
54+
*/
55+
@RequestMapping(value = {"/putcache/{cache}/{key}/{val}" })
56+
@ResponseBody
57+
public Element put(@PathVariable("cache") String cacheName,@PathVariable("key") String key,@PathVariable("val") String val) {
58+
Cache cache=cacheManager.getCache(cacheName);
59+
Element element=new Element(key,val);
60+
cache.put(element);
61+
return element;
62+
}
63+
64+
/**
65+
* 获取指定cache下的指定key内容
66+
* @param cacheName
67+
* @param key
68+
* @return
69+
*/
70+
@RequestMapping(value = {"/getcache/{cache}/{key}" })
71+
@ResponseBody
72+
public Element get(@PathVariable("cache") String cacheName,@PathVariable("key") String key) {
73+
Cache cache=cacheManager.getCache(cacheName);
74+
return cache.get(key);
75+
}
4576
}

src/main/java/cn/com/ttblog/ssmbootstrap_table/controller/IndexController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ public String login(HttpSession session, HttpServletRequest request,
7373
Cookie c = new Cookie(ConfigConstant.USERNAME, username);
7474
c.setMaxAge(86400);
7575
response.addCookie(c);
76-
Map<String, String> param=new HashMap<String,String>();
76+
Map<String, String> param=new HashMap<>();
7777
param.put("loginname", username);
7878
param.put("logintime", new DateTime().toString("yyyy-MM-dd HH:mm:ss"));
7979
param.put("loginip", request.getRemoteAddr());
80-
applicationContext.publishEvent(new LoginEvent(param));
80+
//publishEvent会依次调用所有的监听器,同步调用,所有监听器执行完毕继续向下执行
81+
applicationContext.publishEvent(new LoginEvent(this,param));
8182
if(requri!=null&&requri.length()>0){
8283
String uri=new String(Base64.decodeBase64(requri));
8384
String touri=uri.substring(request.getContextPath().length()+1);
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
package cn.com.ttblog.ssmbootstrap_table.event;
22

3+
import org.apache.commons.lang3.builder.ToStringBuilder;
34
import org.springframework.context.ApplicationEvent;
5+
import java.util.Map;
46

57
public class LoginEvent extends ApplicationEvent {
6-
7-
public LoginEvent(Object source) {
8+
9+
private Map data;
10+
11+
public LoginEvent(Object source, Map<String, String> data) {
812
super(source);
13+
this.data=data;
14+
}
15+
16+
public Map getData() {
17+
return data;
18+
}
19+
20+
public void setData(Map data) {
21+
this.data = data;
22+
}
23+
24+
public String toString(){
25+
return ToStringBuilder.reflectionToString(this);
926
}
10-
1127
}

src/main/java/cn/com/ttblog/ssmbootstrap_table/listener/TestReceiveLoginEventListener1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@Component
1212
public class TestReceiveLoginEventListener1 implements SmartApplicationListener {
1313

14-
private static final Logger log = LoggerFactory.getLogger(TestReceiveLoginEventListener2.class);
14+
private static final Logger log = LoggerFactory.getLogger(TestReceiveLoginEventListener1.class);
1515

1616
@Override
1717
public boolean supportsEventType(final Class<? extends ApplicationEvent> eventType) {
Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,48 @@
11
package cn.com.ttblog.ssmbootstrap_table.util;
22

3+
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
34
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.scheduling.annotation.AsyncConfigurer;
46
import org.springframework.scheduling.annotation.EnableAsync;
7+
import java.lang.reflect.Method;
8+
import java.util.concurrent.Executor;
9+
import java.util.concurrent.ExecutorService;
10+
import java.util.concurrent.Executors;
11+
import java.util.concurrent.ThreadFactory;
512

613
/**
714
* 启用异步方法
815
* 发现在xml中配置<task:annotation-driven></task:annotation-driven>不生效,
916
* 基于java config是生效的
1017
* http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/annotation/EnableAsync.html
18+
* http://docs.spring.io/spring/docs/4.2.9.RELEASE/spring-framework-reference/htmlsingle/#scheduling-annotation-support-async
1119
*/
1220
@Configuration
1321
@EnableAsync
14-
public class Config {
22+
public class Config implements AsyncConfigurer {
23+
24+
/**
25+
* 自定义实现Executor
26+
* @return
27+
*/
28+
@Override
29+
public Executor getAsyncExecutor() {
30+
ExecutorService executorService=Executors.newSingleThreadExecutor(new ThreadFactory() {
31+
@Override
32+
public Thread newThread(Runnable r) {
33+
return new Thread(r,"task");
34+
}
35+
});
36+
return executorService;
37+
}
38+
39+
@Override
40+
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
41+
return new AsyncUncaughtExceptionHandler() {
42+
@Override
43+
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
44+
System.out.printf("throwable:%s,method:%s,objects:%s",throwable,method,objects);
45+
}
46+
};
47+
}
1548
}

src/main/resources/spring/spring-context.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns:context="http://www.springframework.org/schema/context"
55
xmlns:aop="http://www.springframework.org/schema/aop"
6-
xsi:schemaLocation="http://www.springframework.org/schema/beans
6+
xmlns:task="http://www.springframework.org/schema/task"
7+
xsi:schemaLocation="
8+
http://www.springframework.org/schema/task
9+
http://www.springframework.org/schema/task/spring-task-4.0.xsd
10+
http://www.springframework.org/schema/beans
711
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
812
http://www.springframework.org/schema/context
913
http://www.springframework.org/schema/context/spring-context-4.0.xsd
@@ -14,9 +18,21 @@
1418

1519
<context:component-scan base-package="cn.com.ttblog.ssmbootstrap_table">
1620
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
21+
<context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.RestController"/>
1722
<context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice" />
1823
</context:component-scan>
1924

25+
<!--<bean id="threadPoolTaskExecutor"-->
26+
<!--class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">-->
27+
<!--<property name="corePoolSize" value="1" />-->
28+
<!--<property name="maxPoolSize" value="10" />-->
29+
<!--<property name="queueCapacity" value="50" />-->
30+
<!--<property name="threadNamePrefix" value="task-" />-->
31+
<!--<property name="keepAliveSeconds" value="30" />-->
32+
<!--</bean>-->
33+
34+
<!--<task:annotation-driven executor="threadPoolTaskExecutor"></task:annotation-driven>-->
35+
2036
<bean id="configProperties"
2137
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
2238
<property name="locations">

src/main/resources/spring/spring-mvc.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<!-- 多包扫描测试 -->
1616
<context:component-scan base-package="cn.com.ttblog.ssmbootstrap_table.controller,com.other.**,org.exampledriven.cxfexample.**" use-default-filters="false">
1717
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
18+
<context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.RestController" />
1819
<context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice" />
1920
</context:component-scan>
2021

0 commit comments

Comments
 (0)