SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Andere mochten auch

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
 

Andere mochten auch (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
 

Kürzlich hochgeladen

Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
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 . pdfQucHHunhnh
 

Kürzlich hochgeladen (20)

Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
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
 

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