SlideShare une entreprise Scribd logo
1  sur  47
สปริงเฟรมเวิร์คเวิร์คชอป(Spring Framework Workshop) By www.spring66.com มิถุนายน 2553, 12 ชัดเจน “เขียนจาวาไม่ใช้สปริง บาป”
@roofimonขอ ขอบคุณTA ไม่มี TA ไม่มีงานนี้ครับ @somkiat พระ @9tae ไปบวชอยู่ @poorprogrammer @nuboat @YashimaExteen @boyone @siros_s มาสอน AOP ตอนบ่าย TA เป็นผู้ทรงคุณวุฒิเรื่องสปริงทุกท่าน
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
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
ที่มาของเนื้อหา(ลอกมาจากไหน) Building Spring2 Enterprise Application Development J2EE without EJB Professional Spring Framework Spring2 in Action Pro Spring2 Spring Recipe หนังสืออ้างอิงเยอะมาก
The Spring Framework ,[object Object]
Spring provides comprehensive infrastructure support for developing Java applications
Infrastructure??????,[object Object]
lightweight Container (Value Added) Transaction Thread management Object pooling Clustering Management Remoting Exposing remote services Consuming remote services Customization and extensibility AOP
ทำไมต้องสปริง เมื่อก่อน Java เตรียมเครื่องมือไว้ให้เยอะไปหมดแต่เวลาใช้ ?  Design Pattern: ต้องนั่งตีความเอาเอง กระบวนการรวมฟีเจอร์ของ SUN โหดร้ายเกินไป ชีวิตเราถูกผูกติดกับ Application Server, API มากเกินไป อยากเอาฟีเจอร์มารวมกันพร้อมทั้งใช้ Design Pattern ด้วย ? Light Weight
สมัยนี้
Main Components
Layer of Application
Bean? Bean is a service Service = Interface+Implement+Descriptor Bean อาศัยอยู่ใน Bean Factory หรือ Application Context Application Context คือหัวใจของ Spring คิดไม่ออกต้องสร้าง Application Context ขึ้นมาก่อน
Configuration ส่วนมากจะชื่อ applicationContect.xml
Initial Context //Load Context Manually From AppConfig.class ApplicationContext context =  		new FileSystemXmlApplicationContext( 		"classpath:/applicationContext.xml"); //Lookup Bean named   Clinic clinic = (Clinic)context.getBean(“clinic”); Collection<Vet> vets = clinic.getVets();
The “PetClinic”
The “Lightweight Container” Architecture
Basic Architecture Spring JDBC Spring Core Spring Web MVC JSP jQuery
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
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”.
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”.
What we have done?
Why Test First Test case is “META-CODE”, code that explains code. Feel confident for refactor, move and share.
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;     }
Go more deep into “DataSource” DB Persistence Manager Oracle MsSQL DB2 MySQL Hibernate iBatis OpenJPA Connection Data Source
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)
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>
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.
Spring JDBC
Go more deep into Spring JDBC JdbcTemplate NamedParameterJdbcTemplate  SimpleJdbcTemplate  SimpleJdbcInsert and SimpleJdbcCall  RDBMS Objects including MappingSqlQuery, SqlUpdate and StoredProcedure
Go more deep into Spring JDBC DataSource Prepared Statement Mapper Extractor
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
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
Spring DispatcherServlet
Dispatcher Servlet <web-app>   <servlet>    <servlet-name>example</servlet-name>     <servlet-class>     org.springframework.web.servlet.DispatcherServlet    </servlet-class>    <load-on-startup>1</load-on-startup>  </servlet>   <servlet-mapping>   <servlet-name>example</servlet-name>   <url-pattern>*.form</url-pattern>   </servlet-mapping>   </web-app>
Example-servlet.xml <context:component-scan base-package="com.spring66.petclinic.web"/> <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0"/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" 			p:suffix=".jsp" p:order="1"/> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" 			p:basename="messages"/>
Context Hierarchy
Web Layer Web  Context Spring Context ,[object Object],org.springframework.web.context.ContextLoaderListener web.xml Web  Context Spring Context
Bootstrapping web applications ,[object Object],<listener>  	<listener-class> 		org.springframework.web.context.ContextLoaderListener 	</listener-class> </listener> <context-param> 	<param-name>contextConfigLocation</param-name>    <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param>
Still have xxx-servlet.xml ,[object Object]
<context:component-scan 	base-package="com.spring66.petclinic.web"/> ,[object Object],[object Object]
First Controller ,[object Object]
And then Copy Content from Main Project
srcainavaompring66etcliniceb
====ClinicController======

Contenu connexe

Tendances

The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
Hybrid Web Applications
Hybrid Web ApplicationsHybrid Web Applications
Hybrid Web ApplicationsJames Da Costa
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)True-Vision
 
Django - 次の一歩 gumiStudy#3
Django - 次の一歩 gumiStudy#3Django - 次の一歩 gumiStudy#3
Django - 次の一歩 gumiStudy#3makoto tsuyuki
 
