From 0da695fba58b4da8e3a6fa60b073c713b5fbc746 Mon Sep 17 00:00:00 2001 From: Erdem Date: Wed, 25 Apr 2018 00:59:56 +0300 Subject: [PATCH 1/7] tutorial real time event streaming with spring webflux --- .../com/baeldung/reactive/webflux/Event.java | 13 ++++++ .../webflux/EventStreamController.java | 20 +++++++++ .../webflux/WebfluxDemoApplication.java | 12 +++++ .../static/webflux/client-event-stream.html | 45 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/Event.java create mode 100644 spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java create mode 100644 spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/WebfluxDemoApplication.java create mode 100644 spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/Event.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/Event.java new file mode 100644 index 0000000000..03e80e915e --- /dev/null +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/Event.java @@ -0,0 +1,13 @@ +package com.baeldung.reactive.webflux; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class Event { + + private Long id; + private String body; + +} diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java new file mode 100644 index 0000000000..5a88f6823e --- /dev/null +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java @@ -0,0 +1,20 @@ +package com.baeldung.reactive.webflux; + +import java.time.Duration; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import reactor.core.publisher.Flux; + +@RestController +public class EventStreamController { + + @GetMapping(value = "/events", produces = MediaType.TEXT_EVENT_STREAM_VALUE) + public Flux getMessages() { + return Flux.interval(Duration.ofMillis(1000)) + .map(tick -> new Event(tick, "This is Message #" + tick)); + } + +} diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/WebfluxDemoApplication.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/WebfluxDemoApplication.java new file mode 100644 index 0000000000..70cad0ad22 --- /dev/null +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/WebfluxDemoApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.reactive.webflux; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class WebfluxDemoApplication { + + public static void main(String[] args) { + SpringApplication.run(WebfluxDemoApplication.class, args); + } +} diff --git a/spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html b/spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html new file mode 100644 index 0000000000..d7631f9217 --- /dev/null +++ b/spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html @@ -0,0 +1,45 @@ + + + + + Baeldung: Spring 5 Reactive Webflux - real time event streaming + + + + + + +

Events streamed...

