SlideShare uma empresa 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

Mais conteúdo relacionado

Destaque

Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
Guy 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 HTML5
Tuna Tore
 

Destaque (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

Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Último (20)

Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
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
 
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
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
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
 

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