diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2b2b42b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/reactivetomcat/target/
+/webflux/target/
+/undertow/target/
+/tomcat/target/
diff --git a/reactivetomcat/nb-configuration.xml b/reactivetomcat/nb-configuration.xml
new file mode 100644
index 0000000..e0ad8dd
--- /dev/null
+++ b/reactivetomcat/nb-configuration.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ Temurin_19.0.2_7
+
+
diff --git a/reactivetomcat/nbactions.xml b/reactivetomcat/nbactions.xml
index 502c81f..782e531 100644
--- a/reactivetomcat/nbactions.xml
+++ b/reactivetomcat/nbactions.xml
@@ -9,8 +9,8 @@
spring-boot:run
- -noverify -XX:TieredStopAtLevel=1
- io.project.app.sp34.Sp34Application
+ -noverify -XX:TieredStopAtLevel=1
+ io.project.app.sp34.Sp34Application
always
@@ -23,8 +23,8 @@
spring-boot:run
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1
- io.project.app.sp34.Sp34Application
+ -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1
+ io.project.app.sp34.Sp34Application
always
true
diff --git a/reactivetomcat/pom.xml b/reactivetomcat/pom.xml
index 9efaa53..ec0efc2 100644
--- a/reactivetomcat/pom.xml
+++ b/reactivetomcat/pom.xml
@@ -5,7 +5,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.2.6.RELEASE
+ 3.0.3
io.project.app
@@ -15,39 +15,27 @@
reactivetomcat
- 1.8
- Hoxton.SR3
+ 19
+ 2022.0.1
+
+ org.springdoc
+ springdoc-openapi-starter-webflux-ui
+ 2.0.2
+
io.vavr
vavr
0.9.2
-
- io.springfox
- springfox-swagger-ui
- 3.0.0-SNAPSHOT
-
-
- io.springfox
- springfox-spring-webflux
- 3.0.0-SNAPSHOT
-
-
- io.springfox
- springfox-swagger2
- 3.0.0-SNAPSHOT
-
+
org.springframework.boot
spring-boot-starter-actuator
-
- org.springframework.boot
- spring-boot-starter-cloud-connectors
-
+
org.springframework.boot
spring-boot-starter-web
diff --git a/reactivetomcat/src/main/java/io/project/app/CorsConfiguration.java b/reactivetomcat/src/main/java/io/project/app/CorsConfiguration.java
new file mode 100644
index 0000000..8448fa3
--- /dev/null
+++ b/reactivetomcat/src/main/java/io/project/app/CorsConfiguration.java
@@ -0,0 +1,40 @@
+package io.project.sp;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.http.server.reactive.ServerHttpResponse;
+import org.springframework.web.cors.reactive.CorsUtils;
+import org.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.WebFilter;
+import org.springframework.web.server.WebFilterChain;
+
+/**
+ *
+ * @author armen
+ */
+@Configuration
+public class CorsConfiguration {
+
+ private static final String ALLOWED_HEADERS = "*";
+ private static final String ALLOWED_METHODS = "GET, PUT, POST, DELETE, OPTIONS, PATCH";
+ private static final String ALLOWED_ORIGIN = "*";
+ private static final String MAX_AGE = "7200";
+
+ @Bean
+ public WebFilter corsFilter() {
+ return (ServerWebExchange ctx, WebFilterChain chain) -> {
+ ServerHttpRequest request = ctx.getRequest();
+ if (CorsUtils.isCorsRequest(request)) {
+ ServerHttpResponse response = ctx.getResponse();
+ HttpHeaders headers = response.getHeaders();
+ headers.add("Access-Control-Allow-Origin", ALLOWED_ORIGIN);
+ headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS);
+ headers.add("Access-Control-Max-Age", MAX_AGE);
+ headers.add("Access-Control-Allow-Headers", ALLOWED_HEADERS);
+ }
+ return chain.filter(ctx);
+ };
+ }
+}
diff --git a/reactivetomcat/src/main/java/io/project/app/OpenApiConfiguration.java b/reactivetomcat/src/main/java/io/project/app/OpenApiConfiguration.java
new file mode 100644
index 0000000..44f2d81
--- /dev/null
+++ b/reactivetomcat/src/main/java/io/project/app/OpenApiConfiguration.java
@@ -0,0 +1,19 @@
+package io.project.sp;
+
+import org.springdoc.core.models.GroupedOpenApi;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class OpenApiConfiguration {
+
+ @Bean
+ public GroupedOpenApi publicApi() {
+ return GroupedOpenApi.builder()
+ .group("publicapi")
+ .packagesToScan("io.project")
+ .pathsToMatch("/api/**")
+ .build();
+ }
+
+}
diff --git a/reactivetomcat/src/main/java/io/project/app/SwaggerConfig.java b/reactivetomcat/src/main/java/io/project/app/SwaggerConfig.java
deleted file mode 100644
index e0a6e7a..0000000
--- a/reactivetomcat/src/main/java/io/project/app/SwaggerConfig.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package io.project.app;
-
-import java.util.function.Predicate;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import springfox.documentation.builders.ApiInfoBuilder;
-import static springfox.documentation.builders.PathSelectors.regex;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.Contact;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2WebFlux;
-
-/**
- *
- * @author armenacd
- */
-@Configuration
-@EnableSwagger2WebFlux
-public class SwaggerConfig {
-
- private ApiInfo apiInfo() {
- return new ApiInfoBuilder()
- .title("Reactive Tomcat API")
- .description("From Zero to Hello!")
- .termsOfServiceUrl("http://www-03.ibm.com/software/sla/sladb.nsf/sla/bm?Open")
- .contact(new Contact("Armen Arzumanyan", "http://github.com/armdev", "armen.arzumanyan@gmail.com"))
- .license("Apache License Version 2.0")
- .licenseUrl("https://github.com/IBM-Bluemix/news-aggregator/blob/master/LICENSE")
- .version("2.0")
- .build();
- }
-
- @Bean
- public Docket api() {
- return new Docket(DocumentationType.SWAGGER_2).enable(true)
- .groupName("Reactive API")
- .apiInfo(apiInfo())
- .select()
- .paths(regex("/api.*"))
- // .paths(not(PathSelectors.regex("/actuator.*")))
- .build();
- }
-
- private static Predicate not(Predicate input) {
- return it -> !input.test(it);
- }
-}
diff --git a/reactivetomcat/src/main/java/io/project/app/services/KillerService.java b/reactivetomcat/src/main/java/io/project/app/services/KillerService.java
index c23ce13..63d7233 100644
--- a/reactivetomcat/src/main/java/io/project/app/services/KillerService.java
+++ b/reactivetomcat/src/main/java/io/project/app/services/KillerService.java
@@ -26,7 +26,7 @@ public class KillerService {
@Autowired
private RestTemplate restTemplate;
- private List targetList = Arrays.asList("http://localhost:2023/actuator/shutdown", "http://venera:2077/actuator/shutdown",
+ private final List targetList = Arrays.asList("http://localhost:2023/actuator/shutdown", "http://venera:2077/actuator/shutdown",
"http://localhost:2021/actuator/shutdown", "http://localhost:2022/actuator/shutdown", "http://mars:8585858585/actuator/shutdown");
@Scheduled(fixedDelay = 8000)
@@ -44,7 +44,6 @@ public void shoot() {
if (!kill.isSuccess()) {
log.info("FAIL: Could not kill microservice with following address: " + url);
- //log.info(kill.toString());
}
}
diff --git a/tomcat/nb-configuration.xml b/tomcat/nb-configuration.xml
new file mode 100644
index 0000000..e0ad8dd
--- /dev/null
+++ b/tomcat/nb-configuration.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ Temurin_19.0.2_7
+
+
diff --git a/tomcat/nbactions.xml b/tomcat/nbactions.xml
index 502c81f..782e531 100644
--- a/tomcat/nbactions.xml
+++ b/tomcat/nbactions.xml
@@ -9,8 +9,8 @@
spring-boot:run
- -noverify -XX:TieredStopAtLevel=1
- io.project.app.sp34.Sp34Application
+ -noverify -XX:TieredStopAtLevel=1
+ io.project.app.sp34.Sp34Application
always
@@ -23,8 +23,8 @@
spring-boot:run
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1
- io.project.app.sp34.Sp34Application
+ -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1
+ io.project.app.sp34.Sp34Application
always
true
diff --git a/tomcat/pom.xml b/tomcat/pom.xml
index 7c3a2ee..dd89c8b 100644
--- a/tomcat/pom.xml
+++ b/tomcat/pom.xml
@@ -5,7 +5,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.2.6.RELEASE
+ 3.0.3
io.project.app
@@ -15,44 +15,33 @@
tomcat
- 1.8
- Hoxton.SR3
+ 19
+ 2022.0.1
-
+
io.vavr
vavr
0.9.2
-
-
- io.springfox
- springfox-swagger-ui
- 2.9.2
-
+
- io.springfox
- springfox-swagger2
- 2.9.2
+ org.springdoc
+ springdoc-openapi-starter-webmvc-ui
+ 2.0.0
org.springframework.boot
spring-boot-starter-actuator
-
-
- org.springframework.boot
- spring-boot-starter-cloud-connectors
-
+
org.springframework.boot
spring-boot-starter-web
-
-
+
org.springframework.cloud
spring-cloud-starter
-
org.springframework.boot
spring-boot-devtools
@@ -68,8 +57,7 @@
org.projectlombok
lombok
true
-
-
+
diff --git a/tomcat/src/main/java/io/project/app/OpenApiConfiguration.java b/tomcat/src/main/java/io/project/app/OpenApiConfiguration.java
new file mode 100644
index 0000000..a571a66
--- /dev/null
+++ b/tomcat/src/main/java/io/project/app/OpenApiConfiguration.java
@@ -0,0 +1,20 @@
+package io.project.app;
+
+import org.springdoc.core.models.GroupedOpenApi;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class OpenApiConfiguration {
+
+ @Bean
+ public GroupedOpenApi publicApi() {
+ return GroupedOpenApi.builder()
+ .group("publicapi")
+ .packagesToScan("io.project")
+ .pathsToMatch("/api/**")
+ .build();
+ }
+
+}
diff --git a/tomcat/src/main/java/io/project/app/RegularTomcatApplication.java b/tomcat/src/main/java/io/project/app/RegularTomcatApplication.java
index e1f7c93..23b1a94 100644
--- a/tomcat/src/main/java/io/project/app/RegularTomcatApplication.java
+++ b/tomcat/src/main/java/io/project/app/RegularTomcatApplication.java
@@ -8,6 +8,9 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@SpringBootApplication
@ComponentScan("io.project.app")
@@ -25,4 +28,19 @@ public static void main(String[] args) {
public RestTemplate restTemplate() {
return new RestTemplate();
}
+
+ @Bean
+ public WebMvcConfigurer corsConfigurer() {
+ return new WebMvcConfigurer() {
+ @Override
+ public void addCorsMappings(CorsRegistry registry) {
+ registry
+ .addMapping("/**")
+ .allowedMethods(CorsConfiguration.ALL)
+ .allowedHeaders(CorsConfiguration.ALL)
+ .allowedOriginPatterns(CorsConfiguration.ALL);
+ }
+ };
+ }
+
}
diff --git a/tomcat/src/main/java/io/project/app/SwaggerConfig.java b/tomcat/src/main/java/io/project/app/SwaggerConfig.java
deleted file mode 100644
index 2633572..0000000
--- a/tomcat/src/main/java/io/project/app/SwaggerConfig.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package io.project.app;
-
-import java.util.function.Predicate;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import springfox.documentation.builders.ApiInfoBuilder;
-import static springfox.documentation.builders.PathSelectors.regex;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.Contact;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-
-/**
- *
- * @author armenacd
- */
-@Configuration
-@EnableSwagger2
-public class SwaggerConfig {
-
- private ApiInfo apiInfo() {
- return new ApiInfoBuilder()
- .title("Tomcat API")
- .description("From Zero to Hello!")
- .termsOfServiceUrl("http://www-03.ibm.com/software/sla/sladb.nsf/sla/bm?Open")
- .contact(new Contact("Armen Arzumanyan", "http://github.com/armdev", "armen.arzumanyan@gmail.com"))
- .license("Apache License Version 2.0")
- .licenseUrl("https://github.com/IBM-Bluemix/news-aggregator/blob/master/LICENSE")
- .version("2.0")
- .build();
- }
-
- @Bean
- public Docket api() {
- return new Docket(DocumentationType.SWAGGER_2).enable(true)
- .groupName("Reactive API")
- .apiInfo(apiInfo())
- .select()
- .paths(regex("/api.*"))
- // .paths(not(PathSelectors.regex("/actuator.*")))
- .build();
- }
-
- private static Predicate not(Predicate input) {
- return it -> !input.test(it);
- }
-}
diff --git a/tomcat/src/main/java/io/project/app/services/KillerService.java b/tomcat/src/main/java/io/project/app/services/KillerService.java
index a304d84..079329a 100644
--- a/tomcat/src/main/java/io/project/app/services/KillerService.java
+++ b/tomcat/src/main/java/io/project/app/services/KillerService.java
@@ -26,7 +26,7 @@ public class KillerService {
@Autowired
private RestTemplate restTemplate;
- private List targetList = Arrays.asList("http://localhost:2020/actuator/shutdown", "http://venera:2077/actuator/shutdown",
+ private final List targetList = Arrays.asList("http://localhost:2020/actuator/shutdown", "http://venera:2077/actuator/shutdown",
"http://localhost:2022/actuator/shutdown", "http://localhost:2023/actuator/shutdown", "http://mars:8585858585/actuator/shutdown");
@Scheduled(fixedDelay = 8000)
diff --git a/undertow/nb-configuration.xml b/undertow/nb-configuration.xml
new file mode 100644
index 0000000..e0ad8dd
--- /dev/null
+++ b/undertow/nb-configuration.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ Temurin_19.0.2_7
+
+
diff --git a/undertow/nbactions.xml b/undertow/nbactions.xml
index 502c81f..782e531 100644
--- a/undertow/nbactions.xml
+++ b/undertow/nbactions.xml
@@ -9,8 +9,8 @@
spring-boot:run
- -noverify -XX:TieredStopAtLevel=1
- io.project.app.sp34.Sp34Application
+ -noverify -XX:TieredStopAtLevel=1
+ io.project.app.sp34.Sp34Application
always
@@ -23,8 +23,8 @@
spring-boot:run
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1
- io.project.app.sp34.Sp34Application
+ -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1
+ io.project.app.sp34.Sp34Application
always
true
diff --git a/undertow/pom.xml b/undertow/pom.xml
index 21f3348..279066a 100644
--- a/undertow/pom.xml
+++ b/undertow/pom.xml
@@ -5,7 +5,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.2.6.RELEASE
+ 3.0.3
io.project.app
@@ -15,34 +15,27 @@
undertow
- 1.8
- Hoxton.SR3
+ 19
+ 2022.0.1
io.vavr
vavr
- 0.9.2
+ 0.10.4
+
- io.springfox
- springfox-swagger-ui
- 2.9.2
-
-
- io.springfox
- springfox-swagger2
- 2.9.2
+ org.springdoc
+ springdoc-openapi-starter-webmvc-ui
+ 2.0.0
org.springframework.boot
spring-boot-starter-actuator
-
- org.springframework.boot
- spring-boot-starter-cloud-connectors
-
+
org.springframework.boot
spring-boot-starter-web
diff --git a/undertow/src/main/java/io/project/app/OpenApiConfiguration.java b/undertow/src/main/java/io/project/app/OpenApiConfiguration.java
new file mode 100644
index 0000000..a571a66
--- /dev/null
+++ b/undertow/src/main/java/io/project/app/OpenApiConfiguration.java
@@ -0,0 +1,20 @@
+package io.project.app;
+
+import org.springdoc.core.models.GroupedOpenApi;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class OpenApiConfiguration {
+
+ @Bean
+ public GroupedOpenApi publicApi() {
+ return GroupedOpenApi.builder()
+ .group("publicapi")
+ .packagesToScan("io.project")
+ .pathsToMatch("/api/**")
+ .build();
+ }
+
+}
diff --git a/undertow/src/main/java/io/project/app/SwaggerConfig.java b/undertow/src/main/java/io/project/app/SwaggerConfig.java
deleted file mode 100644
index 9a0896e..0000000
--- a/undertow/src/main/java/io/project/app/SwaggerConfig.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package io.project.app;
-
-import java.util.function.Predicate;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import springfox.documentation.builders.ApiInfoBuilder;
-import static springfox.documentation.builders.PathSelectors.regex;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.Contact;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-
-/**
- *
- * @author armenacd
- */
-@Configuration
-@EnableSwagger2
-public class SwaggerConfig {
-
- private ApiInfo apiInfo() {
- return new ApiInfoBuilder()
- .title("Undertow API")
- .description("From Zero to Hello!")
- .termsOfServiceUrl("http://www-03.ibm.com/software/sla/sladb.nsf/sla/bm?Open")
- .contact(new Contact("Armen Arzumanyan", "http://github.com/armdev", "armen.arzumanyan@gmail.com"))
- .license("Apache License Version 2.0")
- .licenseUrl("https://github.com/IBM-Bluemix/news-aggregator/blob/master/LICENSE")
- .version("2.0")
- .build();
- }
-
- @Bean
- public Docket api() {
- return new Docket(DocumentationType.SWAGGER_2).enable(true)
- .groupName("Undertow API")
- .apiInfo(apiInfo())
- .select()
- .paths(regex("/api.*"))
- // .paths(not(PathSelectors.regex("/actuator.*")))
- .build();
- }
-
- private static Predicate not(Predicate input) {
- return it -> !input.test(it);
- }
-}
diff --git a/undertow/src/main/java/io/project/app/UndertowApplication.java b/undertow/src/main/java/io/project/app/UndertowApplication.java
index d8662be..1118c49 100644
--- a/undertow/src/main/java/io/project/app/UndertowApplication.java
+++ b/undertow/src/main/java/io/project/app/UndertowApplication.java
@@ -8,6 +8,9 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@SpringBootApplication
@ComponentScan("io.project.app")
@@ -25,4 +28,19 @@ public static void main(String[] args) {
public RestTemplate restTemplate() {
return new RestTemplate();
}
+
+
+ @Bean
+ public WebMvcConfigurer corsConfigurer() {
+ return new WebMvcConfigurer() {
+ @Override
+ public void addCorsMappings(CorsRegistry registry) {
+ registry
+ .addMapping("/**")
+ .allowedMethods(CorsConfiguration.ALL)
+ .allowedHeaders(CorsConfiguration.ALL)
+ .allowedOriginPatterns(CorsConfiguration.ALL);
+ }
+ };
+ }
}
diff --git a/webflux/nb-configuration.xml b/webflux/nb-configuration.xml
new file mode 100644
index 0000000..e0ad8dd
--- /dev/null
+++ b/webflux/nb-configuration.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ Temurin_19.0.2_7
+
+
diff --git a/webflux/nbactions.xml b/webflux/nbactions.xml
index 502c81f..782e531 100644
--- a/webflux/nbactions.xml
+++ b/webflux/nbactions.xml
@@ -9,8 +9,8 @@
spring-boot:run
- -noverify -XX:TieredStopAtLevel=1
- io.project.app.sp34.Sp34Application
+ -noverify -XX:TieredStopAtLevel=1
+ io.project.app.sp34.Sp34Application
always
@@ -23,8 +23,8 @@
spring-boot:run
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1
- io.project.app.sp34.Sp34Application
+ -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1
+ io.project.app.sp34.Sp34Application
always
true
diff --git a/webflux/pom.xml b/webflux/pom.xml
index a99dfe6..742fec8 100644
--- a/webflux/pom.xml
+++ b/webflux/pom.xml
@@ -5,7 +5,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.2.6.RELEASE
+ 3.0.3
io.project.app
@@ -15,43 +15,26 @@
webflux
- 1.8
- Hoxton.SR3
+ 19
+ 2022.0.1
io.vavr
vavr
- 0.9.2
+ 0.10.4
- io.springfox
- springfox-swagger-ui
- 3.0.0-SNAPSHOT
-
-
- io.springfox
- springfox-spring-webflux
- 3.0.0-SNAPSHOT
-
-
- io.springfox
- springfox-swagger2
- 3.0.0-SNAPSHOT
+ org.springdoc
+ springdoc-openapi-starter-webflux-ui
+ 2.0.2
org.springframework.boot
spring-boot-starter-actuator
-
- org.springframework.boot
- spring-boot-starter-cloud-connectors
-
-
+
org.springframework.boot
spring-boot-starter-webflux
@@ -77,22 +60,7 @@
lombok
true
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
-
-
- io.projectreactor
- reactor-test
- test
-
+
diff --git a/webflux/src/main/java/io/project/app/CorsConfiguration.java b/webflux/src/main/java/io/project/app/CorsConfiguration.java
new file mode 100644
index 0000000..b9f0e06
--- /dev/null
+++ b/webflux/src/main/java/io/project/app/CorsConfiguration.java
@@ -0,0 +1,40 @@
+package io.project.app;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.http.server.reactive.ServerHttpResponse;
+import org.springframework.web.cors.reactive.CorsUtils;
+import org.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.WebFilter;
+import org.springframework.web.server.WebFilterChain;
+
+/**
+ *
+ * @author armen
+ */
+@Configuration
+public class CorsConfiguration {
+
+ private static final String ALLOWED_HEADERS = "*";
+ private static final String ALLOWED_METHODS = "GET, PUT, POST, DELETE, OPTIONS, PATCH";
+ private static final String ALLOWED_ORIGIN = "*";
+ private static final String MAX_AGE = "7200";
+
+ @Bean
+ public WebFilter corsFilter() {
+ return (ServerWebExchange ctx, WebFilterChain chain) -> {
+ ServerHttpRequest request = ctx.getRequest();
+ if (CorsUtils.isCorsRequest(request)) {
+ ServerHttpResponse response = ctx.getResponse();
+ HttpHeaders headers = response.getHeaders();
+ headers.add("Access-Control-Allow-Origin", ALLOWED_ORIGIN);
+ headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS);
+ headers.add("Access-Control-Max-Age", MAX_AGE);
+ headers.add("Access-Control-Allow-Headers", ALLOWED_HEADERS);
+ }
+ return chain.filter(ctx);
+ };
+ }
+}
diff --git a/webflux/src/main/java/io/project/app/OpenApiConfiguration.java b/webflux/src/main/java/io/project/app/OpenApiConfiguration.java
new file mode 100644
index 0000000..d39234b
--- /dev/null
+++ b/webflux/src/main/java/io/project/app/OpenApiConfiguration.java
@@ -0,0 +1,19 @@
+package io.project.app;
+
+import org.springdoc.core.models.GroupedOpenApi;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class OpenApiConfiguration {
+
+ @Bean
+ public GroupedOpenApi publicApi() {
+ return GroupedOpenApi.builder()
+ .group("publicapi")
+ .packagesToScan("io.project")
+ .pathsToMatch("/api/**")
+ .build();
+ }
+
+}
diff --git a/webflux/src/main/java/io/project/app/SwaggerConfig.java b/webflux/src/main/java/io/project/app/SwaggerConfig.java
deleted file mode 100644
index bf72561..0000000
--- a/webflux/src/main/java/io/project/app/SwaggerConfig.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package io.project.app;
-
-import java.util.function.Predicate;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import springfox.documentation.builders.ApiInfoBuilder;
-import static springfox.documentation.builders.PathSelectors.regex;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.Contact;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2WebFlux;
-
-/**
- *
- * @author armenacd
- */
-@Configuration
-@EnableSwagger2WebFlux
-public class SwaggerConfig {
-
- private ApiInfo apiInfo() {
- return new ApiInfoBuilder()
- .title("WebFLux API")
- .description("From Zero to Hello!")
- .termsOfServiceUrl("http://www-03.ibm.com/software/sla/sladb.nsf/sla/bm?Open")
- .contact(new Contact("Armen Arzumanyan", "http://github.com/armdev", "armen.arzumanyan@gmail.com"))
- .license("Apache License Version 2.0")
- .licenseUrl("https://github.com/IBM-Bluemix/news-aggregator/blob/master/LICENSE")
- .version("2.0")
- .build();
- }
-
- @Bean
- public Docket api() {
- return new Docket(DocumentationType.SWAGGER_2).enable(true)
- .groupName("Reactive API")
- .apiInfo(apiInfo())
- .select()
- .paths(regex("/api.*"))
- // .paths(not(PathSelectors.regex("/actuator.*")))
- .build();
- }
-
- private static Predicate not(Predicate input) {
- return it -> !input.test(it);
- }
-}
diff --git a/webflux/src/main/java/io/project/app/services/KillerService.java b/webflux/src/main/java/io/project/app/services/KillerService.java
index 33b7626..de46ffd 100644
--- a/webflux/src/main/java/io/project/app/services/KillerService.java
+++ b/webflux/src/main/java/io/project/app/services/KillerService.java
@@ -26,7 +26,7 @@ public class KillerService {
@Autowired
private RestTemplate restTemplate;
- private List targetList = Arrays.asList("http://localhost:2020/actuator/shutdown", "http://venera:2077/actuator/shutdown",
+ private final List targetList = Arrays.asList("http://localhost:2020/actuator/shutdown", "http://venera:2077/actuator/shutdown",
"http://localhost:2021/actuator/shutdown", "http://localhost:2022/actuator/shutdown", "http://mars:8585858585/actuator/shutdown");
@Scheduled(fixedDelay = 8000)