SlideShare una empresa de Scribd logo
1 de 10
Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit
Spring Quick Start
Introducing the Spring Application Context and
Spring’s XML-based configuration language
2
Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit
Topics in this session
• Spring quick start
• Writing bean definitions
– Configuring objects
– Going beyond constructor instantiation
• Creating an application context
• Summary
3
Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit
How Spring Works
Spring
ApplicationContext
Configuration
Instructions
Your Application Classes (POJOs)
Fully configured
application system
Ready for use
Creates
4
Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit
Your Application Classes
public class TransferServiceImpl implements TransferService {
public TransferServiceImpl(AccountRepository ar) {
this.accountRepository = ar;
}
…
}
public class JdbcAccountRepository implements AccountRepository {
public JdbcAccountRepository(DataSource ds) {
this.dataSource = ds;
}
…
}
Needed to load accounts from the database
Needed to perform money transfers
between accounts
5
Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit
Configuration Instructions
<beans>
<bean id=“transferService” class=“app.impl.TransferServiceImpl”>
<constructor-arg ref=“accountRepository” />
</bean>
<bean id=“accountRepository” class=“app.impl.JdbcAccountRepository”>
<constructor-arg ref=“dataSource” />
</bean>
<bean id=“dataSource” class=“com.oracle.jdbc.pool.OracleDataSource”>
<property name=“URL” value=“jdbc:oracle:thin:@localhost:1521:BANK” />
<property name=“user” value=“moneytransfer-app” />
</bean>
</beans>
6
Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit
Creating and Using the
Application
// Create the application from the configuration
ApplicationContext context =
new ClassPathXmlApplicationContext(“application-config.xml”);
// Look up the application service interface
TransferService service =
(TransferService) context.getBean(“transferService”);
// Use the application
service.transfer(new MonetaryAmount(“300.00”), “1”, “2”);
7
Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit
Inside the Spring Application
Context
// Create the application from the configuration
ApplicationContext context =
new ClassPathXmlApplicationContext(“application-config.xml”);
Application Context
OracleDataSource
dataSource
JdbcAccountRepository
accountRepository
TransferServiceImpl
transferService
8
Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit
Quick Start Summary
• Spring manages the lifecycle of the application
– All beans are fully initialized before they are used
• Beans are always created in the right order
– Based on their dependencies
• Each bean is bound to a unique id
– The id reflects the service the bean provides to clients
• The ApplicationContext works as a container,
encapsulating the bean implementations
chosen for a given deployment
– Conceals implementation details
9
Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit
Topics in this session
• Spring quick start
• Writing bean definitions
– Configuring objects
– Going beyond constructor instantiation
• Creating an application context
• Summary
10
Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit
Register…
To register for this training please visit
http://www.springpeople.com/courses/regular/spr-001.php
For further info please contact
SpringPeople Technologies
info@springpeople.com
+91 80 4114 6519
http://www.springpeople.com

Más contenido relacionado

Destacado

Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsGuy Nir
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVCGuy Nir
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Tuna Tore
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework Serhat Can
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 

Destacado (9)

Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Spring framework core
Spring framework coreSpring framework core
Spring framework core
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 

Último

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Último (20)

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

Spring-framework-Training,core spring 3.0,spring training,springpeople

  • 1. Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit Spring Quick Start Introducing the Spring Application Context and Spring’s XML-based configuration language
  • 2. 2 Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit Topics in this session • Spring quick start • Writing bean definitions – Configuring objects – Going beyond constructor instantiation • Creating an application context • Summary
  • 3. 3 Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit How Spring Works Spring ApplicationContext Configuration Instructions Your Application Classes (POJOs) Fully configured application system Ready for use Creates
  • 4. 4 Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit Your Application Classes public class TransferServiceImpl implements TransferService { public TransferServiceImpl(AccountRepository ar) { this.accountRepository = ar; } … } public class JdbcAccountRepository implements AccountRepository { public JdbcAccountRepository(DataSource ds) { this.dataSource = ds; } … } Needed to load accounts from the database Needed to perform money transfers between accounts
  • 5. 5 Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit Configuration Instructions <beans> <bean id=“transferService” class=“app.impl.TransferServiceImpl”> <constructor-arg ref=“accountRepository” /> </bean> <bean id=“accountRepository” class=“app.impl.JdbcAccountRepository”> <constructor-arg ref=“dataSource” /> </bean> <bean id=“dataSource” class=“com.oracle.jdbc.pool.OracleDataSource”> <property name=“URL” value=“jdbc:oracle:thin:@localhost:1521:BANK” /> <property name=“user” value=“moneytransfer-app” /> </bean> </beans>
  • 6. 6 Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit Creating and Using the Application // Create the application from the configuration ApplicationContext context = new ClassPathXmlApplicationContext(“application-config.xml”); // Look up the application service interface TransferService service = (TransferService) context.getBean(“transferService”); // Use the application service.transfer(new MonetaryAmount(“300.00”), “1”, “2”);
  • 7. 7 Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit Inside the Spring Application Context // Create the application from the configuration ApplicationContext context = new ClassPathXmlApplicationContext(“application-config.xml”); Application Context OracleDataSource dataSource JdbcAccountRepository accountRepository TransferServiceImpl transferService
  • 8. 8 Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit Quick Start Summary • Spring manages the lifecycle of the application – All beans are fully initialized before they are used • Beans are always created in the right order – Based on their dependencies • Each bean is bound to a unique id – The id reflects the service the bean provides to clients • The ApplicationContext works as a container, encapsulating the bean implementations chosen for a given deployment – Conceals implementation details
  • 9. 9 Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit Topics in this session • Spring quick start • Writing bean definitions – Configuring objects – Going beyond constructor instantiation • Creating an application context • Summary
  • 10. 10 Copyright 2005-2008 SpringSource. Copying, publishing or distributing without express written permission is prohibit Register… To register for this training please visit http://www.springpeople.com/courses/regular/spr-001.php For further info please contact SpringPeople Technologies info@springpeople.com +91 80 4114 6519 http://www.springpeople.com