Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Commit 8a77a4b

Browse files
committed
reactive
1 parent 0112ba3 commit 8a77a4b

File tree

11 files changed

+335
-0
lines changed

11 files changed

+335
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<modules>
4242
<module>component</module>
4343
<module>service-mvc</module>
44+
<module>service-reactive</module>
4445
</modules>
4546

4647
<!--

service-reactive/.oss-build

Whitespace-only changes.

service-reactive/pom.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed under the Apache License, Version 2.0 (the "License");
4+
~ you may not use this file except in compliance with the License.
5+
~ You may obtain a copy of the License at
6+
~
7+
~ http://www.apache.org/licenses/LICENSE-2.0
8+
~
9+
~ Unless required by applicable law or agreed to in writing, software
10+
~ distributed under the License is distributed on an "AS IS" BASIS,
11+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
~ See the License for the specific language governing permissions and
13+
~ limitations under the License.
14+
-->
15+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
16+
17+
<modelVersion>4.0.0</modelVersion>
18+
<parent>
19+
<groupId>com.opentable</groupId>
20+
<artifactId>otj-spring-archetypes</artifactId>
21+
<version>0.0.10-SNAPSHOT</version>
22+
</parent>
23+
24+
<artifactId>spring-archetype-service-reactive</artifactId>
25+
<packaging>maven-archetype</packaging>
26+
<description>OpenTable Spring Reactive Service archetype</description>
27+
28+
<dependencies>
29+
<dependency>
30+
<groupId>javax.inject</groupId>
31+
<artifactId>javax.inject</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.springframework</groupId>
35+
<artifactId>spring-context</artifactId>
36+
</dependency>
37+
</dependencies>
38+
</project>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed under the Apache License, Version 2.0 (the "License");
4+
~ you may not use this file except in compliance with the License.
5+
~ You may obtain a copy of the License at
6+
~
7+
~ http://www.apache.org/licenses/LICENSE-2.0
8+
~
9+
~ Unless required by applicable law or agreed to in writing, software
10+
~ distributed under the License is distributed on an "AS IS" BASIS,
11+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
~ See the License for the specific language governing permissions and
13+
~ limitations under the License.
14+
-->
15+
<!--
16+
NB: This file is mostly duplicated between the service and component.
17+
Make sure to update accordingly.
18+
-->
19+
<archetype-descriptor name="component">
20+
<requiredProperties>
21+
<requiredProperty key="otj-parent-version" />
22+
</requiredProperties>
23+
<fileSets>
24+
<fileSet filtered="true" packaged="true">
25+
<directory>src/main/java</directory>
26+
<includes>
27+
<include>**/*.java</include>
28+
</includes>
29+
</fileSet>
30+
<fileSet filtered="true" packaged="true">
31+
<directory>src/test/java</directory>
32+
<includes>
33+
<include>**/*.java</include>
34+
</includes>
35+
</fileSet>
36+
<fileSet>
37+
<directory></directory>
38+
<includes>
39+
<include>.build-service</include>
40+
</includes>
41+
</fileSet>
42+
</fileSets>
43+
</archetype-descriptor>

service-reactive/src/main/resources/archetype-resources/.build-service

