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

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Dernier (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

สปริงเฟรมเวิร์ค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