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

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

SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 

Kürzlich hochgeladen (20)

How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Benefits and Challenges of OER by Shweta Babel.pptx
Benefits and Challenges of OER by Shweta Babel.pptxBenefits and Challenges of OER by Shweta Babel.pptx
Benefits and Challenges of OER by Shweta Babel.pptx
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 Inventory
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 

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