diff --git a/apache-poi/src/main/java/com/baeldung/poi/word/WordDocument.java b/apache-poi/src/main/java/com/baeldung/poi/word/WordDocument.java index c05c323447..599da86eaa 100644 --- a/apache-poi/src/main/java/com/baeldung/poi/word/WordDocument.java +++ b/apache-poi/src/main/java/com/baeldung/poi/word/WordDocument.java @@ -1,5 +1,8 @@ package com.baeldung.poi.word; +import org.apache.poi.util.Units; +import org.apache.poi.xwpf.usermodel.*; + import java.io.FileOutputStream; import java.io.IOException; import java.net.URISyntaxException; @@ -9,13 +12,6 @@ import java.nio.file.Paths; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.poi.util.Units; -import org.apache.poi.xwpf.usermodel.ParagraphAlignment; -import org.apache.poi.xwpf.usermodel.UnderlinePatterns; -import org.apache.poi.xwpf.usermodel.XWPFDocument; -import org.apache.poi.xwpf.usermodel.XWPFParagraph; -import org.apache.poi.xwpf.usermodel.XWPFRun; - public class WordDocument { public static String logo = "logo-leaf.png"; public static String paragraph1 = "poi-word-para1.txt"; diff --git a/spring-reactor/src/main/java/com/baeldung/Application.java b/spring-reactor/src/main/java/com/baeldung/Application.java index 67f713cd83..b635a39e97 100644 --- a/spring-reactor/src/main/java/com/baeldung/Application.java +++ b/spring-reactor/src/main/java/com/baeldung/Application.java @@ -15,35 +15,34 @@ import reactor.bus.EventBus; import static reactor.bus.selector.Selectors.$; - @Configuration @EnableAutoConfiguration @ComponentScan public class Application implements CommandLineRunner { - - @Autowired - private EventBus eventBus; - - @Autowired - private NotificationConsumer notificationConsumer; - + + @Autowired + private EventBus eventBus; + + @Autowired + private NotificationConsumer notificationConsumer; + @Bean Environment env() { return Environment.initializeIfEmpty().assignErrorJournal(); } - + @Bean EventBus createEventBus(Environment env) { - return EventBus.create(env, Environment.THREAD_POOL); + return EventBus.create(env, Environment.THREAD_POOL); } - @Override - public void run(String... args) throws Exception { - eventBus.on($("notificationConsumer"), notificationConsumer); - } + @Override + public void run(String... args) throws Exception { + eventBus.on($("notificationConsumer"), notificationConsumer); + } - public static void main(String[] args){ - SpringApplication.run(Application.class, args); - } + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } } diff --git a/spring-reactor/src/main/java/com/baeldung/consumer/NotificationConsumer.java b/spring-reactor/src/main/java/com/baeldung/consumer/NotificationConsumer.java index 0d33f78477..ca6a5b4303 100644 --- a/spring-reactor/src/main/java/com/baeldung/consumer/NotificationConsumer.java +++ b/spring-reactor/src/main/java/com/baeldung/consumer/NotificationConsumer.java @@ -12,17 +12,18 @@ import reactor.fn.Consumer; @Service public class NotificationConsumer implements Consumer> { - @Autowired - private NotificationService notificationService; - - @Override - public void accept(Event notificationDataEvent) { - - NotificationData notificationData = notificationDataEvent.getData(); - try { - notificationService.initiateNotofication(notificationData); - } catch (InterruptedException e) {} - - } + @Autowired + private NotificationService notificationService; + + @Override + public void accept(Event notificationDataEvent) { + + NotificationData notificationData = notificationDataEvent.getData(); + try { + notificationService.initiateNotification(notificationData); + } catch (InterruptedException e) { + } + + } } diff --git a/spring-reactor/src/main/java/com/baeldung/controller/NotificationController.java b/spring-reactor/src/main/java/com/baeldung/controller/NotificationController.java index a6dba64bc2..87198409b5 100644 --- a/spring-reactor/src/main/java/com/baeldung/controller/NotificationController.java +++ b/spring-reactor/src/main/java/com/baeldung/controller/NotificationController.java @@ -13,25 +13,25 @@ import reactor.bus.EventBus; @Controller public class NotificationController { - - @Autowired - private EventBus eventBus; - @RequestMapping(value = "/startNotification/{param}", method = RequestMethod.GET) - public void startNotification(@PathVariable("param") String param) { - - int notificationSize = Integer.parseInt(param); - - for(int i = 0; i < notificationSize; i++) { - - NotificationData data = new NotificationData(); - data.setId(i); - - eventBus.notify("notificationConsumer",Event.wrap(data)); - - System.out.println("Notification " +i +": notification task submitted successfully"); - } - - } - + @Autowired + private EventBus eventBus; + + @RequestMapping(value = "/startNotification/{param}", method = RequestMethod.GET) + public void startNotification(@PathVariable("param") String param) { + + int notificationSize = Integer.parseInt(param); + + for (int i = 0; i < notificationSize; i++) { + + NotificationData data = new NotificationData(); + data.setId(i); + + eventBus.notify("notificationConsumer", Event.wrap(data)); + + System.out.println("Notification " + i + ": notification task submitted successfully"); + } + + } + } diff --git a/spring-reactor/src/main/java/com/baeldung/doman/NotificationData.java b/spring-reactor/src/main/java/com/baeldung/doman/NotificationData.java index e623d80887..d6d7b02949 100644 --- a/spring-reactor/src/main/java/com/baeldung/doman/NotificationData.java +++ b/spring-reactor/src/main/java/com/baeldung/doman/NotificationData.java @@ -1,35 +1,42 @@ package com.baeldung.doman; public class NotificationData { - - private long id; - private String name; - private String email; - private String mobile; - public long getId() { - return id; - } - public void setId(long id) { - this.id = id; - } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public String getEmail() { - return email; - } - public void setEmail(String email) { - this.email = email; - } - public String getMobile() { - return mobile; - } - public void setMobile(String mobile) { - this.mobile = mobile; - } + private long id; + private String name; + private String email; + private String mobile; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } } diff --git a/spring-reactor/src/main/java/com/baeldung/service/NotificationService.java b/spring-reactor/src/main/java/com/baeldung/service/NotificationService.java index 348024d8a1..f653b2162f 100644 --- a/spring-reactor/src/main/java/com/baeldung/service/NotificationService.java +++ b/spring-reactor/src/main/java/com/baeldung/service/NotificationService.java @@ -4,6 +4,6 @@ import com.baeldung.doman.NotificationData; public interface NotificationService { - public void initiateNotofication(NotificationData notificationData) throws InterruptedException; - + void initiateNotification(NotificationData notificationData) throws InterruptedException; + } diff --git a/spring-reactor/src/main/java/com/baeldung/service/impl/NotificationServiceimpl.java b/spring-reactor/src/main/java/com/baeldung/service/impl/NotificationServiceimpl.java index e5dc209384..bf37741f6a 100644 --- a/spring-reactor/src/main/java/com/baeldung/service/impl/NotificationServiceimpl.java +++ b/spring-reactor/src/main/java/com/baeldung/service/impl/NotificationServiceimpl.java @@ -7,15 +7,15 @@ import com.baeldung.service.NotificationService; @Service public class NotificationServiceimpl implements NotificationService { - - @Override - public void initiateNotofication(NotificationData notificationData) throws InterruptedException { - System.out.println("Notification service started for Notification ID: " +notificationData.getId()); - - Thread.sleep(5000); - - System.out.println("Notification service ended for Notification ID: " +notificationData.getId()); - } + @Override + public void initiateNotification(NotificationData notificationData) throws InterruptedException { + + System.out.println("Notification service started for Notification ID: " + notificationData.getId()); + + Thread.sleep(5000); + + System.out.println("Notification service ended for Notification ID: " + notificationData.getId()); + } }