File tree Expand file tree Collapse file tree
apache-poi/src/main/java/com/baeldung/poi/word
spring-reactor/src/main/java/com/baeldung Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com .baeldung .poi .word ;
22
3+ import org .apache .poi .util .Units ;
4+ import org .apache .poi .xwpf .usermodel .*;
5+
36import java .io .FileOutputStream ;
47import java .io .IOException ;
58import java .net .URISyntaxException ;
912import java .util .stream .Collectors ;
1013import java .util .stream .Stream ;
1114
12- import org .apache .poi .util .Units ;
13- import org .apache .poi .xwpf .usermodel .ParagraphAlignment ;
14- import org .apache .poi .xwpf .usermodel .UnderlinePatterns ;
15- import org .apache .poi .xwpf .usermodel .XWPFDocument ;
16- import org .apache .poi .xwpf .usermodel .XWPFParagraph ;
17- import org .apache .poi .xwpf .usermodel .XWPFRun ;
18-
1915public class WordDocument {
2016 public static String logo = "logo-leaf.png" ;
2117 public static String paragraph1 = "poi-word-para1.txt" ;
Original file line number Diff line number Diff line change 1515
1616import static reactor .bus .selector .Selectors .$ ;
1717
18-
1918@ Configuration
2019@ EnableAutoConfiguration
2120@ ComponentScan
2221public class Application implements CommandLineRunner {
23-
24- @ Autowired
25- private EventBus eventBus ;
26-
27- @ Autowired
28- private NotificationConsumer notificationConsumer ;
29-
22+
23+ @ Autowired
24+ private EventBus eventBus ;
25+
26+ @ Autowired
27+ private NotificationConsumer notificationConsumer ;
28+
3029 @ Bean
3130 Environment env () {
3231 return Environment .initializeIfEmpty ().assignErrorJournal ();
3332 }
34-
33+
3534 @ Bean
3635 EventBus createEventBus (Environment env ) {
37- return EventBus .create (env , Environment .THREAD_POOL );
36+ return EventBus .create (env , Environment .THREAD_POOL );
3837 }
3938
40- @ Override
41- public void run (String ... args ) throws Exception {
42- eventBus .on ($ ("notificationConsumer" ), notificationConsumer );
43- }
39+ @ Override
40+ public void run (String ... args ) throws Exception {
41+ eventBus .on ($ ("notificationConsumer" ), notificationConsumer );
42+ }
4443
45- public static void main (String [] args ){
46- SpringApplication .run (Application .class , args );
47- }
44+ public static void main (String [] args ) {
45+ SpringApplication .run (Application .class , args );
46+ }
4847
4948}
Original file line number Diff line number Diff line change 1212@ Service
1313public class NotificationConsumer implements Consumer <Event <NotificationData >> {
1414
15- @ Autowired
16- private NotificationService notificationService ;
17-
18- @ Override
19- public void accept (Event <NotificationData > notificationDataEvent ) {
20-
21- NotificationData notificationData = notificationDataEvent .getData ();
22- try {
23- notificationService .initiateNotofication (notificationData );
24- } catch (InterruptedException e ) {}
25-
26- }
15+ @ Autowired
16+ private NotificationService notificationService ;
17+
18+ @ Override
19+ public void accept (Event <NotificationData > notificationDataEvent ) {
20+
21+ NotificationData notificationData = notificationDataEvent .getData ();
22+ try {
23+ notificationService .initiateNotification (notificationData );
24+ } catch (InterruptedException e ) {
25+ }
26+
27+ }
2728
2829}
Original file line number Diff line number Diff line change 1313
1414@ Controller
1515public class NotificationController {
16-
17- @ Autowired
18- private EventBus eventBus ;
19-
20- @ RequestMapping (value = "/startNotification/{param}" , method = RequestMethod .GET )
21- public void startNotification (@ PathVariable ("param" ) String param ) {
22-
23- int notificationSize = Integer .parseInt (param );
24-
25- for (int i = 0 ; i < notificationSize ; i ++) {
26-
27- NotificationData data = new NotificationData ();
28- data .setId (i );
29-
30- eventBus .notify ("notificationConsumer" ,Event .wrap (data ));
31-
32- System .out .println ("Notification " +i +": notification task submitted successfully" );
33- }
34-
35- }
36-
16+
17+ @ Autowired
18+ private EventBus eventBus ;
19+
20+ @ RequestMapping (value = "/startNotification/{param}" , method = RequestMethod .GET )
21+ public void startNotification (@ PathVariable ("param" ) String param ) {
22+
23+ int notificationSize = Integer .parseInt (param );
24+
25+ for (int i = 0 ; i < notificationSize ; i ++) {
26+
27+ NotificationData data = new NotificationData ();
28+ data .setId (i );
29+
30+ eventBus .notify ("notificationConsumer" , Event .wrap (data ));
31+
32+ System .out .println ("Notification " + i + ": notification task submitted successfully" );
33+ }
34+
35+ }
36+
3737}
Original file line number Diff line number Diff line change 11package com .baeldung .doman ;
22
33public class NotificationData {
4-
5- private long id ;
6- private String name ;
7- private String email ;
8- private String mobile ;
9-
10- public long getId () {
11- return id ;
12- }
13- public void setId (long id ) {
14- this .id = id ;
15- }
16- public String getName () {
17- return name ;
18- }
19- public void setName (String name ) {
20- this .name = name ;
21- }
22- public String getEmail () {
23- return email ;
24- }
25- public void setEmail (String email ) {
26- this .email = email ;
27- }
28- public String getMobile () {
29- return mobile ;
30- }
31- public void setMobile (String mobile ) {
32- this .mobile = mobile ;
33- }
4+
5+ private long id ;
6+ private String name ;
7+ private String email ;
8+ private String mobile ;
9+
10+ public long getId () {
11+ return id ;
12+ }
13+
14+ public void setId (long id ) {
15+ this .id = id ;
16+ }
17+
18+ public String getName () {
19+ return name ;
20+ }
21+
22+ public void setName (String name ) {
23+ this .name = name ;
24+ }
25+
26+ public String getEmail () {
27+ return email ;
28+ }
29+
30+ public void setEmail (String email ) {
31+ this .email = email ;
32+ }
33+
34+ public String getMobile () {
35+ return mobile ;
36+ }
37+
38+ public void setMobile (String mobile ) {
39+ this .mobile = mobile ;
40+ }
3441
3542}
Original file line number Diff line number Diff line change 44
55public interface NotificationService {
66
7- public void initiateNotofication (NotificationData notificationData ) throws InterruptedException ;
8-
7+ void initiateNotification (NotificationData notificationData ) throws InterruptedException ;
8+
99}
Original file line number Diff line number Diff line change 77
88@ Service
99public class NotificationServiceimpl implements NotificationService {
10-
11- @ Override
12- public void initiateNotofication (NotificationData notificationData ) throws InterruptedException {
13-
14- System .out .println ("Notification service started for Notification ID: " +notificationData .getId ());
15-
16- Thread .sleep (5000 );
17-
18- System .out .println ("Notification service ended for Notification ID: " +notificationData .getId ());
19- }
10+
11+ @ Override
12+ public void initiateNotification (NotificationData notificationData ) throws InterruptedException {
13+
14+ System .out .println ("Notification service started for Notification ID: " + notificationData .getId ());
15+
16+ Thread .sleep (5000 );
17+
18+ System .out .println ("Notification service ended for Notification ID: " + notificationData .getId ());
19+ }
2020
2121}
You can’t perform that action at this time.
0 commit comments