Tan115 commited on
Commit
f6d5eb9
·
verified ·
1 Parent(s): 3711998

Clean up: Remove specific course folders (delete folder '83 - ===== EXAM Spring Core & Spring MVC - Online Shop =====')

Browse files
83 - ===== EXAM Spring Core & Spring MVC - Online Shop =====/001 EXAM Spring Core & Spring MVC.mp4 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:761cb738afd76c0625c25970c1579d601560f1946b91c1d6b07dcb0dbed846e2
3
- size 758307884
 
 
 
 
83 - ===== EXAM Spring Core & Spring MVC - Online Shop =====/001 EXAM Spring Core & Spring MVC_en.srt DELETED
@@ -1,1852 +0,0 @@
1
- 1
2
- 00:00:06,000 --> 00:00:06,000
3
- Hello, Tim.
4
-
5
- 2
6
- 00:00:06,000 --> 00:00:11,000
7
- By this moment in our course, we have learned a lot about Spring Corps and Spring.
8
-
9
- 3
10
- 00:00:11,000 --> 00:00:15,000
11
- And we see now this time to practice your skills.
12
-
13
- 4
14
- 00:00:15,000 --> 00:00:22,000
15
- And I spent a lot of time in order to prepare for your special production related tasks.
16
-
17
- 5
18
- 00:00:22,000 --> 00:00:29,000
19
- Uses a whole course Java from zero to first job together with all my students who develop online shop
20
-
21
- 6
22
- 00:00:29,000 --> 00:00:31,000
23
- web application.
24
-
25
- 7
26
- 00:00:31,000 --> 00:00:37,000
27
- Usually, after learning each new topic, we apply our knowledge to improve our solution.
28
-
29
- 8
30
- 00:00:37,000 --> 00:00:44,000
31
- Today we are going to make the same scene in order to practice the skills and knowledge that we get
32
-
33
- 9
34
- 00:00:44,000 --> 00:00:52,000
35
- After learning Spring Corps and Spring and we see topics on the screen, you can see the task description.
36
-
37
- 10
38
- 00:00:52,000 --> 00:00:57,000
39
- You can find the reference to this document in attachments to the video.
40
-
41
- 11
42
- 00:00:57,000 --> 00:01:04,000
43
- Let me describe the task and explain to you what is expected from you during this task.
44
-
45
- 12
46
- 00:01:05,000 --> 00:01:14,000
47
- So the first thing that you have to do to a complete project of online shop that is completely working
48
-
49
- 13
50
- 00:01:14,000 --> 00:01:15,000
51
- Web application.
52
-
53
- 14
54
- 00:01:15,000 --> 00:01:19,000
55
- It just doesn't have spring integration yet.
56
-
57
- 15
58
- 00:01:20,000 --> 00:01:24,000
59
- We will take this solution and will improve it.
60
-
61
- 16
62
- 00:01:24,000 --> 00:01:31,000
63
- I believe that this is just a great task for all my students because when you refactor the code within
64
-
65
- 17
66
- 00:01:31,000 --> 00:01:38,000
67
- the service and you integrate spring core and spring and we see it is easier for you to build analogy
68
-
69
- 18
70
- 00:01:38,000 --> 00:01:46,000
71
- between servlet and spring and we see thus it is easier for you to understand how all these things work.
72
-
73
- 19
74
- 00:01:46,000 --> 00:01:53,000
75
- That's why I believe that this is just an amazing exercise for students after completing it using the
76
-
77
- 20
78
- 00:01:53,000 --> 00:01:59,000
79
- templates provided, I give you the guarantees that you would understand Spring Corps and Spring and
80
-
81
- 21
82
- 00:01:59,000 --> 00:02:02,000
83
- you see like never before.
84
-
85
- 22
86
- 00:02:02,000 --> 00:02:04,000
87
- Let's continue.
88
-
89
- 23
90
- 00:02:04,000 --> 00:02:08,000
91
- As you can see, this is Maimon Memorial project.
92
-
93
- 24
94
- 00:02:08,000 --> 00:02:11,000
95
- The second step is kind of generic one.
96
-
97
- 25
98
- 00:02:11,000 --> 00:02:17,000
99
- Just make sure that you can run the project and that it can be started easily.
100
-
101
- 26
102
- 00:02:17,000 --> 00:02:23,000
103
- Please follow the steps from the file in order to configure the database on your local environment.
104
-
105
- 27
106
- 00:02:24,000 --> 00:02:25,000
107
- The next step.
108
-
109
- 28
110
- 00:02:25,000 --> 00:02:28,000
111
- Understand how application works.
112
-
113
- 29
114
- 00:02:28,000 --> 00:02:36,000
115
- Navigate through the application on the stand and scenarios just in case I left here as a reference
116
-
117
- 30
118
- 00:02:36,000 --> 00:02:39,000
119
- to the business requirements for the application.
120
-
121
- 31
122
- 00:02:39,000 --> 00:02:41,000
123
- Feel free to read through them.
124
-
125
- 32
126
- 00:02:42,000 --> 00:02:48,000
127
- Knowing the way how our online shop should behave, it will be easier for you to understand what should
128
-
129
- 33
130
- 00:02:48,000 --> 00:02:51,000
131
- be fixed and how application should work.
132
-
133
- 34
134
- 00:02:51,000 --> 00:03:00,000
135
- After factoring and finally the poor piece of our exam task, we have to integrate spring or spring.
136
-
137
- 35
138
- 00:03:00,000 --> 00:03:06,000
139
- Can we see into this project what can be considered as integration of screen and screen?
140
-
141
- 36
142
- 00:03:06,000 --> 00:03:12,000
143
- We see we need to be specific in the definition of the success criteria so far.
144
-
145
- 37
146
- 00:03:12,000 --> 00:03:15,000
147
- This project uses silhouettes technology.
148
-
149
- 38
150
- 00:03:15,000 --> 00:03:21,000
151
- You need to make a revision of the project and make appropriate changes.
152
-
153
- 39
154
- 00:03:21,000 --> 00:03:24,000
155
- First of all, we need to define spring context.
156
-
157
- 40
158
- 00:03:24,000 --> 00:03:28,000
159
- It is up to you what type of configuration you would like to use.
160
-
161
- 41
162
- 00:03:28,000 --> 00:03:31,000
163
- Annotation based or XML based.
164
-
165
- 42
166
- 00:03:31,000 --> 00:03:38,000
167
- My course will use different types of configuration and you already understand that this is a matter
168
-
169
- 43
170
- 00:03:38,000 --> 00:03:41,000
171
- of style rather than some strict rules here.
172
-
173
- 44
174
- 00:03:41,000 --> 00:03:47,000
175
- One or another approach so describes a configuration.
176
-
177
- 45
178
- 00:03:47,000 --> 00:03:49,000
179
- Define the spring beans.
180
-
181
- 46
182
- 00:03:49,000 --> 00:03:57,000
183
- Configure other beans using dependency injection with regards to the screen can be see you have to configure
184
-
185
- 47
186
- 00:03:57,000 --> 00:03:58,000
187
- dispatch server.
188
-
189
- 48
190
- 00:03:59,000 --> 00:04:04,000
191
- Also view all the existence of lets and configure request mappings.
192
-
193
- 49
194
- 00:04:04,000 --> 00:04:08,000
195
- Feel free to refactor the code as you feel needed.
196
-
197
- 50
198
- 00:04:09,000 --> 00:04:15,000
199
- Take advantage of using the request forum and modal attribute integrate hibernate validation of model
200
-
201
- 51
202
- 00:04:15,000 --> 00:04:21,000
203
- attributes, integrate properties and use property source for the application.
204
-
205
- 52
206
- 00:04:21,000 --> 00:04:28,000
207
- Also, do not forget about implementation of the localization and internationalization.
208
-
209
- 53
210
- 00:04:28,000 --> 00:04:36,000
211
- The main success criteria is that application is still working as expected and all scenarios work.
212
-
213
- 54
214
- 00:04:36,000 --> 00:04:37,000
215
- End to end.
216
-
217
- 55
218
- 00:04:37,000 --> 00:04:42,000
219
- After you're done with integration of Sprint core and speed.
220
-
221
- 56
222
- 00:04:42,000 --> 00:04:42,000
223
- And we see.
224
-
225
- 57
226
- 00:04:43,000 --> 00:04:44,000
227
- Is that clear?
228
-
229
- 58
230
- 00:04:45,000 --> 00:04:48,000
231
- In case you have any questions regarding task.
232
-
233
- 59
234
- 00:04:48,000 --> 00:04:53,000
235
- Feel free to post your questions below this video and I will be happy to answer.
236
-
237
- 60
238
- 00:04:54,000 --> 00:05:01,000
239
- Now I recommend you to put on pause the video and try to implement the task by yourself.
240
-
241
- 61
242
- 00:05:02,000 --> 00:05:09,000
243
- Feel free to use examples from the previous lessons and remember in this task you don't leave any signals.
244
-
245
- 62
246
- 00:05:09,000 --> 00:05:12,000
247
- What we do them in previous lessons.
248
-
249
- 63
250
- 00:05:12,000 --> 00:05:18,000
251
- So the information and the knowledge you gained from the previous lessons should be enough in order
252
-
253
- 64
254
- 00:05:18,000 --> 00:05:20,000
255
- to complete this task.
256
-
257
- 65
258
- 00:05:21,000 --> 00:05:29,000
259
- Once you try to implement the solution, then proceed with this video because right now I'm going to
260
-
261
- 66
262
- 00:05:29,000 --> 00:05:35,000
263
- share with you my solution and give my comments as we go over it.
264
-
265
- 67
266
- 00:05:35,000 --> 00:05:42,000
267
- By the way, here you can find the reference to the repository with the solution and reference to the
268
-
269
- 68
270
- 00:05:42,000 --> 00:05:42,000
271
- commit.
272
-
273
- 69
274
- 00:05:43,000 --> 00:05:44,000
275
- It contains the difference.
276
-
277
- 70
278
- 00:05:45,000 --> 00:05:52,000
279
- Probably it would be interesting for you to go over the changes only and understand what has been changed
280
-
281
- 71
282
- 00:05:52,000 --> 00:05:54,000
283
- in competition within it.
284
-
285
- 72
286
- 00:05:54,000 --> 00:05:55,000
287
- Commit.
288
-
289
- 73
290
- 00:05:56,000 --> 00:06:01,000
291
- Let me now start sharing the source code and walk you through my solution.
292
-
293
- 74
294
- 00:06:01,000 --> 00:06:09,000
295
- So the first thing that I did, I adjusted for maximum file to include required dependencies.
296
-
297
- 75
298
- 00:06:09,000 --> 00:06:18,000
299
- We have maximal files on different levels because we have multi module project on the global level.
300
-
301
- 76
302
- 00:06:18,000 --> 00:06:27,000
303
- I added spring core spring beans and spring context dependencies in the form XML of persistence module.
304
-
305
- 77
306
- 00:06:27,000 --> 00:06:36,000
307
- I substituted Jakarta persistence API with Java x Persistence API because as you remember, in order
308
-
309
- 78
310
- 00:06:36,000 --> 00:06:42,000
311
- to use spring, we need to use Java API instead of Jakarta.
312
-
313
- 79
314
- 00:06:43,000 --> 00:06:48,000
315
- Please don't forget to update hibernate core version as well.
316
-
317
- 80
318
- 00:06:48,000 --> 00:06:52,000
319
- Again, you need to use compatible version with Xerox API.
320
-
321
- 81
322
- 00:06:53,000 --> 00:06:55,000
323
- The latest Hibernate core versions.
324
-
325
- 82
326
- 00:06:55,000 --> 00:07:02,000
327
- It is compatible with Java API is 5.6. 14 final.
328
-
329
- 83
330
- 00:07:02,000 --> 00:07:11,000
331
- Also, I added Hibernate validator dependency and inside the web module I added sprint and C dependency.
332
-
333
- 84
334
- 00:07:11,000 --> 00:07:18,000
335
- Also, I removed Jakarta API dependency and added Java servlet dependency stat.
336
-
337
- 85
338
- 00:07:18,000 --> 00:07:28,000
339
- I remove the Jakarta annotation API and edit Java annotation API instead and also I edit Java, GCP
340
-
341
- 86
342
- 00:07:28,000 --> 00:07:30,000
343
- API and Java servlet.
344
-
345
- 87
346
- 00:07:30,000 --> 00:07:32,000
347
- JSP dependencies.
348
-
349
- 88
350
- 00:07:33,000 --> 00:07:35,000
351
- Let's start now from the core module.
352
-
353
- 89
354
- 00:07:35,000 --> 00:07:38,000
355
- I open facades package.
356
-
357
- 90
358
- 00:07:38,000 --> 00:07:43,000
359
- I put service annotation above the each implementation of required facade.
360
-
361
- 91
362
- 00:07:44,000 --> 00:07:52,000
363
- Remember, you have to put annotation above the complete plus, but not above the interface because
364
-
365
- 92
366
- 00:07:52,000 --> 00:07:57,000
367
- spring needs some classes that will allow it to create object.
368
-
369
- 93
370
- 00:07:57,000 --> 00:08:01,000
371
- If you remember I implemented singleton component here.
372
-
373
- 94
374
- 00:08:02,000 --> 00:08:09,000
375
- And now we don't need it because we are going to have spring container who will manage lifecycle of
376
-
377
- 95
378
- 00:08:09,000 --> 00:08:10,000
379
- our builds.
380
-
381
- 96
382
- 00:08:11,000 --> 00:08:19,000
383
- That's why we can do small refactor here and remove all the code as it was responsible for single component
384
-
385
- 97
386
- 00:08:19,000 --> 00:08:20,000
387
- implementation.
388
-
389
- 98
390
- 00:08:21,000 --> 00:08:23,000
391
- When you will check the difference.
392
-
393
- 99
394
- 00:08:23,000 --> 00:08:23,000
395
- Indeed.
396
-
397
- 100
398
- 00:08:23,000 --> 00:08:31,000
399
- You will find that I removed static field private constructor and static method here that instantiate
400
-
401
- 101
402
- 00:08:31,000 --> 00:08:33,000
403
- an instance of this type.
404
-
405
- 102
406
- 00:08:34,000 --> 00:08:41,000
407
- Also I added out-of-order annotation in order to inject the beans into the properties in this class.
408
-
409
- 103
410
- 00:08:42,000 --> 00:08:49,000
411
- Since I am going to use spring, I don't use manually to instantiate objects, I need just to configure
412
-
413
- 104
414
- 00:08:49,000 --> 00:08:54,000
415
- the dependencies and let spring to manage all the required injections.
416
-
417
- 105
418
- 00:08:55,000 --> 00:09:00,000
419
- I did the similar refactoring in all other facade classes implementations.
420
-
421
- 106
422
- 00:09:01,000 --> 00:09:02,000
423
- Let's move on.
424
-
425
- 107
426
- 00:09:02,000 --> 00:09:07,000
427
- The same thing I did was the default mail sender.
428
-
429
- 108
430
- 00:09:07,000 --> 00:09:10,000
431
- I marked it with service annotation.
432
-
433
- 109
434
- 00:09:11,000 --> 00:09:15,000
435
- The next package in our list here is services annotation.
436
-
437
- 110
438
- 00:09:16,000 --> 00:09:24,000
439
- We need to do the similar exercise more classes with service annotation and configure dependency injection
440
-
441
- 111
442
- 00:09:24,000 --> 00:09:26,000
443
- where this will be needed.
444
-
445
- 112
446
- 00:09:27,000 --> 00:09:33,000
447
- Basically, those are all adjustments that we need to do in the core module.
448
-
449
- 113
450
- 00:09:33,000 --> 00:09:38,000
451
- Let's proceed with the persistence module in the persistence module.
452
-
453
- 114
454
- 00:09:38,000 --> 00:09:45,000
455
- We need to make the similar exercise, but instead of service annotation I'm going to put repository
456
-
457
- 115
458
- 00:09:45,000 --> 00:09:46,000
459
- annotation.
460
-
461
- 116
462
- 00:09:46,000 --> 00:09:54,000
463
- I will update all the implementations that I started with the GP because in scope of this exam we're
464
-
465
- 117
466
- 00:09:54,000 --> 00:09:56,000
467
- going to use GP for persistence.
468
-
469
- 118
470
- 00:09:56,000 --> 00:10:04,000
471
- Later, a little bit later in all the lessons, we're going to learn to speak data separately and we'll
472
-
473
- 119
474
- 00:10:04,000 --> 00:10:06,000
475
- update this too.
476
-
477
- 120
478
- 00:10:06,000 --> 00:10:12,000
479
- Also, we had my SQL JDBC implementations of our interfaces.
480
-
481
- 121
482
- 00:10:12,000 --> 00:10:17,000
483
- I decided to delete them in order to not keep the code that we don't use anymore.
484
-
485
- 122
486
- 00:10:18,000 --> 00:10:28,000
487
- The next released web DX tool package lets mark with the service annotations converters because we are
488
-
489
- 123
490
- 00:10:28,000 --> 00:10:34,000
491
- going to use them in our facades on the business level as you will go over these.
492
-
493
- 124
494
- 00:10:34,000 --> 00:10:37,000
495
- Pay attention to the dependency injection.
496
-
497
- 125
498
- 00:10:37,000 --> 00:10:41,000
499
- In some classes you need to configure dependency injection.
500
-
501
- 126
502
- 00:10:42,000 --> 00:10:45,000
503
- I did this with the help of auto annotation.
504
-
505
- 127
506
- 00:10:46,000 --> 00:10:53,000
507
- Actually the fuel you can keep without changes because they will be used for GP only.
508
-
509
- 128
510
- 00:10:54,000 --> 00:10:59,000
511
- And objects will be created using the object relational database mapping.
512
-
513
- 129
514
- 00:10:59,000 --> 00:11:01,000
515
- So I skip this.
516
-
517
- 130
518
- 00:11:02,000 --> 00:11:06,000
519
- The same story is with the entities classes here.
520
-
521
- 131
522
- 00:11:06,000 --> 00:11:13,000
523
- I removed package validation because we are going to implement validation with the hibernate data.
524
-
525
- 132
526
- 00:11:13,000 --> 00:11:22,000
527
- Now, in the previous solution we configure it validation for default user only a little bit later during
528
-
529
- 133
530
- 00:11:22,000 --> 00:11:23,000
531
- the solution review.
532
-
533
- 134
534
- 00:11:23,000 --> 00:11:27,000
535
- We are going to take a look at how I configured validation here.
536
-
537
- 135
538
- 00:11:28,000 --> 00:11:32,000
539
- I removed the beauteous glass because we don't use it anymore.
540
-
541
- 136
542
- 00:11:33,000 --> 00:11:38,000
543
- Also, I removed the BCP connection pool class because of the same reason.
544
-
545
- 137
546
- 00:11:38,000 --> 00:11:43,000
547
- Make sure that code is not used anymore before deleting it.
548
-
549
- 138
550
- 00:11:43,000 --> 00:11:51,000
551
- Just perform some search and investigation whether this class is used somewhere in the project.
552
-
553
- 139
554
- 00:11:51,000 --> 00:11:57,000
555
- In Eclipse, you can use search tools by pressing control and edge button simultaneously.
556
-
557
- 140
558
- 00:11:57,000 --> 00:12:03,000
559
- So after making sure that class is not used anywhere, you can delete it.
560
-
561
- 141
562
- 00:12:03,000 --> 00:12:08,000
563
- That's it was a persistence model and that's the important thing.
564
-
565
- 142
566
- 00:12:09,000 --> 00:12:18,000
567
- Considering Springworks with Java API and doesn't work with Jakarta API, we need to adjust input statements
568
-
569
- 143
570
- 00:12:18,000 --> 00:12:20,000
571
- across all different modules.
572
-
573
- 144
574
- 00:12:21,000 --> 00:12:26,000
575
- You can use eclipse search by pressing console and key simultaneously.
576
-
577
- 145
578
- 00:12:27,000 --> 00:12:32,000
579
- After that, try to search source java files for input space.
580
-
581
- 146
582
- 00:12:32,000 --> 00:12:37,000
583
- Jakarta point You can replace all things involved.
584
-
585
- 147
586
- 00:12:38,000 --> 00:12:40,000
587
- Just click replace here.
588
-
589
- 148
590
- 00:12:40,000 --> 00:12:47,000
591
- New window will pop up and you would need to specify with what you would like to substitute.
592
-
593
- 149
594
- 00:12:47,000 --> 00:12:52,000
595
- Adjust everything from Jakarta import to Java import.
596
-
597
- 150
598
- 00:12:53,000 --> 00:12:54,000
599
- I already did that.
600
-
601
- 151
602
- 00:12:55,000 --> 00:13:02,000
603
- That's why I can search for input box point in order to show the navigation is eclipse.
604
-
605
- 152
606
- 00:13:02,000 --> 00:13:13,000
607
- Basically, here you need to specify old value and here to specify the new value and click replace button.
608
-
609
- 153
610
- 00:13:13,000 --> 00:13:14,000
611
- That's it.
612
-
613
- 154
614
- 00:13:15,000 --> 00:13:23,000
615
- After changing the inputs, you're going to have compilation errors in all GP dot classes because we
616
-
617
- 155
618
- 00:13:23,000 --> 00:13:31,000
619
- used try with the resource block for entity manager factory and entity manager, which is okay for Jakarta
620
-
621
- 156
622
- 00:13:31,000 --> 00:13:40,000
623
- API but which is not okay for Java Persistence API because back then all the possible interface hasn't
624
-
625
- 157
626
- 00:13:40,000 --> 00:13:45,000
627
- been implemented yet in entity manager factor and in entity.
628
-
629
- 158
630
- 00:13:45,000 --> 00:13:53,000
631
- Managing these minor API differences is that we should be aware of and be ready to fix when it will
632
-
633
- 159
634
- 00:13:53,000 --> 00:13:54,000
635
- be necessary.
636
-
637
- 160
638
- 00:13:55,000 --> 00:13:59,000
639
- Like for example, in such case I open GP category.
640
-
641
- 161
642
- 00:14:00,000 --> 00:14:03,000
643
- I didn't so much changes here.
644
-
645
- 162
646
- 00:14:03,000 --> 00:14:09,000
647
- Basically I just substituted trial resources block with try final block.
648
-
649
- 163
650
- 00:14:10,000 --> 00:14:15,000
651
- Yes, it is a little bit more lines of code, but it is what it is.
652
-
653
- 164
654
- 00:14:15,000 --> 00:14:18,000
655
- Still, we achieve the same result.
656
-
657
- 165
658
- 00:14:18,000 --> 00:14:24,000
659
- And I close entity manager, factory and entity manager is a final block.
660
-
661
- 166
662
- 00:14:25,000 --> 00:14:31,000
663
- After factoring all these, you should get rid of the compilation errors and you can proceed.
664
-
665
- 167
666
- 00:14:31,000 --> 00:14:39,000
667
- And now the things that we shouldn't forget to update is persistence XML configuration in the persistence
668
-
669
- 168
670
- 00:14:39,000 --> 00:14:39,000
671
- module.
672
-
673
- 169
674
- 00:14:40,000 --> 00:14:44,000
675
- Just to remind you that we don't use Jakarta with spring.
676
-
677
- 170
678
- 00:14:44,000 --> 00:14:51,000
679
- That's why we need to adjust this file to and configure it with Java API.
680
-
681
- 171
682
- 00:14:51,000 --> 00:14:57,000
683
- I did this by substituting Jakarta word with Java here and that's it.
684
-
685
- 172
686
- 00:14:58,000 --> 00:15:03,000
687
- Also taking into account we changed the version of the hybrid core.
688
-
689
- 173
690
- 00:15:03,000 --> 00:15:11,000
691
- We also need to change the dialect, otherwise we are going to get different strange errors.
692
-
693
- 174
694
- 00:15:11,000 --> 00:15:14,000
695
- And one more important things that I did here.
696
-
697
- 175
698
- 00:15:14,000 --> 00:15:17,000
699
- Also, it is related with the version we used.
700
-
701
- 176
702
- 00:15:18,000 --> 00:15:26,000
703
- The reason error in case index will be created on the fields that are longer than 1000 bytes.
704
-
705
- 177
706
- 00:15:26,000 --> 00:15:34,000
707
- This error tells us that there is no sense to create index on such long fields because you wouldn't
708
-
709
- 178
710
- 00:15:34,000 --> 00:15:36,000
711
- be able to benefit from that.
712
-
713
- 179
714
- 00:15:37,000 --> 00:15:40,000
715
- You might be wondering and where we created indices.
716
-
717
- 180
718
- 00:15:41,000 --> 00:15:43,000
719
- Let me open the user data across.
720
-
721
- 181
722
- 00:15:43,000 --> 00:15:52,000
723
- In this class you can find that we use unique constraints on the email and on the partner code fields.
724
-
725
- 182
726
- 00:15:52,000 --> 00:16:00,000
727
- Let's specify length field for these columns in order to avoid error with very long indices.
728
-
729
- 183
730
- 00:16:00,000 --> 00:16:05,000
731
- I believe that's it with regards to the persistence module.
732
-
733
- 184
734
- 00:16:05,000 --> 00:16:08,000
735
- Now it is time to look at the Web model.
736
-
737
- 185
738
- 00:16:09,000 --> 00:16:16,000
739
- Let's look through the whole controllers category server that can be renamed to the category controller.
740
-
741
- 186
742
- 00:16:17,000 --> 00:16:23,000
743
- Product facade should be injected with the help of dependency injection tools of spring.
744
-
745
- 187
746
- 00:16:24,000 --> 00:16:33,000
747
- Also, lets add controller annotation and remove web servlet annotation and add request mapping or get
748
-
749
- 188
750
- 00:16:33,000 --> 00:16:35,000
751
- mapping annotation for the master.
752
-
753
- 189
754
- 00:16:36,000 --> 00:16:42,000
755
- If you follow my course, then you already know the difference between these two jobs.
756
-
757
- 190
758
- 00:16:43,000 --> 00:16:50,000
759
- We'll keep the same euro as it was before, but instead of keeping it with the web server, annotation
760
-
761
- 191
762
- 00:16:50,000 --> 00:16:58,000
763
- will pass it to the request modeling annotation or get mapping annotation or post mapping quotation
764
-
765
- 192
766
- 00:16:58,000 --> 00:17:00,000
767
- depending on each case.
768
-
769
- 193
770
- 00:17:01,000 --> 00:17:09,000
771
- Also, since this is not a server anymore, we can remove extends http server red and leave it like
772
-
773
- 194
774
- 00:17:09,000 --> 00:17:09,000
775
- this.
776
-
777
- 195
778
- 00:17:10,000 --> 00:17:13,000
779
- Let's make the similar changes in all servers.
780
-
781
- 196
782
- 00:17:14,000 --> 00:17:20,000
783
- When I worked on this I recommended to not refactor the whole scenes at once.
784
-
785
- 197
786
- 00:17:20,000 --> 00:17:27,000
787
- Just try to channel your service into the controllers and apply so can see configuration.
788
-
789
- 198
790
- 00:17:28,000 --> 00:17:32,000
791
- The rest of the code you will refactor after that.
792
-
793
- 199
794
- 00:17:32,000 --> 00:17:37,000
795
- Because the most challenging would be to build and run your application.
796
-
797
- 200
798
- 00:17:37,000 --> 00:17:41,000
799
- Once you will be sure that your application is built.
800
-
801
- 201
802
- 00:17:41,000 --> 00:17:46,000
803
- You can continue with massive refactoring to use all the features of Sprint.
804
-
805
- 202
806
- 00:17:46,000 --> 00:17:49,000
807
- And we see we'll get this soon.
808
-
809
- 203
810
- 00:17:50,000 --> 00:17:56,000
811
- Right now I just want to click through each server and show you that in each server.
812
-
813
- 204
814
- 00:17:56,000 --> 00:18:04,000
815
- I did the following things changed the class name to highlight the controller status, removed extents,
816
-
817
- 205
818
- 00:18:04,000 --> 00:18:13,000
819
- http server removed web server annotation, added request mapping annotation configured dependency injection
820
-
821
- 206
822
- 00:18:13,000 --> 00:18:14,000
823
- where it was needed.
824
-
825
- 207
826
- 00:18:15,000 --> 00:18:19,000
827
- The next thing in our list here are web filters.
828
-
829
- 208
830
- 00:18:19,000 --> 00:18:26,000
831
- You don't have to do a lot of things because spring be has special support for scanning classes annotated
832
-
833
- 209
834
- 00:18:26,000 --> 00:18:28,000
835
- with web filter annotations.
836
-
837
- 210
838
- 00:18:29,000 --> 00:18:36,000
839
- The only things that we have to change is that in previous solution we extended our classes from the
840
-
841
- 211
842
- 00:18:36,000 --> 00:18:39,000
843
- HTP filter from the Jakarta API.
844
-
845
- 212
846
- 00:18:39,000 --> 00:18:46,000
847
- But since we don't use Jakarta API anymore, we need to implement filter interface here.
848
-
849
- 213
850
- 00:18:47,000 --> 00:18:52,000
851
- Filter interface makes us to implement init and destroy methods.
852
-
853
- 214
854
- 00:18:53,000 --> 00:18:56,000
855
- You shouldn't be bothered about this too much.
856
-
857
- 215
858
- 00:18:56,000 --> 00:18:59,000
859
- We don't have any business necessity to implement them.
860
-
861
- 216
862
- 00:18:59,000 --> 00:19:05,000
863
- Just leave them as this take into account that we don't have servants anymore.
864
-
865
- 217
866
- 00:19:05,000 --> 00:19:13,000
867
- Let's change mappings of management filter from server names to the URL mappings.
868
-
869
- 218
870
- 00:19:13,000 --> 00:19:21,000
871
- Previously in the template solution we specified here server names to trigger filter only for those
872
-
873
- 219
874
- 00:19:21,000 --> 00:19:22,000
875
- servers.
876
-
877
- 220
878
- 00:19:22,000 --> 00:19:29,000
879
- But now we changed this attribute to specify resource mapping of zero related controllers.
880
-
881
- 221
882
- 00:19:30,000 --> 00:19:33,000
883
- This is purchase and fulfillment controller.
884
-
885
- 222
886
- 00:19:34,000 --> 00:19:35,000
887
- Okay.
888
-
889
- 223
890
- 00:19:35,000 --> 00:19:36,000
891
- We're good with filters.
892
-
893
- 224
894
- 00:19:36,000 --> 00:19:37,000
895
- Let's move on.
896
-
897
- 225
898
- 00:19:38,000 --> 00:19:46,000
899
- We had that package before, but I investigated it and realized that we don't use code from there anymore.
900
-
901
- 226
902
- 00:19:47,000 --> 00:19:48,000
903
- That's why I removed it.
904
-
905
- 227
906
- 00:19:49,000 --> 00:19:50,000
907
- By the way.
908
-
909
- 228
910
- 00:19:50,000 --> 00:19:52,000
911
- Make a note about this, too.
912
-
913
- 229
914
- 00:19:52,000 --> 00:19:57,000
915
- Always challenge yourself whether some code is still used.
916
-
917
- 230
918
- 00:19:57,000 --> 00:20:03,000
919
- Now we have relatively not huge, but also not small application here.
920
-
921
- 231
922
- 00:20:03,000 --> 00:20:08,000
923
- And you can see that it can happen that we forget to remove some code.
924
-
925
- 232
926
- 00:20:08,000 --> 00:20:14,000
927
- That's why always ask yourself what zip code is still in use now.
928
-
929
- 233
930
- 00:20:15,000 --> 00:20:18,000
931
- And in case it is not used, remove it.
932
-
933
- 234
934
- 00:20:19,000 --> 00:20:23,000
935
- But be 1,000% sure that it is not used.
936
-
937
- 235
938
- 00:20:24,000 --> 00:20:27,000
939
- The next package here is utils.
940
-
941
- 236
942
- 00:20:27,000 --> 00:20:35,000
943
- In utils we have just one class and this is encryption service that we use in different scenarios,
944
-
945
- 237
946
- 00:20:35,000 --> 00:20:39,000
947
- like for example, user registration and logging.
948
-
949
- 238
950
- 00:20:40,000 --> 00:20:48,000
951
- I market with the service annotation and I already configure dependency injection in all places where
952
-
953
- 239
954
- 00:20:48,000 --> 00:20:48,000
955
- it is used.
956
-
957
- 240
958
- 00:20:49,000 --> 00:20:57,000
959
- Now let's configure that and we see configuration and web application in action.
960
-
961
- 241
962
- 00:20:57,000 --> 00:21:04,000
963
- If you followed the course attentively, you can just copy and paste configurations that we created
964
-
965
- 242
966
- 00:21:04,000 --> 00:21:07,000
967
- together with you during our lessons.
968
-
969
- 243
970
- 00:21:07,000 --> 00:21:10,000
971
- Here is my main web app initialization.
972
-
973
- 244
974
- 00:21:10,000 --> 00:21:19,000
975
- We already reviewed each line of code from this class when we created it the first time I configure
976
-
977
- 245
978
- 00:21:19,000 --> 00:21:21,000
979
- my dispatcher servlet here.
980
-
981
- 246
982
- 00:21:21,000 --> 00:21:27,000
983
- And here is web config that implements web MVC configure.
984
-
985
- 247
986
- 00:21:27,000 --> 00:21:34,000
987
- We reviewed a lot of lines of code from this file, and during this video I will highlight the scenes
988
-
989
- 248
990
- 00:21:34,000 --> 00:21:36,000
991
- that I added here.
992
-
993
- 249
994
- 00:21:36,000 --> 00:21:43,000
995
- I want to highlight the configuration of resource handlers because in the web project we already had
996
-
997
- 250
998
- 00:21:43,000 --> 00:21:48,000
999
- some web resources and we will not move them to different folders.
1000
-
1001
- 251
1002
- 00:21:48,000 --> 00:21:55,000
1003
- We just need to tell Sprint and we see how to map resources properly inside our application.
1004
-
1005
- 252
1006
- 00:21:55,000 --> 00:22:00,000
1007
- Taking into account I implements web and DC configure.
1008
-
1009
- 253
1010
- 00:22:00,000 --> 00:22:07,000
1011
- I just need to override add resource and this massive it takes resource handler registry.
1012
-
1013
- 254
1014
- 00:22:08,000 --> 00:22:16,000
1015
- I post strings to which requests from our view layers are sent in to add the resource handler message
1016
-
1017
- 255
1018
- 00:22:16,000 --> 00:22:19,000
1019
- and in the add resource locations.
1020
-
1021
- 256
1022
- 00:22:19,000 --> 00:22:25,000
1023
- I added the name of the folder house called in my web resources.
1024
-
1025
- 257
1026
- 00:22:26,000 --> 00:22:27,000
1027
- Is that clear?
1028
-
1029
- 258
1030
- 00:22:28,000 --> 00:22:32,000
1031
- So these are just few lines of code, but important ones.
1032
-
1033
- 259
1034
- 00:22:33,000 --> 00:22:34,000
1035
- Congratulations.
1036
-
1037
- 260
1038
- 00:22:34,000 --> 00:22:36,000
1039
- We have done a lot of refactoring since.
1040
-
1041
- 261
1042
- 00:22:36,000 --> 00:22:41,000
1043
- Already we try to make similar updates and updates involved.
1044
-
1045
- 262
1046
- 00:22:41,000 --> 00:22:47,000
1047
- Now let's get deeper into the details and review specific parts of the implementation.
1048
-
1049
- 263
1050
- 00:22:48,000 --> 00:22:55,000
1051
- Let's learn how we can approach the question of localization and internationalization in Sprint.
1052
-
1053
- 264
1054
- 00:22:55,000 --> 00:23:03,000
1055
- And we see because if you already know this in template application, based on the seven we used resource
1056
-
1057
- 265
1058
- 00:23:03,000 --> 00:23:12,000
1059
- bundles, we add separate services which is local and we have special tags on the GCP page to print
1060
-
1061
- 266
1062
- 00:23:12,000 --> 00:23:14,000
1063
- localized message.
1064
-
1065
- 267
1066
- 00:23:14,000 --> 00:23:18,000
1067
- How we can address the same challenge is a sprint and we see.
1068
-
1069
- 268
1070
- 00:23:19,000 --> 00:23:25,000
1071
- First of all, I removed change because we don't need it anymore.
1072
-
1073
- 269
1074
- 00:23:26,000 --> 00:23:30,000
1075
- The next thing that I did, I declared few beans.
1076
-
1077
- 270
1078
- 00:23:30,000 --> 00:23:30,000
1079
- Here.
1080
-
1081
- 271
1082
- 00:23:30,000 --> 00:23:31,000
1083
- Let me show you.
1084
-
1085
- 272
1086
- 00:23:32,000 --> 00:23:35,000
1087
- I open close this code web config.
1088
-
1089
- 273
1090
- 00:23:35,000 --> 00:23:39,000
1091
- I declare bean of message source.
1092
-
1093
- 274
1094
- 00:23:39,000 --> 00:23:43,000
1095
- I create object of reward resource bundle.
1096
-
1097
- 275
1098
- 00:23:43,000 --> 00:23:44,000
1099
- Message source.
1100
-
1101
- 276
1102
- 00:23:44,000 --> 00:23:53,000
1103
- This implementation will update resource messages in case it will be updated without reloading the server.
1104
-
1105
- 277
1106
- 00:23:53,000 --> 00:24:00,000
1107
- If you would start explore the Iraq of message source interface, you're going to see that there are
1108
-
1109
- 278
1110
- 00:24:00,000 --> 00:24:04,000
1111
- huge variety of OSR interfaces and classes.
1112
-
1113
- 279
1114
- 00:24:05,000 --> 00:24:10,000
1115
- Feel free to explore this Iraq deeper by reading the official documentation.
1116
-
1117
- 280
1118
- 00:24:11,000 --> 00:24:16,000
1119
- In case I would tell the hosting documentation, we wouldn't have enough time.
1120
-
1121
- 281
1122
- 00:24:17,000 --> 00:24:20,000
1123
- Of the creation of the object of message source.
1124
-
1125
- 282
1126
- 00:24:20,000 --> 00:24:22,000
1127
- We configure base name.
1128
-
1129
- 283
1130
- 00:24:23,000 --> 00:24:27,000
1131
- If you remember since about localization and internationalization.
1132
-
1133
- 284
1134
- 00:24:28,000 --> 00:24:35,000
1135
- The base name is the basis name of our source bundles without language and country code.
1136
-
1137
- 285
1138
- 00:24:35,000 --> 00:24:42,000
1139
- In our particular case, the base name is Online Shop Resource Bundle.
1140
-
1141
- 286
1142
- 00:24:43,000 --> 00:24:50,000
1143
- I can add plus more brackets here in order to tell spring that my resource bundles are located in the
1144
-
1145
- 287
1146
- 00:24:50,000 --> 00:24:52,000
1147
- class pass of the project.
1148
-
1149
- 288
1150
- 00:24:52,000 --> 00:24:59,000
1151
- I also set default encoding to UTF eight in order to support most of the Unicode characters.
1152
-
1153
- 289
1154
- 00:25:00,000 --> 00:25:03,000
1155
- Additionally, we need to declare a local resolver.
1156
-
1157
- 290
1158
- 00:25:03,000 --> 00:25:08,000
1159
- Being set helps to identify which locale is being used.
1160
-
1161
- 291
1162
- 00:25:09,000 --> 00:25:13,000
1163
- There are such popular concrete implementations of local resolver.
1164
-
1165
- 292
1166
- 00:25:14,000 --> 00:25:23,000
1167
- Accept how the local resolver uses a primary locale specified in SAP plan which had.
1168
-
1169
- 293
1170
- 00:25:23,000 --> 00:25:24,000
1171
- Of the HTP request.
1172
-
1173
- 294
1174
- 00:25:25,000 --> 00:25:26,000
1175
- Six.
1176
-
1177
- 295
1178
- 00:25:26,000 --> 00:25:34,000
1179
- The local resolver always return a fixed default, local and optionally time zone session.
1180
-
1181
- 296
1182
- 00:25:34,000 --> 00:25:43,000
1183
- Local resolver uses a local attribute in the user session with a fallback to the specified default locale
1184
-
1185
- 297
1186
- 00:25:43,000 --> 00:25:44,000
1187
- of the request.
1188
-
1189
- 298
1190
- 00:25:44,000 --> 00:25:53,000
1191
- Accept how the local local resolver persists a custom, local and or time zone information.
1192
-
1193
- 299
1194
- 00:25:53,000 --> 00:25:59,000
1195
- As a browser cookie, you're welcome to use any implementations that you wish.
1196
-
1197
- 300
1198
- 00:26:00,000 --> 00:26:06,000
1199
- I decided to use local resolver and also we need to add interceptor.
1200
-
1201
- 301
1202
- 00:26:07,000 --> 00:26:15,000
1203
- We need to register a local change interceptor to allow specify the desired local on average request.
1204
-
1205
- 302
1206
- 00:26:15,000 --> 00:26:23,000
1207
- You can see that I create object of local change interceptor and specify the name of the request parameter
1208
-
1209
- 303
1210
- 00:26:23,000 --> 00:26:25,000
1211
- that will be used to specify the language.
1212
-
1213
- 304
1214
- 00:26:26,000 --> 00:26:33,000
1215
- Pay attention that I override the mask that exists to register all possible interceptors.
1216
-
1217
- 305
1218
- 00:26:33,000 --> 00:26:37,000
1219
- We get interceptor register here as my set argument.
1220
-
1221
- 306
1222
- 00:26:38,000 --> 00:26:41,000
1223
- I use it to add my interceptor.
1224
-
1225
- 307
1226
- 00:26:41,000 --> 00:26:42,000
1227
- Okay.
1228
-
1229
- 308
1230
- 00:26:42,000 --> 00:26:48,000
1231
- Now we're good and required all required builds to support localization.
1232
-
1233
- 309
1234
- 00:26:49,000 --> 00:26:54,000
1235
- The next thing that we have to do is to make proper changes on the view level.
1236
-
1237
- 310
1238
- 00:26:54,000 --> 00:27:00,000
1239
- In the project template, we use the localization only in the header element.
1240
-
1241
- 311
1242
- 00:27:00,000 --> 00:27:07,000
1243
- As example, while I'm totally okay to implement localization and internationalization support across
1244
-
1245
- 312
1246
- 00:27:07,000 --> 00:27:11,000
1247
- the whole application, this approach would be the same.
1248
-
1249
- 313
1250
- 00:27:12,000 --> 00:27:15,000
1251
- That's why I would show you only other example.
1252
-
1253
- 314
1254
- 00:27:16,000 --> 00:27:23,000
1255
- Let me open the header file in the header with language switch that changes language.
1256
-
1257
- 315
1258
- 00:27:24,000 --> 00:27:29,000
1259
- So the first thing that we need to add here is to add spring tags.
1260
-
1261
- 316
1262
- 00:27:29,000 --> 00:27:34,000
1263
- You can see here on top tag directive for spring tags.
1264
-
1265
- 317
1266
- 00:27:35,000 --> 00:27:38,000
1267
- It goes with Spirit and we see library.
1268
-
1269
- 318
1270
- 00:27:38,000 --> 00:27:41,000
1271
- So if you add a sprinkle, you see in the Maven X.
1272
-
1273
- 319
1274
- 00:27:42,000 --> 00:27:45,000
1275
- You don't have to add any other dependencies.
1276
-
1277
- 320
1278
- 00:27:46,000 --> 00:27:53,000
1279
- Now, the only thing that remains to do is to use Sprint message tag and pause the name of the message
1280
-
1281
- 321
1282
- 00:27:53,000 --> 00:27:55,000
1283
- that we want to use.
1284
-
1285
- 322
1286
- 00:27:55,000 --> 00:27:57,000
1287
- Everything is super simple.
1288
-
1289
- 323
1290
- 00:27:57,000 --> 00:28:04,000
1291
- You don't need to be bothered about uploading resource bundles into the file, declaring variables of
1292
-
1293
- 324
1294
- 00:28:04,000 --> 00:28:05,000
1295
- resource bundles.
1296
-
1297
- 325
1298
- 00:28:05,000 --> 00:28:08,000
1299
- The rest sprint will handle by itself.
1300
-
1301
- 326
1302
- 00:28:09,000 --> 00:28:15,000
1303
- And to actually handle change of locale, we need to send a request with the LAN parameter.
1304
-
1305
- 327
1306
- 00:28:16,000 --> 00:28:24,000
1307
- Do remember we have just configured interceptor, so we have to use the same parameter that we specified
1308
-
1309
- 328
1310
- 00:28:24,000 --> 00:28:25,000
1311
- in the intercept.
1312
-
1313
- 329
1314
- 00:28:26,000 --> 00:28:30,000
1315
- Here you can see that the use links with length parameters.
1316
-
1317
- 330
1318
- 00:28:31,000 --> 00:28:35,000
1319
- Basically when the link is clicked, request is sent.
1320
-
1321
- 331
1322
- 00:28:35,000 --> 00:28:43,000
1323
- Sprint intercept request verifies the value of request parameter changes local inside the context and
1324
-
1325
- 332
1326
- 00:28:43,000 --> 00:28:47,000
1327
- reload all the localized resources on the page.
1328
-
1329
- 333
1330
- 00:28:48,000 --> 00:28:49,000
1331
- Is that clear?
1332
-
1333
- 334
1334
- 00:28:49,000 --> 00:28:55,000
1335
- If you noticed, we also used resource bundles inside the classes.
1336
-
1337
- 335
1338
- 00:28:55,000 --> 00:29:03,000
1339
- For example, we use resource bundles in the edit profile controller, checkout controller and in the
1340
-
1341
- 336
1342
- 00:29:03,000 --> 00:29:08,000
1343
- sign up controller instead of the object of resource bundle.
1344
-
1345
- 337
1346
- 00:29:08,000 --> 00:29:10,000
1347
- We have message source now.
1348
-
1349
- 338
1350
- 00:29:11,000 --> 00:29:17,000
1351
- So in these classes you can configure the dependency injection of the message source Bing.
1352
-
1353
- 339
1354
- 00:29:18,000 --> 00:29:20,000
1355
- It has slightly different API.
1356
-
1357
- 340
1358
- 00:29:20,000 --> 00:29:24,000
1359
- It doesn't have gets to method like resource bundle type does it?
1360
-
1361
- 341
1362
- 00:29:24,000 --> 00:29:26,000
1363
- Does get message message.
1364
-
1365
- 342
1366
- 00:29:27,000 --> 00:29:30,000
1367
- I'm going to use get message method with three arguments.
1368
-
1369
- 343
1370
- 00:29:31,000 --> 00:29:35,000
1371
- The first parameter is our message code from our source bundle.
1372
-
1373
- 344
1374
- 00:29:35,000 --> 00:29:37,000
1375
- The key of the message.
1376
-
1377
- 345
1378
- 00:29:38,000 --> 00:29:44,000
1379
- The second parameter is array of arguments that we will use to inject into the messages.
1380
-
1381
- 346
1382
- 00:29:44,000 --> 00:29:47,000
1383
- And the third parameter is local.
1384
-
1385
- 347
1386
- 00:29:47,000 --> 00:29:51,000
1387
- Taking the account Spring changes local.
1388
-
1389
- 348
1390
- 00:29:51,000 --> 00:29:58,000
1391
- We'll just use massive default from local class because it returns the current local.
1392
-
1393
- 349
1394
- 00:29:58,000 --> 00:30:05,000
1395
- Is it clear to even in case you have any questions, please do not hesitate to ask questions below the
1396
-
1397
- 350
1398
- 00:30:05,000 --> 00:30:08,000
1399
- video and I will be happy to answer.
1400
-
1401
- 351
1402
- 00:30:09,000 --> 00:30:12,000
1403
- The next thing that we have to configure is exception handling.
1404
-
1405
- 352
1406
- 00:30:13,000 --> 00:30:15,000
1407
- You already saw the lesson about exception handling.
1408
-
1409
- 353
1410
- 00:30:16,000 --> 00:30:19,000
1411
- That's why there will be nothing new for you.
1412
-
1413
- 354
1414
- 00:30:20,000 --> 00:30:25,000
1415
- This web config class will declare the handler exception resolver.
1416
-
1417
- 355
1418
- 00:30:25,000 --> 00:30:33,000
1419
- So this one supposed to handle all exceptions without handlers and forwards in request is an error page.
1420
-
1421
- 356
1422
- 00:30:33,000 --> 00:30:36,000
1423
- I added this JSP to this.
1424
-
1425
- 357
1426
- 00:30:36,000 --> 00:30:39,000
1427
- This is from our lesson about exception handling.
1428
-
1429
- 358
1430
- 00:30:39,000 --> 00:30:40,000
1431
- And this.
1432
-
1433
- 359
1434
- 00:30:40,000 --> 00:30:40,000
1435
- Can we see.
1436
-
1437
- 360
1438
- 00:30:41,000 --> 00:30:51,000
1439
- His main position was, I said, strong exception if no ever found property in our dispatch server to
1440
-
1441
- 361
1442
- 00:30:51,000 --> 00:30:51,000
1443
- true.
1444
-
1445
- 362
1446
- 00:30:52,000 --> 00:30:57,000
1447
- And also I declare the error controller advisor in the exception package.
1448
-
1449
- 363
1450
- 00:30:58,000 --> 00:31:03,000
1451
- It handles our not found exceptions and for that request is not found.
1452
-
1453
- 364
1454
- 00:31:03,000 --> 00:31:04,000
1455
- JSP page.
1456
-
1457
- 365
1458
- 00:31:05,000 --> 00:31:06,000
1459
- That's it.
1460
-
1461
- 366
1462
- 00:31:06,000 --> 00:31:14,000
1463
- With regards to exceptions, it is also can be considered as a good thing to refactor exists in masses
1464
-
1465
- 367
1466
- 00:31:14,000 --> 00:31:21,000
1467
- in controllers that will work with HTTP server request and h to be server response.
1468
-
1469
- 368
1470
- 00:31:21,000 --> 00:31:22,000
1471
- No doubt.
1472
-
1473
- 369
1474
- 00:31:23,000 --> 00:31:30,000
1475
- But we end the process of and we see integration in order to take advantage of using it in our code.
1476
-
1477
- 370
1478
- 00:31:30,000 --> 00:31:38,000
1479
- I'm talking about not extracting request parameters from the server request with a separate method calls
1480
-
1481
- 371
1482
- 00:31:38,000 --> 00:31:43,000
1483
- not perform mapping between the form and the entity manually.
1484
-
1485
- 372
1486
- 00:31:43,000 --> 00:31:45,000
1487
- Let's use spring for all these routine.
1488
-
1489
- 373
1490
- 00:31:47,000 --> 00:31:53,000
1491
- Also, we'll get rid of request forwarding through the dispatcher servlet like we did before.
1492
-
1493
- 374
1494
- 00:31:53,000 --> 00:31:58,000
1495
- Let's review each controller one by one and make appropriate changes.
1496
-
1497
- 375
1498
- 00:31:58,000 --> 00:32:01,000
1499
- We start from the category controller.
1500
-
1501
- 376
1502
- 00:32:02,000 --> 00:32:09,000
1503
- I added a few request parameters here instead of extracting them from the request object, I injected
1504
-
1505
- 377
1506
- 00:32:09,000 --> 00:32:18,000
1507
- model and I returned street value of the view where for the request to in checkout controller and in
1508
-
1509
- 378
1510
- 00:32:18,000 --> 00:32:22,000
1511
- some other places pay extra attention is redirect.
1512
-
1513
- 379
1514
- 00:32:22,000 --> 00:32:30,000
1515
- You know that there can be different reasons for redirecting request instead of the forwarding request
1516
-
1517
- 380
1518
- 00:32:30,000 --> 00:32:31,000
1519
- ignores the view.
1520
-
1521
- 381
1522
- 00:32:31,000 --> 00:32:37,000
1523
- In this particular case, according to our business logic, we would like to make redirect after the
1524
-
1525
- 382
1526
- 00:32:37,000 --> 00:32:42,000
1527
- checkout the different ways about how to make redirects.
1528
-
1529
- 383
1530
- 00:32:42,000 --> 00:32:49,000
1531
- But in my opinion, the simplest one is to use redirect graphics before the union.
1532
-
1533
- 384
1534
- 00:32:50,000 --> 00:32:50,000
1535
- That's it.
1536
-
1537
- 385
1538
- 00:32:51,000 --> 00:32:58,000
1539
- Walks through the controllers attentively and refactor all the masses attentively, just in case.
1540
-
1541
- 386
1542
- 00:32:58,000 --> 00:33:07,000
1543
- You can always look at my solution, taking into account the changes as similar in all classes, I wouldn't
1544
-
1545
- 387
1546
- 00:33:07,000 --> 00:33:11,000
1547
- stop on each controller, just try to make changes.
1548
-
1549
- 388
1550
- 00:33:11,000 --> 00:33:17,000
1551
- By analogy, there is sign up controller that also requires updates.
1552
-
1553
- 389
1554
- 00:33:17,000 --> 00:33:25,000
1555
- In the related view, I recommend here to implement smooth forms, use model attributes, feature and
1556
-
1557
- 390
1558
- 00:33:25,000 --> 00:33:27,000
1559
- validation feature.
1560
-
1561
- 391
1562
- 00:33:27,000 --> 00:33:35,000
1563
- Let me show it to you In the get method, I put the object of the user into the model and therefore
1564
-
1565
- 392
1566
- 00:33:35,000 --> 00:33:36,000
1567
- to request a view.
1568
-
1569
- 393
1570
- 00:33:37,000 --> 00:33:38,000
1571
- Let me open now.
1572
-
1573
- 394
1574
- 00:33:38,000 --> 00:33:40,000
1575
- Sign up JSP page.
1576
-
1577
- 395
1578
- 00:33:41,000 --> 00:33:42,000
1579
- On top of the page.
1580
-
1581
- 396
1582
- 00:33:42,000 --> 00:33:46,000
1583
- You can see that I used spring forms directly.
1584
-
1585
- 397
1586
- 00:33:47,000 --> 00:33:50,000
1587
- It also goes with the Spring MVC library.
1588
-
1589
- 398
1590
- 00:33:50,000 --> 00:33:56,000
1591
- After that I change each HTML tag form with spring form tag.
1592
-
1593
- 399
1594
- 00:33:57,000 --> 00:34:00,000
1595
- I add modal attribute to the form.
1596
-
1597
- 400
1598
- 00:34:00,000 --> 00:34:09,000
1599
- I substitute all HTML input tags with spring form input dates and the specifies the POS attribute instead
1600
-
1601
- 401
1602
- 00:34:09,000 --> 00:34:12,000
1603
- of the name in order to set the values.
1604
-
1605
- 402
1606
- 00:34:12,000 --> 00:34:20,000
1607
- It is a model object that tensions and previously with POS repeat passwords as a separate argument.
1608
-
1609
- 403
1610
- 00:34:20,000 --> 00:34:28,000
1611
- And now, since we have binding all form parameters with the object, we need to add one more field
1612
-
1613
- 404
1614
- 00:34:28,000 --> 00:34:35,000
1615
- for a password into the default user object and also getters and status free.
1616
-
1617
- 405
1618
- 00:34:36,000 --> 00:34:37,000
1619
- Okay.
1620
-
1621
- 406
1622
- 00:34:37,000 --> 00:34:43,000
1623
- After submitting this form, we can extract the user object in the sign up controller with the model
1624
-
1625
- 407
1626
- 00:34:43,000 --> 00:34:44,000
1627
- attribute annotation.
1628
-
1629
- 408
1630
- 00:34:45,000 --> 00:34:52,000
1631
- You can see that I also added bind binding result object that goes right after our model for the model
1632
-
1633
- 409
1634
- 00:34:52,000 --> 00:34:53,000
1635
- validation.
1636
-
1637
- 410
1638
- 00:34:53,000 --> 00:35:02,000
1639
- I edit valid annotation to validate the model attribute and inside the default user class, I also configured
1640
-
1641
- 411
1642
- 00:35:02,000 --> 00:35:03,000
1643
- validation rules.
1644
-
1645
- 412
1646
- 00:35:04,000 --> 00:35:12,000
1647
- I added validation rules for the first name, last name and email and in case binding results have errors,
1648
-
1649
- 413
1650
- 00:35:12,000 --> 00:35:15,000
1651
- referred user back to the signup page.
1652
-
1653
- 414
1654
- 00:35:15,000 --> 00:35:19,000
1655
- If no, then we continue our business logic here.
1656
-
1657
- 415
1658
- 00:35:19,000 --> 00:35:25,000
1659
- And the next thing that we have to do is to verify the proof key with the partner code to implement
1660
-
1661
- 416
1662
- 00:35:25,000 --> 00:35:27,000
1663
- our referral program.
1664
-
1665
- 417
1666
- 00:35:28,000 --> 00:35:35,000
1667
- The next thing that we do here is extract the value from the key in case there is any partner code in
1668
-
1669
- 418
1670
- 00:35:35,000 --> 00:35:35,000
1671
- it.
1672
-
1673
- 419
1674
- 00:35:36,000 --> 00:35:43,000
1675
- We will speak MVC instead of iterating over all cookies until we find the right one with the name that
1676
-
1677
- 420
1678
- 00:35:43,000 --> 00:35:43,000
1679
- we need.
1680
-
1681
- 421
1682
- 00:35:44,000 --> 00:35:50,000
1683
- I just use quick value annotation and pass it in the mass parameters.
1684
-
1685
- 422
1686
- 00:35:50,000 --> 00:35:54,000
1687
- I specify the name of the cookie and the default value.
1688
-
1689
- 423
1690
- 00:35:55,000 --> 00:35:58,000
1691
- Pay attention in case there will not be a cookie.
1692
-
1693
- 424
1694
- 00:35:59,000 --> 00:36:01,000
1695
- Then spring will throw an exception.
1696
-
1697
- 425
1698
- 00:36:02,000 --> 00:36:10,000
1699
- That's why it is important to set default value in order to avoid exception and using this cookie value.
1700
-
1701
- 426
1702
- 00:36:10,000 --> 00:36:12,000
1703
- I work with it in the code.
1704
-
1705
- 427
1706
- 00:36:13,000 --> 00:36:19,000
1707
- And the last but not the least thing taking into account we use spring court now.
1708
-
1709
- 428
1710
- 00:36:19,000 --> 00:36:24,000
1711
- There is no need for us to store configurations in the constants.
1712
-
1713
- 429
1714
- 00:36:24,000 --> 00:36:31,000
1715
- Let's keep all application related properties outside of our code in the separate properties file.
1716
-
1717
- 430
1718
- 00:36:31,000 --> 00:36:35,000
1719
- Let me show you how easily we can configure this.
1720
-
1721
- 431
1722
- 00:36:35,000 --> 00:36:39,000
1723
- I added properties file in my resource folder.
1724
-
1725
- 432
1726
- 00:36:39,000 --> 00:36:46,000
1727
- Basically, what I did here, I just moved all the properties from the configurations interface to the
1728
-
1729
- 433
1730
- 00:36:46,000 --> 00:36:48,000
1731
- properties file.
1732
-
1733
- 434
1734
- 00:36:48,000 --> 00:36:57,000
1735
- The next thing I did, I verified where I have completion error and then I injected the required property
1736
-
1737
- 435
1738
- 00:36:57,000 --> 00:36:58,000
1739
- values there.
1740
-
1741
- 436
1742
- 00:36:59,000 --> 00:37:01,000
1743
- Let me show you one example.
1744
-
1745
- 437
1746
- 00:37:01,000 --> 00:37:04,000
1747
- For example, I open search controller.
1748
-
1749
- 438
1750
- 00:37:05,000 --> 00:37:12,000
1751
- Previously I used here pagination limit constant value from the configurations interface in order to
1752
-
1753
- 439
1754
- 00:37:12,000 --> 00:37:17,000
1755
- tell my facade how many records I expect to get on the page.
1756
-
1757
- 440
1758
- 00:37:17,000 --> 00:37:24,000
1759
- And now, instead of using the constant from the configurations interface, I inject the property from
1760
-
1761
- 441
1762
- 00:37:24,000 --> 00:37:26,000
1763
- the properties file.
1764
-
1765
- 442
1766
- 00:37:26,000 --> 00:37:31,000
1767
- I inject it using value annotation and string expression language.
1768
-
1769
- 443
1770
- 00:37:31,000 --> 00:37:38,000
1771
- But in order to use properties like this from the properties file, you need to register property file
1772
-
1773
- 444
1774
- 00:37:38,000 --> 00:37:39,000
1775
- in the spring.
1776
-
1777
- 445
1778
- 00:37:40,000 --> 00:37:43,000
1779
- I open web config class.
1780
-
1781
- 446
1782
- 00:37:43,000 --> 00:37:46,000
1783
- I use this class as a configuration.
1784
-
1785
- 447
1786
- 00:37:46,000 --> 00:37:53,000
1787
- And you can see that I added here another annotation that is called Properties source and I post app
1788
-
1789
- 448
1790
- 00:37:53,000 --> 00:37:55,000
1791
- properties value there.
1792
-
1793
- 449
1794
- 00:37:56,000 --> 00:37:57,000
1795
- So that's it.
1796
-
1797
- 450
1798
- 00:37:57,000 --> 00:38:02,000
1799
- Now we can say that we are ready to use properties in our application.
1800
-
1801
- 451
1802
- 00:38:03,000 --> 00:38:06,000
1803
- Basically that all changes that they did.
1804
-
1805
- 452
1806
- 00:38:07,000 --> 00:38:10,000
1807
- Compare your solution with my solution.
1808
-
1809
- 453
1810
- 00:38:10,000 --> 00:38:16,000
1811
- Ask your questions below the video and verify end to end behavior of the application.
1812
-
1813
- 454
1814
- 00:38:17,000 --> 00:38:23,000
1815
- Remember, you have the reference to all the requirements in order to verify all behavior.
1816
-
1817
- 455
1818
- 00:38:23,000 --> 00:38:32,000
1819
- And then I'm sure that this exercise helps you a lot in getting practical skills of work with this framework.
1820
-
1821
- 456
1822
- 00:38:32,000 --> 00:38:35,000
1823
- This task is really comprehensive.
1824
-
1825
- 457
1826
- 00:38:35,000 --> 00:38:39,000
1827
- Now we integrate the Sprint core and sprint and we see.
1828
-
1829
- 458
1830
- 00:38:39,000 --> 00:38:41,000
1831
- But we are not done yet.
1832
-
1833
- 459
1834
- 00:38:41,000 --> 00:38:44,000
1835
- We have a lot of lessons ahead.
1836
-
1837
- 460
1838
- 00:38:44,000 --> 00:38:45,000
1839
- So stay tuned.
1840
-
1841
- 461
1842
- 00:38:46,000 --> 00:38:53,000
1843
- We are going to improve this online shop with implementation of other cool features from this framework.
1844
-
1845
- 462
1846
- 00:38:53,000 --> 00:38:55,000
1847
- Thanks a lot for your attention.
1848
-
1849
- 463
1850
- 00:38:55,000 --> 00:38:58,000
1851
- Have a great day and see you in the next lesson.
1852
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83 - ===== EXAM Spring Core & Spring MVC - Online Shop =====/001 Task-description-reference-to-the-solution-and-the-source-code.url DELETED
@@ -1,2 +0,0 @@
1
- [InternetShortcut]
2
- URL=https://docs.google.com/document/d/1sCd2OpRMFyeTZzkZ_mDPQFvtECu8pLqFm3lPJW9lf_U/edit?usp=sharing
 
 
 
83 - ===== EXAM Spring Core & Spring MVC - Online Shop =====/external-links.txt DELETED
@@ -1,3 +0,0 @@
1
-
2
- 001 Task-description-reference-to-the-solution-and-the-source-code
3
- https://docs.google.com/document/d/1sCd2OpRMFyeTZzkZ_mDPQFvtECu8pLqFm3lPJW9lf_U/edit?usp=sharing