2. @roofimonขอ ขอบคุณTA ไม่มี TA ไม่มีงานนี้ครับ @somkiat พระ @9tae ไปบวชอยู่ @poorprogrammer @nuboat @YashimaExteen @boyone @siros_s มาสอน AOP ตอนบ่าย TA เป็นผู้ทรงคุณวุฒิเรื่องสปริงทุกท่าน
3. Agenda Impossible is nothing Why Spring? New Features and Enhancements in Spring 3.0 Core Container 3.0 Persistence with Spring JDBC AOP (@siros_s) EhCache(Apply AOP) Spring Web MVC with Web Annotation
4. Basic Requirements JDK 1.6 ++ Maven 2.0.x Apache Derby Netbeans, Eclipse, Vi, Whatever IDE Skeleton Source from http://code.google.com/p/spring66-training-3/svn/branches/1.0.PRE Full https://spring66-training-3.googlecode.com/svn/branches/1.9PRE
5. ที่มาของเนื้อหา(ลอกมาจากไหน) Building Spring2 Enterprise Application Development J2EE without EJB Professional Spring Framework Spring2 in Action Pro Spring2 Spring Recipe หนังสืออ้างอิงเยอะมาก
15. Bean? Bean is a service Service = Interface+Implement+Descriptor Bean อาศัยอยู่ใน Bean Factory หรือ Application Context Application Context คือหัวใจของ Spring คิดไม่ออกต้องสร้าง Application Context ขึ้นมาก่อน
21. Basic Requirement Use Cases View a list of veterinarians and their specialties View information pertaining to a pet owner Update the information pertaining to a pet owner Add a new pet owner to the system View information pertaining to a pet Update the information pertaining to a pet Add a new pet to the system View information pertaining to a pet's visitation history Add information pertaining to a visit to the pet's visitation history Business Rules An owner may not have multiple pets with the same case-insensitive name
22. Checkout Code from Google Code Create Test Case Call “isClinicServiceReady” @Autowired protected Clinic clinic; @Test public void isCliniceReady() { assertNotNull(clinic); } We have done creating our first “bean”.
23. Checkout Code from Google Code Create “interface Clinic” Run Test (Fail!!!!!) Create applicationContect.xml Copy content from “Master Project” “srcestesourcesrgpring66raining3estetclinicaseline” Run Test !!!!!! We have done creating our first “bean”.
25. Why Test First Test case is “META-CODE”, code that explains code. Feel confident for refactor, move and share.
26. Checkout Code from Google Code Create “interface ListDataService” Create “class ListDataServiceImpl” @Override public List getElementsList() { List list = new ArrayList(); list.add("Tom"); list.add("Henri"); list.add("Jim"); return list; }
27. Go more deep into “DataSource” DB Persistence Manager Oracle MsSQL DB2 MySQL Hibernate iBatis OpenJPA Connection Data Source
28. Go more deep into “DataSource” Basically we must have this information for datasource Driver Class Driver Class Name Connection String (URL) Username Password Plus some optional parameters depends on Driver Manager (Pool Size, Wait Time, bla bla bla)
29. Go more deep into DataSource Basically we must have this information <bean id="dataSource" class=“$Driver"> <!-- Connection Info --> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- Connection Pooling DBCP --> <property name="initialSize" value="5"/> <property name="maxActive" value="100" /> <property name="maxIdle" value="30" /> <property name="maxWait" value="1000" /> <property name="poolPreparedStatements" value="true" /> <property name="defaultAutoCommit" value="false" /> </bean>
30. Spring JDBC The value-add provided by the Spring Framework JDBC abstraction is perhaps best shown by the sequence of actions outlined in the table.
32. Go more deep into Spring JDBC JdbcTemplate NamedParameterJdbcTemplate SimpleJdbcTemplate SimpleJdbcInsert and SimpleJdbcCall RDBMS Objects including MappingSqlQuery, SqlUpdate and StoredProcedure
33. Go more deep into Spring JDBC DataSource Prepared Statement Mapper Extractor
34. Move up to Service Layer The most important part of our Application. All business logics are located, here Test it carefully, change very often. Controller Service Entity A Entity B Entity C
35. Spring Web MVC Flow Clear separation of roles Powerful and straightforward configuration of both framework and application classes as JavaBeans. Adaptability, non-intrusiveness, and flexibility. Customizable binding and validation Customizable handler mapping and view resolution Flexible model transfer Beans whose lifecycle is scoped to the current HTTP request or HTTP Session