+ + + + + + + + + +
Event IdEvent Body
+ + + + + \ No newline at end of file From 6cbe92600d3da221a3b1a1324f953898d7ef16b7 Mon Sep 17 00:00:00 2001 From: Erdem Date: Wed, 25 Apr 2018 01:37:08 +0300 Subject: [PATCH 2/7] fix some type and change spring boot version to 2.0.1 from 2.0.0 --- spring-5-reactive/pom.xml | 2 +- .../baeldung/reactive/webflux/EventStreamController.java | 4 ++-- .../resources/static/webflux/client-event-stream.html | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-5-reactive/pom.xml b/spring-5-reactive/pom.xml index 96378c60de..324fb13dd2 100644 --- a/spring-5-reactive/pom.xml +++ b/spring-5-reactive/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.RELEASE + 2.0.1.RELEASE diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java index 5a88f6823e..f3d10437e2 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java @@ -12,9 +12,9 @@ import reactor.core.publisher.Flux; public class EventStreamController { @GetMapping(value = "/events", produces = MediaType.TEXT_EVENT_STREAM_VALUE) - public Flux getMessages() { + public Flux getEvents() { return Flux.interval(Duration.ofMillis(1000)) - .map(tick -> new Event(tick, "This is Message #" + tick)); + .map(tick -> new Event(tick, "This is Event #" + tick)); } } diff --git a/spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html b/spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html index d7631f9217..e44cbf0746 100644 --- a/spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html +++ b/spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html @@ -32,12 +32,12 @@ var data = JSON.parse(event.data); var table = document.getElementById("events-table"); var row = table.insertRow(1); - var cell1 = row.insertCell(0); - var cell2 = row.insertCell(1); + var cellId = row.insertCell(0); + var cellBody = row.insertCell(1); - cell1.innerHTML = '' + data.id + ''; - cell2.innerHTML = '' + data.body + ''; + cellId.innerHTML = '' + data.id + ''; + cellBody.innerHTML = '' + data.body + ''; } From ef481d19ee865911ed5ec5c9423c79d9242e4631 Mon Sep 17 00:00:00 2001 From: Erdem Date: Thu, 3 May 2018 22:02:16 +0300 Subject: [PATCH 3/7] BAEL-1746 added property editor implementation --- .../baeldung/propertyeditor/CreditCard.java | 41 +++++++++++++++++++ .../propertyeditor/CreditCardEditor.java | 39 ++++++++++++++++++ .../CreditCardRestController.java | 17 ++++++++ .../PropertyEditorApplication.java | 12 ++++++ .../propertyeditor/CreditCardEditorTest.java | 41 +++++++++++++++++++ 5 files changed, 150 insertions(+) create mode 100644 spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCard.java create mode 100644 spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardEditor.java create mode 100644 spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardRestController.java create mode 100644 spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java create mode 100644 spring-rest/src/test/java/com/baeldung/propertyeditor/CreditCardEditorTest.java diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCard.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCard.java new file mode 100644 index 0000000000..2b1fbb9b6c --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCard.java @@ -0,0 +1,41 @@ +package com.baeldung.propertyeditor; + +public class CreditCard { + + private String rawCardNumber; + + private Integer bankIdNo; + + private Integer accountNo; + + private Integer checkCode; + + public String getRawCardNumber() { + return rawCardNumber; + } + public void setRawCardNumber(String rawCardNumber) { + this.rawCardNumber = rawCardNumber; + } + + public Integer getBankIdNo() { + return bankIdNo; + } + public void setBankIdNo(Integer bankIdNo) { + this.bankIdNo = bankIdNo; + } + + public Integer getAccountNo() { + return accountNo; + } + public void setAccountNo(Integer accountNo) { + this.accountNo = accountNo; + } + + public Integer getCheckCode() { + return checkCode; + } + public void setCheckCode(Integer checkCode) { + this.checkCode = checkCode; + } + +} diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardEditor.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardEditor.java new file mode 100644 index 0000000000..4b1374a76a --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardEditor.java @@ -0,0 +1,39 @@ +package com.baeldung.propertyeditor; + +import java.beans.PropertyEditorSupport; + +import org.springframework.util.StringUtils; + +public class CreditCardEditor extends PropertyEditorSupport { + + @Override + public String getAsText() { + CreditCard creditCard = (CreditCard) getValue(); + + return creditCard == null ? "" : creditCard.getRawCardNumber(); + } + + @Override + public void setAsText(String text) throws IllegalArgumentException { + if (StringUtils.isEmpty(text)) { + setValue(null); + } else { + CreditCard creditCard = new CreditCard(); + creditCard.setRawCardNumber(text); + + String cardNo = text.replaceAll("-", ""); + if (cardNo.length() != 16) + throw new IllegalArgumentException("Credit card format should be xxxx-xxxx-xxxx-xxxx"); + + try { + creditCard.setBankIdNo( Integer.valueOf(cardNo.substring(0, 6)) ); + creditCard.setAccountNo( Integer.valueOf(cardNo.substring(6, cardNo.length() - 1)) ); + creditCard.setCheckCode( Integer.valueOf(cardNo.substring(cardNo.length() - 1)) ); + } catch (NumberFormatException nfe) { + throw new IllegalArgumentException(nfe); + } + + setValue(creditCard); + } + } +} diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardRestController.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardRestController.java new file mode 100644 index 0000000000..bf8e0586f8 --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardRestController.java @@ -0,0 +1,17 @@ +package com.baeldung.propertyeditor; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping(value = "/credit-card") +public class CreditCardRestController { + + @GetMapping(value = "/parse/{card-no}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + public CreditCard parseCreditCardNumber(@PathVariable("card-no") CreditCard creditCard) { + return creditCard; + } +} diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java new file mode 100644 index 0000000000..b0d75cd072 --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.propertyeditor; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class PropertyEditorApplication { + + public static void main(String[] args) { + SpringApplication.run(PropertyEditorApplication.class, args); + } +} diff --git a/spring-rest/src/test/java/com/baeldung/propertyeditor/CreditCardEditorTest.java b/spring-rest/src/test/java/com/baeldung/propertyeditor/CreditCardEditorTest.java new file mode 100644 index 0000000000..b7da905f13 --- /dev/null +++ b/spring-rest/src/test/java/com/baeldung/propertyeditor/CreditCardEditorTest.java @@ -0,0 +1,41 @@ +package com.baeldung.propertyeditor; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class CreditCardEditorTest { + + private CreditCardEditor creditCardEditor; + + @Before + public void setup() { + creditCardEditor = new CreditCardEditor(); + } + + @Test(expected=IllegalArgumentException.class) + public void whenInvalidCardNoWithLessDigits_thenThrowsException() { + creditCardEditor.setAsText("123-123-123-123"); + } + + @Test(expected=IllegalArgumentException.class) + public void whenInvalidCardNoWithNonDigits_thenThrowsException() { + creditCardEditor.setAsText("1234-1234-xxxx-yyyy"); + } + + @Test + public void whenCardNoWithNonDigits_parseCreditCard() { + creditCardEditor.setAsText("1234-5678-9123-4560"); + + CreditCard creditCard = (CreditCard) creditCardEditor.getValue(); + Assert.assertNotNull(creditCard); + + Assert.assertEquals(123456, creditCard.getBankIdNo().intValue()); + Assert.assertEquals(789123456, creditCard.getAccountNo().intValue()); + Assert.assertEquals(0, creditCard.getCheckCode().intValue()); + } + +} From 043f6bade7aea7004907e2495b945b23dd7c9381 Mon Sep 17 00:00:00 2001 From: Erdem Date: Thu, 3 May 2018 23:27:12 +0300 Subject: [PATCH 4/7] BAEL-1746 added custom property editor implementation --- .../CreditCardRestController.java | 17 ---------- .../PropertyEditorApplication.java | 6 ++-- .../PropertyEditorRestController.java | 34 +++++++++++++++++++ .../{ => creditcard}/CreditCard.java | 2 +- .../{ => creditcard}/CreditCardEditor.java | 2 +- .../editor/CustomExoticTypeEditor.java | 23 +++++++++++++ .../exotictype/model/ExoticType.java | 14 ++++++++ .../src/main/resources/application.properties | 2 +- .../CreditCardEditorTest.java | 5 ++- 9 files changed, 81 insertions(+), 24 deletions(-) delete mode 100644 spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardRestController.java create mode 100644 spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java rename spring-rest/src/main/java/com/baeldung/propertyeditor/{ => creditcard}/CreditCard.java (94%) rename spring-rest/src/main/java/com/baeldung/propertyeditor/{ => creditcard}/CreditCardEditor.java (96%) create mode 100644 spring-rest/src/main/java/com/baeldung/propertyeditor/exotictype/editor/CustomExoticTypeEditor.java create mode 100644 spring-rest/src/main/java/com/baeldung/propertyeditor/exotictype/model/ExoticType.java rename spring-rest/src/test/java/com/baeldung/propertyeditor/{ => creditcard}/CreditCardEditorTest.java (88%) diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardRestController.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardRestController.java deleted file mode 100644 index bf8e0586f8..0000000000 --- a/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardRestController.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.propertyeditor; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping(value = "/credit-card") -public class CreditCardRestController { - - @GetMapping(value = "/parse/{card-no}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public CreditCard parseCreditCardNumber(@PathVariable("card-no") CreditCard creditCard) { - return creditCard; - } -} diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java index b0d75cd072..f98648c6b2 100644 --- a/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java +++ b/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java @@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class PropertyEditorApplication { - public static void main(String[] args) { - SpringApplication.run(PropertyEditorApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(PropertyEditorApplication.class, args); + } } diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java new file mode 100644 index 0000000000..24f1b33471 --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java @@ -0,0 +1,34 @@ +package com.baeldung.propertyeditor; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.propertyeditor.creditcard.CreditCard; +import com.baeldung.propertyeditor.exotictype.editor.CustomExoticTypeEditor; +import com.baeldung.propertyeditor.exotictype.model.ExoticType; + +@RestController +@RequestMapping(value = "/property-editor") +public class PropertyEditorRestController { + + @GetMapping(value = "/credit-card/{card-no}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + public CreditCard parseCreditCardNumber(@PathVariable("card-no") CreditCard creditCard) { + return creditCard; + } + + @GetMapping(value = "/exotic-type/{value}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + public ExoticType parseCreditCardNumber(@PathVariable("value") ExoticType exoticType) { + return exoticType; + } + + @InitBinder + public void initBinder(WebDataBinder binder) { + binder.registerCustomEditor(ExoticType.class, new CustomExoticTypeEditor()); + } + +} diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCard.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCard.java similarity index 94% rename from spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCard.java rename to spring-rest/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCard.java index 2b1fbb9b6c..f3adfb5d9f 100644 --- a/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCard.java +++ b/spring-rest/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCard.java @@ -1,4 +1,4 @@ -package com.baeldung.propertyeditor; +package com.baeldung.propertyeditor.creditcard; public class CreditCard { diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardEditor.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCardEditor.java similarity index 96% rename from spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardEditor.java rename to spring-rest/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCardEditor.java index 4b1374a76a..d413afee85 100644 --- a/spring-rest/src/main/java/com/baeldung/propertyeditor/CreditCardEditor.java +++ b/spring-rest/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCardEditor.java @@ -1,4 +1,4 @@ -package com.baeldung.propertyeditor; +package com.baeldung.propertyeditor.creditcard; import java.beans.PropertyEditorSupport; diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/exotictype/editor/CustomExoticTypeEditor.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/exotictype/editor/CustomExoticTypeEditor.java new file mode 100644 index 0000000000..08dbceae3d --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/propertyeditor/exotictype/editor/CustomExoticTypeEditor.java @@ -0,0 +1,23 @@ +package com.baeldung.propertyeditor.exotictype.editor; + +import java.beans.PropertyEditorSupport; + +import com.baeldung.propertyeditor.exotictype.model.ExoticType; + +public class CustomExoticTypeEditor extends PropertyEditorSupport { + + @Override + public String getAsText() { + ExoticType exoticType = (ExoticType) getValue(); + + return exoticType == null ? "" : exoticType.getName(); + } + + @Override + public void setAsText(String text) throws IllegalArgumentException { + ExoticType exoticType = new ExoticType(); + exoticType.setName(text.toUpperCase()); + + setValue(exoticType); + } +} diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/exotictype/model/ExoticType.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/exotictype/model/ExoticType.java new file mode 100644 index 0000000000..95ba95643d --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/propertyeditor/exotictype/model/ExoticType.java @@ -0,0 +1,14 @@ +package com.baeldung.propertyeditor.exotictype.model; + +public class ExoticType { + + private String name; + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + +} diff --git a/spring-rest/src/main/resources/application.properties b/spring-rest/src/main/resources/application.properties index 300589f561..c4722f3c36 100644 --- a/spring-rest/src/main/resources/application.properties +++ b/spring-rest/src/main/resources/application.properties @@ -1,2 +1,2 @@ -server.port= 8082 +server.port= 8080 server.context-path=/spring-rest \ No newline at end of file diff --git a/spring-rest/src/test/java/com/baeldung/propertyeditor/CreditCardEditorTest.java b/spring-rest/src/test/java/com/baeldung/propertyeditor/creditcard/CreditCardEditorTest.java similarity index 88% rename from spring-rest/src/test/java/com/baeldung/propertyeditor/CreditCardEditorTest.java rename to spring-rest/src/test/java/com/baeldung/propertyeditor/creditcard/CreditCardEditorTest.java index b7da905f13..e87adbc712 100644 --- a/spring-rest/src/test/java/com/baeldung/propertyeditor/CreditCardEditorTest.java +++ b/spring-rest/src/test/java/com/baeldung/propertyeditor/creditcard/CreditCardEditorTest.java @@ -1,4 +1,4 @@ -package com.baeldung.propertyeditor; +package com.baeldung.propertyeditor.creditcard; import org.junit.Assert; import org.junit.Before; @@ -6,6 +6,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; +import com.baeldung.propertyeditor.creditcard.CreditCard; +import com.baeldung.propertyeditor.creditcard.CreditCardEditor; + @RunWith(MockitoJUnitRunner.class) public class CreditCardEditorTest { From 1fe62a811cd311c2fd1c5153114dd090cba6e473 Mon Sep 17 00:00:00 2001 From: Erdem Date: Fri, 4 May 2018 00:26:37 +0300 Subject: [PATCH 5/7] BAEL-1746 added custom property editor implementation --- .../propertyeditor/PropertyEditorRestController.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java b/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java index 24f1b33471..02edc96cf6 100644 --- a/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java +++ b/spring-rest/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java @@ -16,13 +16,15 @@ import com.baeldung.propertyeditor.exotictype.model.ExoticType; @RequestMapping(value = "/property-editor") public class PropertyEditorRestController { - @GetMapping(value = "/credit-card/{card-no}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @GetMapping(value = "/credit-card/{card-no}", + produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public CreditCard parseCreditCardNumber(@PathVariable("card-no") CreditCard creditCard) { return creditCard; } - @GetMapping(value = "/exotic-type/{value}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public ExoticType parseCreditCardNumber(@PathVariable("value") ExoticType exoticType) { + @GetMapping(value = "/exotic-type/{value}", + produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + public ExoticType parseExoticType(@PathVariable("value") ExoticType exoticType) { return exoticType; } From c8b44cc141a0db743e52f19c87995b349e65ef11 Mon Sep 17 00:00:00 2001 From: Erdem Date: Fri, 4 May 2018 00:53:01 +0300 Subject: [PATCH 6/7] remove weblux files --- .../com/baeldung/reactive/webflux/Event.java | 13 ------ .../webflux/EventStreamController.java | 20 --------- .../webflux/WebfluxDemoApplication.java | 12 ----- .../static/webflux/client-event-stream.html | 45 ------------------- 4 files changed, 90 deletions(-) delete mode 100644 spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/Event.java delete mode 100644 spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java delete mode 100644 spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/WebfluxDemoApplication.java delete mode 100644 spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/Event.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/Event.java deleted file mode 100644 index 03e80e915e..0000000000 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/Event.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.reactive.webflux; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class Event { - - private Long id; - private String body; - -} diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java deleted file mode 100644 index f3d10437e2..0000000000 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/EventStreamController.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.reactive.webflux; - -import java.time.Duration; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import reactor.core.publisher.Flux; - -@RestController -public class EventStreamController { - - @GetMapping(value = "/events", produces = MediaType.TEXT_EVENT_STREAM_VALUE) - public Flux getEvents() { - return Flux.interval(Duration.ofMillis(1000)) - .map(tick -> new Event(tick, "This is Event #" + tick)); - } - -} diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/WebfluxDemoApplication.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/WebfluxDemoApplication.java deleted file mode 100644 index 70cad0ad22..0000000000 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/webflux/WebfluxDemoApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.baeldung.reactive.webflux; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class WebfluxDemoApplication { - - public static void main(String[] args) { - SpringApplication.run(WebfluxDemoApplication.class, args); - } -} diff --git a/spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html b/spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html deleted file mode 100644 index e44cbf0746..0000000000 --- a/spring-5-reactive/src/main/resources/static/webflux/client-event-stream.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - Baeldung: Spring 5 Reactive Webflux - real time event streaming - - - - - - -

Events streamed...

- - - - - - - - - -
Event IdEvent Body
- - - - - \ No newline at end of file From 8d8010cd2e36f51115f4705127f6dd33fa43ac31 Mon Sep 17 00:00:00 2001 From: Erdem Date: Fri, 4 May 2018 00:53:57 +0300 Subject: [PATCH 7/7] remove weblux files --- spring-5-reactive/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-5-reactive/pom.xml b/spring-5-reactive/pom.xml index 324fb13dd2..96378c60de 100644 --- a/spring-5-reactive/pom.xml +++ b/spring-5-reactive/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.1.RELEASE + 2.0.0.RELEASE