Whitespace-only changes.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
## Licensed under the Apache License, Version 2.0 (the "License");
3+
## you may not use this file except in compliance with the License.
4+
## You may obtain a copy of the License at
5+
##
6+
## http://www.apache.org/licenses/LICENSE-2.0
7+
##
8+
## Unless required by applicable law or agreed to in writing, software
9+
## distributed under the License is distributed on an "AS IS" BASIS,
10+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
## See the License for the specific language governing permissions and
12+
## limitations under the License.
13+
14+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
15+
16+
<modelVersion>4.0.0</modelVersion>
17+
<parent>
18+
<groupId>com.opentable</groupId>
19+
<artifactId>otj-parent-spring</artifactId>
20+
<version>${otj-parent-version}</version>
21+
</parent>
22+
23+
<scm>
24+
<connection>scm:git:git://github.com/opentable/${project.artifactId}.git</connection>
25+
<developerConnection>scm:git:git@github.com:opentable/${project.artifactId}.git</developerConnection>
26+
<url>http://github.com/opentable/${project.artifactId}</url>
27+
<tag>HEAD</tag>
28+
</scm>
29+
30+
<groupId>${groupId}</groupId>
31+
<artifactId>${artifactId}</artifactId>
32+
<version>1.0.0-SNAPSHOT</version>
33+
<description>Automatically generated description, fill me in!</description>
34+
35+
<properties>
36+
<ot.mainclass>${package}.Main</ot.mainclass>
37+
</properties>
38+
39+
<dependencies>
40+
<dependency>
41+
<groupId>com.opentable.components</groupId>
42+
<artifactId>otj-core</artifactId>
43+
</dependency>
44+
<dependency>
45+
<groupId>com.opentable.components</groupId>
46+
<artifactId>otj-server-core</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>com.opentable.components</groupId>
50+
<artifactId>otj-server-reactive</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>com.opentable.service.discovery</groupId>
54+
<artifactId>discovery-client</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>com.opentable.components</groupId>
58+
<artifactId>otj-webclient</artifactId>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.eclipse.jetty</groupId>
62+
<artifactId>jetty-reactive-httpclient</artifactId>
63+
<scope>runtime</scope>
64+
</dependency>
65+
66+
<dependency>
67+
<groupId>org.springframework</groupId>
68+
<artifactId>spring-context</artifactId>
69+
</dependency>
70+
<dependency>
71+
<groupId>org.springframework</groupId>
72+
<artifactId>spring-web</artifactId>
73+
</dependency>
74+
<dependency>
75+
<groupId>org.springframework</groupId>
76+
<artifactId>spring-webflux</artifactId>
77+
</dependency>
78+
79+
<dependency>
80+
<groupId>javax.inject</groupId>
81+
<artifactId>javax.inject</artifactId>
82+
</dependency>
83+
84+
<dependency>
85+
<groupId>junit</groupId>
86+
<artifactId>junit</artifactId>
87+
<scope>test</scope>
88+
</dependency>
89+
90+
<dependency>
91+
<groupId>org.springframework</groupId>
92+
<artifactId>spring-test</artifactId>
93+
<scope>test</scope>
94+
</dependency>
95+
<dependency>
96+
<groupId>org.springframework.boot</groupId>
97+
<artifactId>spring-boot-test</artifactId>
98+
<scope>test</scope>
99+
</dependency>
100+
101+
<dependency>
102+
<groupId>org.assertj</groupId>
103+
<artifactId>assertj-core</artifactId>
104+
<scope>test</scope>
105+
</dependency>
106+
</dependencies>
107+
</project>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## Licensed under the Apache License, Version 2.0 (the "License");
2+
## you may not use this file except in compliance with the License.
3+
## You may obtain a copy of the License at
4+
##
5+
## http://www.apache.org/licenses/LICENSE-2.0
6+
##
7+
## Unless required by applicable law or agreed to in writing, software
8+
## distributed under the License is distributed on an "AS IS" BASIS,
9+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
## See the License for the specific language governing permissions and
11+
## limitations under the License.
12+
package ${package};
13+
14+
import org.springframework.context.annotation.Bean;
15+
import org.springframework.context.annotation.Configuration;
16+
import org.springframework.context.annotation.Import;
17+
import org.springframework.web.reactive.function.client.WebClient;
18+
19+
import com.opentable.server.OTApplication;
20+
import com.opentable.server.reactive.ReactiveServer;
21+
import com.opentable.service.ServiceInfo;
22+
import com.opentable.service.discovery.client.EnableDiscoveryClient;
23+
24+
import com.opentable.webclient.WebClientConfiguration;
25+
import com.opentable.webclient.WebClientBuilderFactory;
26+
import com.opentable.webclient.WebClientFeatureBinding;
27+
28+
@Configuration
29+
@ReactiveServer
30+
@EnableDiscoveryClient
31+
@Import({WebClientConfiguration.class, MyController.class})
32+
public class Main {
33+
public static void main(final String[] args) {
34+
OTApplication.run(Main.class, args);
35+
}
36+
37+
@Bean
38+
public ServiceInfo serviceInfo() {
39+
return new ServiceInfo() {
40+
@Override
41+
public String getName() {
42+
return "${artifactId}";
43+
}
44+
};
45+
}
46+
47+
@Bean
48+
public WebClient echoClient(WebClientBuilderFactory factory) {
49+
return factory.newBuilder("curl", WebClientFeatureBinding.INTERNAL)
50+
.baseUrl("https://postman-echo.com/")
51+
.build();
52+
}
53+
54+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Licensed under the Apache License, Version 2.0 (the "License");
2+
## you may not use this file except in compliance with the License.
3+
## You may obtain a copy of the License at
4+
##
5+
## http://www.apache.org/licenses/LICENSE-2.0
6+
##
7+
## Unless required by applicable law or agreed to in writing, software
8+
## distributed under the License is distributed on an "AS IS" BASIS,
9+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
## See the License for the specific language governing permissions and
11+
## limitations under the License.
12+
package ${package};
13+
14+
import org.springframework.web.bind.annotation.GetMapping;
15+
import org.springframework.web.bind.annotation.RequestMapping;
16+
import org.springframework.web.bind.annotation.RestController;
17+
18+
@RequestMapping("/")
19+
@RestController
20+
public class MyController
21+
{
22+
23+
@GetMapping
24+
public String getGreeting()
25+
{
26+
return "Hello, world!";
27+
}
28+
29+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Licensed under the Apache License, Version 2.0 (the "License");
2+
## you may not use this file except in compliance with the License.
3+
## You may obtain a copy of the License at
4+
##
5+
## http://www.apache.org/licenses/LICENSE-2.0
6+
##
7+
## Unless required by applicable law or agreed to in writing, software
8+
## distributed under the License is distributed on an "AS IS" BASIS,
9+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
## See the License for the specific language governing permissions and
11+
## limitations under the License.
12+
package ${package};
13+
14+
import static org.assertj.core.api.Assertions.assertThat;
15+
16+
import javax.inject.Inject;
17+
18+
import org.junit.Test;
19+
import org.junit.runner.RunWith;
20+
import org.springframework.boot.test.context.SpringBootTest;
21+
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
22+
import org.springframework.boot.test.web.client.TestRestTemplate;
23+
import org.springframework.http.HttpStatus;
24+
import org.springframework.http.ResponseEntity;
25+
import org.springframework.test.context.junit4.SpringRunner;
26+
27+
import ${package}.Main;
28+
29+
@RunWith(SpringRunner.class)
30+
@SpringBootTest(classes=Main.class, webEnvironment=WebEnvironment.RANDOM_PORT)
31+
public class MainTest {
32+
33+
@Inject
34+
private TestRestTemplate testRestTemplate;
35+
36+
@Test
37+
public void testHelloWorld() {
38+
ResponseEntity<String> actualResponse = testRestTemplate.getForEntity("/", String.class);
39+
assertThat(actualResponse.getStatusCode()).isEqualTo(HttpStatus.OK);
40+
assertThat(actualResponse.getBody()).isEqualTo("Hello, world!");
41+
}
42+
43+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
#
14+
15+
groupId=com.opentable.its
16+
artifactId=service-it
17+
version=0.1.2-SNAPSHOT
18+
package=com.opentable.its.mvc
19+
otj-parent-version=378

0 commit comments

Comments
 (0)