The effective use of Django ORM
The effective use of Django ORMThe effective use of Django ORM
The effective use of Django ORMYaroslav Muravskyi
 
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)Peter Lehto
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone InteractivityEric Steele
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Storiesrahoulb
 
Tips and tricks for building api heavy ruby on rails applications
Tips and tricks for building api heavy ruby on rails applicationsTips and tricks for building api heavy ruby on rails applications
Tips and tricks for building api heavy ruby on rails applicationsTim Cull
 
Maintainable JavaScript 2012
Maintainable JavaScript 2012Maintainable JavaScript 2012
Maintainable JavaScript 2012Nicholas Zakas
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?brynary
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kianphelios
 
Gaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App EngineGaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App EngineTim Berglund
 
Moving from Django Apps to Services
Moving from Django Apps to ServicesMoving from Django Apps to Services
Moving from Django Apps to ServicesCraig Kerstiens
 

Tendances (19)

The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Hybrid Web Applications
Hybrid Web ApplicationsHybrid Web Applications
Hybrid Web Applications
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)
 
Django - 次の一歩 gumiStudy#3
Django - 次の一歩 gumiStudy#3Django - 次の一歩 gumiStudy#3
Django - 次の一歩 gumiStudy#3
 
The effective use of Django ORM
The effective use of Django ORMThe effective use of Django ORM
The effective use of Django ORM
 
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Stories
 
Tips and tricks for building api heavy ruby on rails applications
Tips and tricks for building api heavy ruby on rails applicationsTips and tricks for building api heavy ruby on rails applications
Tips and tricks for building api heavy ruby on rails applications
 
Jsp1
Jsp1Jsp1
Jsp1
 
GAEO
GAEOGAEO
GAEO
 
Jsp
JspJsp
Jsp
 
Maintainable JavaScript 2012
Maintainable JavaScript 2012Maintainable JavaScript 2012
Maintainable JavaScript 2012
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kian
 
Django a whirlwind tour
Django   a whirlwind tourDjango   a whirlwind tour
Django a whirlwind tour
 
Gaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App EngineGaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App Engine
 
Fast by Default
Fast by DefaultFast by Default
Fast by Default
 
Moving from Django Apps to Services
Moving from Django Apps to ServicesMoving from Django Apps to Services
Moving from Django Apps to Services
 

Similaire à สปริงเฟรมเวิร์ค4.1

Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesJohn Brunswick
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentationipolevoy
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax componentsIgnacio Coloma
 
KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7phuphax
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog SampleSkills Matter
 
Going Offline with Gears And GWT
Going Offline with Gears And GWTGoing Offline with Gears And GWT
Going Offline with Gears And GWTtom.peck
 
Uma introdução ao framework Spring
Uma introdução ao framework SpringUma introdução ao framework Spring
Uma introdução ao framework Springelliando dias
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklum Ukraine
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniternicdev
 
The vJUG talk about jOOQ: Get Back in Control of Your SQL
The vJUG talk about jOOQ: Get Back in Control of Your SQLThe vJUG talk about jOOQ: Get Back in Control of Your SQL
The vJUG talk about jOOQ: Get Back in Control of Your SQLLukas Eder
 
Apache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onApache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onMatt Raible
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVCAlan Dean
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixBruce Snyder
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and DashboardsAtlassian
 
Spring MVC
Spring MVCSpring MVC
Spring MVCyuvalb
 
Aspnet2 Overview
Aspnet2 OverviewAspnet2 Overview
Aspnet2 Overviewajitbergi
 

Similaire à สปริงเฟรมเวิร์ค4.1 (20)

I Feel Pretty
I Feel PrettyI Feel Pretty
I Feel Pretty
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax components
 
Spring and DWR
Spring and DWRSpring and DWR
Spring and DWR
 
KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7
 
Jsp
JspJsp
Jsp
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog Sample
 
Going Offline with Gears And GWT
Going Offline with Gears And GWTGoing Offline with Gears And GWT
Going Offline with Gears And GWT
 
Uma introdução ao framework Spring
Uma introdução ao framework SpringUma introdução ao framework Spring
Uma introdução ao framework Spring
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter
 
The vJUG talk about jOOQ: Get Back in Control of Your SQL
The vJUG talk about jOOQ: Get Back in Control of Your SQLThe vJUG talk about jOOQ: Get Back in Control of Your SQL
The vJUG talk about jOOQ: Get Back in Control of Your SQL
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
 
Apache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onApache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-on
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVC
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and Dashboards
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Aspnet2 Overview
Aspnet2 OverviewAspnet2 Overview
Aspnet2 Overview
 

Plus de ทวิร พานิชสมบัติ

Plus de ทวิร พานิชสมบัติ (20)

Devops maturity model
Devops maturity modelDevops maturity model
Devops maturity model
 
Crafting Culture
Crafting CultureCrafting Culture
Crafting Culture
 
