Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fee4488

Browse files
Flowable 和Spring web的结合使用
1 parent ec1e43f commit fee4488

File tree

21 files changed

+5700
-0
lines changed

21 files changed

+5700
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
*#*#
2+
*.#*
3+
*.iml
4+
*.ipr
5+
*.iws
6+
*.pyc
7+
*.pyo
8+
*.swp
9+
*~
10+
.DS_Store
11+
.cache
12+
.classpath
13+
.ensime
14+
.ensime_cache/
15+
.ensime_lucene
16+
.generated-mima*
17+
.idea/
18+
.idea_modules/
19+
.project
20+
.pydevproject
21+
.scala_dependencies
22+
.settings
23+
/lib/
24+
R-unit-tests.log
25+
R/unit-tests.out
26+
R/cran-check.out
27+
R/pkg/vignettes/sparkr-vignettes.html
28+
R/pkg/tests/fulltests/Rplots.pdf
29+
build/*.jar
30+
build/apache-maven*
31+
build/scala*
32+
build/zinc*
33+
cache
34+
checkpoint
35+
conf/*.cmd
36+
conf/*.conf
37+
conf/*.properties
38+
conf/*.sh
39+
conf/*.xml
40+
conf/java-opts
41+
conf/slaves
42+
dependency-reduced-pom.xml
43+
derby.log
44+
dev/create-release/*final
45+
dev/create-release/*txt
46+
dev/pr-deps/
47+
dist/
48+
docs/_site
49+
docs/api
50+
sql/docs
51+
sql/site
52+
lib_managed/
53+
lint-r-report.log
54+
log/
55+
logs/
56+
out/
57+
project/boot/
58+
project/build/target/
59+
project/plugins/lib_managed/
60+
project/plugins/project/build.properties
61+
project/plugins/src_managed/
62+
project/plugins/target/
63+
python/lib/pyspark.zip
64+
python/deps
65+
python/pyspark/python
66+
reports/
67+
scalastyle-on-compile.generated.xml
68+
scalastyle-output.xml
69+
scalastyle.txt
70+
spark-*-bin-*.tgz
71+
spark-tests.log
72+
src_managed/
73+
streaming-tests.log
74+
target/
75+
unit-tests.log
76+
work/
77+
78+
# For Hive
79+
TempStatsStore/
80+
metastore/
81+
metastore_db/
82+
sql/hive-thriftserver/test_warehouses
83+
warehouse/
84+
spark-warehouse/
85+
86+
# For R session data
87+
.RData
88+
.RHistory
89+
.Rhistory
90+
*.Rproj
91+
*.Rproj.*
92+
93+
.Rproj.user

‎chapter14/Spring Demo/rx-react/pom.xml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.dockerx</groupId>
7+
<artifactId>rx-react</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<name>rx-react</name>
12+
<description>RxJava2 Demo project for Spring Boot</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>2.0.1.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24+
<java.version>9</java.version>
25+
<springfox.version>2.8.0</springfox.version>
26+
<springfoxui.version>2.8.0</springfoxui.version>
27+
</properties>
28+
29+
<dependencies>
30+
<dependency>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-starter-web</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-starter-tomcat</artifactId>
37+
<scope>compile</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>com.google.guava</groupId>
41+
<artifactId>guava</artifactId>
42+
<version>23.6-jre</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>io.reactivex.rxjava2</groupId>
46+
<artifactId>rxjava</artifactId>
47+
<version>2.1.7</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>com.fasterxml.jackson.datatype</groupId>
51+
<artifactId>jackson-datatype-jsr310</artifactId>
52+
<version>2.9.2</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.yaml</groupId>
56+
<artifactId>snakeyaml</artifactId>
57+
<version>1.19</version>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.apache.commons</groupId>
61+
<artifactId>commons-lang3</artifactId>
62+
<version>3.6</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>commons-io</groupId>
66+
<artifactId>commons-io</artifactId>
67+
<version>2.5</version>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.projectlombok</groupId>
71+
<artifactId>lombok</artifactId>
72+
<optional>true</optional>
73+
</dependency>
74+
<dependency>
75+
<groupId>org.springframework.boot</groupId>
76+
<artifactId>spring-boot-starter-test</artifactId>
77+
<scope>test</scope>
78+
</dependency>
79+
<!-- https://mvnrepository.com/artifact/com.github.servanter/netsfjson-support-spring -->
80+
<dependency>
81+
<groupId>com.github.servanter</groupId>
82+
<artifactId>netsfjson-support-spring</artifactId>
83+
<version>1.0.0</version>
84+
</dependency>
85+
<dependency>
86+
<groupId>io.springfox</groupId>
87+
<artifactId>springfox-swagger2</artifactId>
88+
<version>${springfox.version}</version>
89+
<exclusions>
90+
<exclusion>
91+
<groupId>org.mapstruct</groupId>
92+
<artifactId>mapstruct</artifactId>
93+
</exclusion>
94+
</exclusions>
95+
</dependency>
96+
<dependency>
97+
<groupId>io.springfox</groupId>
98+
<artifactId>springfox-swagger-ui</artifactId>
99+
<version>${springfoxui.version}</version>
100+
<exclusions>
101+
<exclusion>
102+
<artifactId>mapstruct</artifactId>
103+
<groupId>org.mapstruct</groupId>
104+
</exclusion>
105+
</exclusions>
106+
</dependency>
107+
<dependency>
108+
<groupId>javax.xml.bind</groupId>
109+
<artifactId>jaxb-api</artifactId>
110+
<version>2.3.0</version>
111+
</dependency>
112+
</dependencies>
113+
114+
<build>
115+
<plugins>
116+
<plugin>
117+
<groupId>org.springframework.boot</groupId>
118+
<artifactId>spring-boot-maven-plugin</artifactId>
119+
</plugin>
120+
</plugins>
121+
</build>
122+
123+
124+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.dockerx.rxreact;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.web.client.RestTemplate;
7+
8+
@SpringBootApplication
9+
public class RxReactApplication {
10+
11+
@Bean
12+
public RestTemplate restTemplate() {
13+
return new RestTemplate();
14+
}
15+
public static void main(String[] args) {
16+
SpringApplication.run(RxReactApplication.class, args);
17+
}
18+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.dockerx.rxreact.config;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.Configuration;
6+
import springfox.documentation.builders.ApiInfoBuilder;
7+
import springfox.documentation.builders.PathSelectors;
8+
import springfox.documentation.builders.RequestHandlerSelectors;
9+
import springfox.documentation.service.ApiInfo;
10+
import springfox.documentation.spi.DocumentationType;
11+
import springfox.documentation.spring.web.plugins.Docket;
12+
import springfox.documentation.swagger2.annotations.EnableSwagger2;
13+
14+
/**
15+
* @author Author 知秋
16+
* @email fei6751803@163.com
17+
* @time Created by Auser on 2018年4月23日 20:55.
18+
*/
19+
@Configuration
20+
@EnableSwagger2
21+
public class SwaggerConfig {
22+
@Value("${swagger.title}")
23+
private String title;
24+
25+
@Value("${swagger.description}")
26+
private String description;
27+
28+
@Value("${swagger.version}")
29+
private String version;
30+
31+
@Bean
32+
public Docket api() {
33+
return new Docket(DocumentationType.SWAGGER_2)
34+
.apiInfo(apiInfo()).select()
35+
.apis(RequestHandlerSelectors.basePackage("com.dockerx.rxreact")).paths(
36+
PathSelectors.any()).build();
37+
}
38+
39+
/**
40+
* This method will return the API info object to swagger which will in turn
41+
* display the information on the swagger UI.
42+
*
43+
* @return the API information
44+
*/
45+
private ApiInfo apiInfo() {
46+
return new ApiInfoBuilder()
47+
.title(title)
48+
.description(description)
49+
.version(version)
50+
.build();
51+
}
52+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.dockerx.rxreact.config;
2+
3+
4+
import com.dockerx.rxreact.returnhandler.FlowableReturnValueHandler;
5+
import org.springframework.context.annotation.ComponentScan;
6+
import org.springframework.context.annotation.Configuration;
7+
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
8+
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
9+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
10+
11+
import java.util.List;
12+
13+
/**
14+
* @author Author 知秋
15+
* @email fei6751803@163.com
16+
* @time Created by Auser on 2018年4月23日 21:24.
17+
*/
18+
@Configuration
19+
@ComponentScan(basePackages = {"com.dockerx.rxreact.*"})
20+
public class Webconfig extends WebMvcConfigurationSupport {
21+
@Override
22+
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
23+
super.addReturnValueHandlers(returnValueHandlers);
24+
returnValueHandlers.add(new FlowableReturnValueHandler());
25+
}
26+
27+
@Override
28+
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
29+
super.addResourceHandlers(registry);
30+
registry.addResourceHandler("swagger-ui.html")
31+
.addResourceLocations("classpath:/META-INF/resources/");
32+
33+
registry.addResourceHandler("/webjars/**")
34+
.addResourceLocations("classpath:/META-INF/resources/webjars/");
35+
36+
}
37+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.dockerx.rxreact.controller;
2+
3+
import com.dockerx.rxreact.domain.Commit;
4+
import com.dockerx.rxreact.services.GitHubService;
5+
import io.reactivex.Flowable;
6+
import io.reactivex.schedulers.Schedulers;
7+
import io.swagger.annotations.ApiImplicitParam;
8+
import io.swagger.annotations.ApiImplicitParams;
9+
import io.swagger.annotations.ApiOperation;
10+
import org.springframework.beans.factory.annotation.Autowired;
11+
import org.springframework.http.MediaType;
12+
import org.springframework.web.bind.annotation.GetMapping;
13+
import org.springframework.web.bind.annotation.PathVariable;
14+
import org.springframework.web.bind.annotation.RequestMapping;
15+
import org.springframework.web.bind.annotation.RestController;
16+
17+
/**
18+
* @author Author 知秋
19+
* @email fei6751803@163.com
20+
* @time Created by Auser on 2018年4月23日 1:41.
21+
*/
22+
@RestController
23+
@RequestMapping("/api/repos")
24+
public class ReposController {
25+
private final GitHubService gitHubService;
26+
27+
@Autowired
28+
public ReposController(GitHubService gitHubService) {
29+
this.gitHubService = gitHubService;
30+
}
31+
@ApiOperation(value="github用户所有仓库查询", notes="根据用户名称来查找其所有的仓库")
32+
@ApiImplicitParam(name = "user", value = "所要查询的用户名称", required = true)
33+
@GetMapping(value = "{user}",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
34+
public Flowable<String> list(@PathVariable String user){
35+
return gitHubService.getRepos(user).observeOn(Schedulers.io());
36+
}
37+
@ApiOperation(value="github用户一周内有推送的仓库查询", notes="根据用户名称来查找其一周内有推送的仓库")
38+
@ApiImplicitParam(name = "user", value = "所要查询的用户名称", required = true)
39+
@GetMapping(value = "/inweek/{user}",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
40+
public Flowable<String> getReposInWeek(@PathVariable String user){
41+
return gitHubService.getReposInWeek(user).observeOn(Schedulers.io());
42+
}
43+
@ApiOperation(value="github用户指定仓库一周内的提交信息")
44+
@ApiImplicitParams({
45+
@ApiImplicitParam(name = "user", value = "所要查询的用户名称", required = true),
46+
@ApiImplicitParam(name = "repo", value = "所要查询的用户的仓库名称", required = true)
47+
})
48+
@GetMapping(value = "/inweek/{user}/{repo}")
49+
public Flowable<Commit> getCommitsInWeek(@PathVariable String user, @PathVariable String repo){
50+
return gitHubService.getCommitsInWeek(user,repo).observeOn(Schedulers.io());
51+
}
52+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /