Petclinic Documentation
Transcript of Petclinic Documentation
-
8/9/2019 Petclinic Documentation
1/20
!"#$%&'()*+,$%$+
-
8/9/2019 Petclinic Documentation
2/20
!"#$%& ()*+,$%$+
./"0122&$*.345+672!"#$%&!63#+)20"#$%&'")*+,$%$+
./"1220"#$%&'")*+,$%$+5+,638963%8#:5+672
-
8/9/2019 Petclinic Documentation
3/20
; "#63,* ?@(AB
!"#$%& C>*> @(A
Repository
Service DE>+.)>4,)DF#>%0>+G6%>,
ControllerH)>% I>,$8>G6%
!"#$%& DJIE >%%6*>G6%0
Views
H66*0*#>" ?E!!B
@!( K$*.
+30*67 *>&0 F.:7),)>9
C>%8),$6%K)4=>#0
| |
&&&&+
-
8/9/2019 Petclinic Documentation
4/20
F6"$+0
E6#) !"#$%&
F.) L)4 ,>:)#
-
8/9/2019 Petclinic Documentation
5/20
C>*> A++)00
I$0$*M)"60$*6#:
@84+I$0$*M)"60$*6#: @">I$0$*M)"6!"#$%&C>*>@">
I$0$*M)"6findByPetId: 16 lines of code findByPetId: 6 (short)
lines of codefindByPetId: 0 lines (interface
declaration is enough based on
naming conventions)
In order to select which implementation should be used, select the
Appropriate bean profile inside web.xml (jdbc, jpa or spring-data-jpa)
-
8/9/2019 Petclinic Documentation
6/20
H)>% "#6
-
8/9/2019 Petclinic Documentation
7/20
E>+.$%&
F.) ,$0* 69 I)*)#$%>#$>%0 $0 +>+.)8 30$%& ).+>+.)
@Cacheable(value = "vets")publicCollection findVets() throwsDataAccessException { }
ClinicServiceImpl
tools-config.xml
ehcache.xml
-
8/9/2019 Petclinic Documentation
8/20
ON+)"G6% P>%8,$%&
()*M)"60$*6#:
E,$%$+!)#Q$+)
()*E6%*#6,,)#
May throw a RuntimeException
(typically DataAccessException)
Transaction is rolled back
in case of a RuntimeException(exception is still propagated to PetController)
Exception isnot handled there
It is propagated.
!$7",)J>""$%&
ON+)"G6%M)06,Q)#
Declared in mvc-core-config.xml
Based on the configuration used in petclinic:
Logs the exception stacktrace
Forwards to WEB-INF/jsp/exception.jsp
Exception logged as a comment inside exception.jsp
-
8/9/2019 Petclinic Documentation
9/20
A0")+* R#$)%*)8 (#6>77$%& ?S2TB
P6K *6 >88 4).>Q$6# $% >,, 7)*.680 69 >,, M)"60$*6#:
+,>00)0U
@">RK%)#M)"60$*6#:
@">()*M)"60$*6#:
@">I)*M)"60$*6#:
@">I$0$*M)"60$*6#:
E,$%$+!)#Q$+) VRW AVVJOFPRC
EAVV!
-
8/9/2019 Petclinic Documentation
10/20
A0")+* R#$)%*)8 (#6>77$%& ?T2TB
E>,,J6%$*6#$%&A0")+*
X@Repository
publicclassJpaVetRepositoryImpl
@Repository
publicclassJpaVisitRepositoryImpl
@AspectpublicclassCallMonitoringAspect {@Around("within(@org.springframework.stereotype.Repository *)")publicObject invoke() { } }
Adds monitoringAddsmonitoring
Adds monitoring
To understand further how AOP works in Spring:http://blog.springsource.org/2012/05/23/understanding-proxy-usage-in-spring/
-
8/9/2019 Petclinic Documentation
11/20
F6"$+0
E6#) !"#$%&
F.) L)4 ,>:)# !"#$%& JIE
F.$#8'">#*: K)4 ,$4#>#$)0
-
8/9/2019 Petclinic Documentation
12/20
I$)K M)06,Q)#0 $% 0"#$%&'")*+,$%$+
ST
E6%*)%*Y)&6G>G%&IMDoes not resolve any view on its own
Delegates to other view resolvers
H)>%Y>7)IM
Atom and XML
Z%*)#%>,M)063#+)IM
Default viewClass: JstlView
(used for JSP files)
vets.html
owners.htmlvets.xmlpets/9/visits.atom
mvc-view-config.xml
-
8/9/2019 Petclinic Documentation
13/20
F6"$+0
E6#) !"#$%&
F.) L)4 ,>:)# !"#$%& JIE
F.$#8'">#*: K)4 ,$4#>#$)0
C>%8),$6% 96# 8>*>*>4,)0
L)4=>#0
-
8/9/2019 Petclinic Documentation
14/20
Based on project Dandelion http://dandelion.github.com/
Datatables in Spring MVC
14
-
8/9/2019 Petclinic Documentation
15/20
Click, sort, scroll, next/previous!
Bootstrap theme
PDF export!
Dandelion is based on
jQuery Datatables and Bootstrap
-
8/9/2019 Petclinic Documentation
16/20
F6"$+0
E6#) !"#$%&
F.) L)4 ,>:)# !"#$%& JIE
F.$#8'">#*: K)4 ,$4#>#$)0
C>%8),$6%
L)4@>#0
-
8/9/2019 Petclinic Documentation
17/20
Allow CSS and JS libraries to be imported as
Maven libraries Used in Petclinic for jQuery, jQuery-ui, datatables,
Bootstrap
http://www.webjars.org/
Webjars
-
8/9/2019 Petclinic Documentation
18/20
Webjars
org.webjarsjquery-ui1.9.1
pom.xml
-
8/9/2019 Petclinic Documentation
19/20
Using Webjars
19
Inside pom.xml Spring configuration
Inside JSP
org.webjarsjquery-ui
1.9.1
js file is inside a jar file!
-
8/9/2019 Petclinic Documentation
20/20
M)9)#)%+)0
!)#$)0 69 [ 4,6& )%*#$)0 9#67 @3,$)% C346$0 6% .6K *6\$7"#6Q) ")#96#7>%+) 69 *.) !"#$%&'()*+,$%$+ >"",$+>G6%]
./"1224,6&5$""6%59#2T^S;2^;2SS2
C>%8),$6%1 +,$+_>4,)206#*>4,) 8>*>*>*>4,)0 $%0$8) !"#$%&'
()*+,$%$+
./"1228>%8),$6%5&$*.345$624,6&2T^S;2^`2T`2Z%*)>G%&'C>%8),$6%'
C>*>F>4,)0'$%'*.)'!"#$%&'()*+,$%$+'>""
T^