Corespring

459 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
459
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Emphasize this presentation will show how to hit the ground running with core Spring feature set.
  • The quick start should be “quick” -- communicate at a high level what has to be done to get a basic Spring-powered application up and running
  • Let’s start with a high level picture of how Spring works… A good analogy is an automobile plant. At a auto plant cars are assembled from parts on an assembly line. Workers on the line have an instruction manual that tells how to piece together the parts to build a car. So, you can view Spring as an application assembler where the parts are your Java components, and the instructions provided to Spring act as the manual for the assembly process. After assembly, you have a fully configured system ready to be used--just like after car assembly, you have a fully configured car ready to be driven. Parts can be interchanged, can be used in other vehicles (systems), etc.
  • Focus on the relationships between the elements rather than they syntax itself.
  • Corespring

    1. 1. Spring Quick Start Introducing the Spring Application Context and Spring’s XML-based configuration language
    2. 2. Topics in this session <ul><li>Spring quick start </li></ul><ul><li>Writing bean definitions </li></ul><ul><ul><li>Configuring objects </li></ul></ul><ul><ul><li>Going beyond constructor instantiation </li></ul></ul><ul><li>Creating an application context </li></ul><ul><li>Summary </li></ul>
    3. 3. How Spring Works Spring ApplicationContext Fully configured application system Ready for use Configuration Instructions Your Application Classes (POJOs) Creates
    4. 4. Your Application Classes <ul><li>public class TransferServiceImpl implements TransferService { </li></ul><ul><li>public TransferServiceImpl(AccountRepository ar) { </li></ul><ul><li>this . accountRepository = ar; </li></ul><ul><li>} </li></ul><ul><li>… </li></ul><ul><li>} </li></ul>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. 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. 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. Inside the Spring A pplication Context // Create the application from the configuration ApplicationContext context = new ClassPathXmlApplicationContext( “application-config.xml” ); Application Context OracleDataSource dataSource JdbcAccountRepository accountRepository TransferServiceImpl transferService
    8. 8. Quick Start Summary <ul><li>Spring manages the lifecycle of the application </li></ul><ul><ul><li>All beans are fully initialized before they are used </li></ul></ul><ul><li>Beans are always created in the right order </li></ul><ul><ul><li>Based on their dependencies </li></ul></ul><ul><li>Each bean is bound to a unique id </li></ul><ul><ul><li>The id reflects the service the bean provides to clients </li></ul></ul><ul><li>The ApplicationContext works as a container, encapsulating the bean implementations chosen for a given deployment </li></ul><ul><ul><li>Conceals implementation details </li></ul></ul>
    9. 9. Topics in this session <ul><li>Spring quick start </li></ul><ul><li>Writing bean definitions </li></ul><ul><ul><li>Configuring objects </li></ul></ul><ul><ul><li>Going beyond constructor instantiation </li></ul></ul><ul><li>Creating an application context </li></ul><ul><li>Summary </li></ul>
    10. 10. Register… To register for this training please visit http://www.springpeople.com/courses/regular/spr-001.php For further info please contact SpringPeople Technologies [email_address] +91 80 4114 6519 http://www.springpeople.com

    ×