Go: Programming Language for Cloud
Go: Programming Language for CloudGo: Programming Language for Cloud
Go: Programming Language for Cloud
 
LeSS
LeSSLeSS
LeSS
 
Legacy Code For Management
Legacy Code For ManagementLegacy Code For Management
Legacy Code For Management
 
Security As A Code :
Security As A Code : Security As A Code :
Security As A Code :
 
ATDD
ATDDATDD
ATDD
 
กระบวนการเชิงประจักษ์ (Empirical Process)
กระบวนการเชิงประจักษ์ (Empirical Process)กระบวนการเชิงประจักษ์ (Empirical Process)
กระบวนการเชิงประจักษ์ (Empirical Process)
 
Geeky Ademy Schedule 2nd Batch
Geeky Ademy Schedule 2nd BatchGeeky Ademy Schedule 2nd Batch
Geeky Ademy Schedule 2nd Batch
 
การทำซอฟท์แวร์ภายใน 30 วัน
การทำซอฟท์แวร์ภายใน 30 วันการทำซอฟท์แวร์ภายใน 30 วัน
การทำซอฟท์แวร์ภายใน 30 วัน
 
Geek Academy Schedule
Geek Academy ScheduleGeek Academy Schedule
Geek Academy Schedule
 
Kku2011
Kku2011Kku2011
Kku2011
 
Scrum version3
Scrum version3Scrum version3
Scrum version3
 
Geeky academy
Geeky academyGeeky academy
Geeky academy
 
Agile
AgileAgile
Agile
 
Bdd bug day2013
Bdd bug day2013Bdd bug day2013
Bdd bug day2013
 
Scrum Version 3
Scrum Version 3Scrum Version 3
Scrum Version 3
 
Fixie atbarcampbangkok5
Fixie atbarcampbangkok5Fixie atbarcampbangkok5
Fixie atbarcampbangkok5
 
Scrum version2
Scrum version2Scrum version2
Scrum version2
 
Agile V2
Agile V2Agile V2
Agile V2
 

Dernier

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 

Dernier (20)

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

สปริงเฟรมเวิร์ค4.1

  • 1. สปริงเฟรมเวิร์คเวิร์คชอป(Spring Framework Workshop) By www.spring66.com มิถุนายน 2553, 12 ชัดเจน “เขียนจาวาไม่ใช้สปริง บาป”
  • 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 หนังสืออ้างอิงเยอะมาก
  • 6.
  • 7. Spring provides comprehensive infrastructure support for developing Java applications
  • 8.
  • 9. lightweight Container (Value Added) Transaction Thread management Object pooling Clustering Management Remoting Exposing remote services Consuming remote services Customization and extensibility AOP
  • 10. ทำไมต้องสปริง เมื่อก่อน Java เตรียมเครื่องมือไว้ให้เยอะไปหมดแต่เวลาใช้ ? Design Pattern: ต้องนั่งตีความเอาเอง กระบวนการรวมฟีเจอร์ของ SUN โหดร้ายเกินไป ชีวิตเราถูกผูกติดกับ Application Server, API มากเกินไป อยากเอาฟีเจอร์มารวมกันพร้อมทั้งใช้ Design Pattern ด้วย ? Light Weight
  • 12.
  • 15. Bean? Bean is a service Service = Interface+Implement+Descriptor Bean อาศัยอยู่ใน Bean Factory หรือ Application Context Application Context คือหัวใจของ Spring คิดไม่ออกต้องสร้าง Application Context ขึ้นมาก่อน
  • 17. Initial Context //Load Context Manually From AppConfig.class ApplicationContext context = new FileSystemXmlApplicationContext( "classpath:/applicationContext.xml"); //Lookup Bean named Clinic clinic = (Clinic)context.getBean(“clinic”); Collection<Vet> vets = clinic.getVets();
  • 20. Basic Architecture Spring JDBC Spring Core Spring Web MVC JSP jQuery
  • 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”.
  • 24. What we have done?
  • 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
  • 37. Dispatcher Servlet <web-app> <servlet> <servlet-name>example</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>example</servlet-name> <url-pattern>*.form</url-pattern> </servlet-mapping> </web-app>
  • 38. Example-servlet.xml <context:component-scan base-package="com.spring66.petclinic.web"/> <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0"/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" p:order="1"/> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" p:basename="messages"/>
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45. And then Copy Content from Main Project
  • 49.
  • 50. And then Copy Content from Web.text
  • 52.
  • 54. Copy content from “Web.txt”
  • 56. There are two interesting parts:
  • 57. Inject “clinic” service into controller
  • 60. @Request over “public Collection<Vet> list()”
  • 61.
  • 62. And then Copy Content from Web.text
  • 64.
  • 65. Copy content from “Web.txt”
  • 67. If it works so move forward
  • 68. Do some magic by adding new Owner
  • 69. Copy content from “Web.txt”
  • 72. Copy content from “Web.txt”
  • 74. Create “PageType”.. Good u can guest, next