Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework,

Slides:



Advertisements
Similar presentations
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Tool Naming Tips Aaron Zeckoski
Advertisements

Introduction to Spring Continued Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack.
Spring, Hibernate and Web Services 13 th September 2014.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmers’ Café Sakai NWU Workshop, South Africa Recap of Sakai Services Antranig.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Enterprise Application Development Sadegh Aliakbary An Introduction to Spring Framework www. JavaCup.ir.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
1 Web Applications – Design Issues. 2 Data Requirements –Persistent –Consistent (no corruption even if server fails) –Concurrent updates –Transactions.
1 November 21st 2009 Shaun Abram An Introduction to Spring.
The Spring Framework: A brief introduction to Inversion of Control James Brundege
Last Update: 5/15/061 Spring J2EE Framework Ram A. Rao May 15 th ‘05.
Intro to Spring CJUG - January What is Spring? “The Spring framework provides central transaction control of various objects.” This means that any.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Spring Framework Adam Waldal Senior Consultant. About me..  OPI is a leader in J2EE consulting with Relationships with BEA, IBM, Tibco, and many other.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Data Persistence and Intro to Hibernate.
Spring Basic Bean wiring
Lecture 2 - Struts ENTERPRISE JAVA. 2 Contents  Servlet Deployment  Servlet Filters  Model View Controllers  Struts  Dependency Injection.
Intermediate Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Spring Framework. Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one.
Introduction to the Spring Framework By: Nigusse A. Duguma Kansas State university Department of Computer Science Nov 20, 2007.
Spring Overview, Application demo -Midhila Paineni 09/23/2011 Spring Overview, Application demo9/8/20151.
The Spring Framework Training Get to know Spring Framework Rohit Prabhakar
Introduction to the Spring Framework Rajesh. Spring Mission Statement J2EE should be easier to use OO design is more important than any implementation.
OpusCollege and the use of Spring and iBatis
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Understanding the Bean Lifecycle An.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
Dependency Injection in Action Jan Västernäs. CADEC2006, DI, Slide 2 Copyright 2006, Callista Enterprise AB Agenda (DI=Dependency Injection) Background.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
Standalone Java Application vs. Java Web Application
Text 16 de mayo de 2009 Spring Framework Part I. Dependency Injection Buenos Aires, May 2009.
Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.
Spring Framework. Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License RSF Wiki Introduction to Reasonable Server Faces Aaron Zeckoski
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Spring Training 17/09/ Dependency Injection.
Introduction to Web Dimitar Nenchev Ivan Nakov
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Persistence and Hibernate Aaron Zeckoski
Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake
Spring 101 Struts University Series. About Ted Husted Lead author, Struts in Action Co-Author, JUnit in Action Member, Apache Software Foundation Member,
A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai development and app/tool tips Aaron Zeckoski
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Sakai code exercises Aaron Zeckoski.
Sakai WebApp Structure
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Spring and DWR Frameworks for Rich Web Enterprise Application Thomas Wiradikusuma Presentation to the 20 th.
1 Spring Framework April, 2012 Lam Ho Lam To. © 2010 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 2 1.Spring Overview 2.Framework.
Dependency Injection Frameworks Technion – Institute of Technology Author: Assaf Israel - Technion 2013 ©
Dependency Injection JAVA EE - Spring Framework. Inner Beans As you know Java inner classes are defined within the scope of other classes, similarly,
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Introduction to Reasonable Server Faces Aaron Zeckoski
Kansas City Java User’s Group Jason W. Bedell July 12, 2006
Give a few Reasons for using Java?
Singleton Pattern. Problem Want to ensure a single instance of a class, shared by all uses throughout a program Context Need to address initialization.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
Dependency Injection with Guice Technion – Institute of Technology Author: Gal Lalouche - Technion 2016 ©
Introduction to Inversion Of Control (IOC). IOC Definition (based on Wikipedia)  Consider the way in which an object obtains references to its dependencies.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Comparative Display Technologies.
C# Programming: From Problem Analysis to Program Design1 Creating Your Own Classes C# Programming: From Problem Analysis to Program Design 4th Edition.
CS520 Web Programming Spring – Inversion of Control Chengyu Sun California State University, Los Angeles.
J2EE Lecture 6: Spring – IoC and Dependency Injection
Structure of a web application
Spring Boot Introduction
CS520 Web Programming Spring – Inversion of Control
Aaron Zeckoski Sakai Tool Naming Tips Aaron Zeckoski
Sakai WebApp Structure
By Ru Shen Department of Computer Science UAlbany, 2008
Intro to Spring CJUG - January 2013.
Introduction to Spring Framework and Dependency Injection
Leveraging ColdSpring To Make Better Applications
Presentation transcript:

Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework, IoC, and Injection Aaron Zeckoski

2 Spring Framework The Spring Framework has become the new standard in Java application frameworks and developmentapplication frameworks –Ubiquitous for Java development –Well established in enterprise Java apps –Time tested and proven reliable Spring code base is proven to be well structured (possibly the best) – URL:

3 More Spring Considered an alternative / replacement for the Enterprise JavaBean (EJB) model Flexible –Programmers decide how to program Not exclusive to Java (e.g..NET) Solutions to typical coding busywork –JDBC –LDAP –Web Services

4 What does Spring offer? Dependency Injection –Also known as IoC (Inversion of Control) Aspect Oriented Programming –Runtime injection-based Portable Service Abstractions –The rest of spring ORM, DAO, Web MVC, Web, etc.

5 Dependency Injection defined This is the central part of Spring –Also called Inversion of Control (IoC) Traditional method is to create needed dependencies or look them up somehow IoC injects needed dependencies into the object instead –Setters or Contructor Primary goal is reduction of dependencies in code URL:

6 Aspect Oriented Programming defined TODO URL:

7 Portable Service Abstractions defined TODO

8 What is a bean? Typical java bean with a unique id In spring there are basically two types –Singleton One instance of the bean created and referenced each time it is requested –Prototype (non-singleton) New bean created each time Same as new ClassName() Beans are normally created by Spring as late as possible

9 What is a bean definition? Defines a bean for Spring to manage –Key attributes class (required): fully qualified java class name id: the unique identifier for this bean configuration: (singleton, init-method, etc.) contructor-arg: arguments to pass to the constructor at creation time property: arguments to pass to the bean setters at creation time Collaborators: other beans needed in this bean (a.k.a dependencies), specified in property or constructor-arg Typically defined in an XML file

10 Sample bean definition 1 public class ExampleBean { private AnotherBean beanOne; private YetAnotherBean beanTwo; private int i; public void setBeanOne(AnotherBean beanOne) { this.beanOne = beanOne; } public void setBeanTwo(YetAnotherBean beanTwo) { this.beanTwo = beanTwo; } public void setIntegerProperty(int i) { this.i = i; } … }

11 What is a bean factory? Typically referred to as an ApplicationContext (though it is a superclass) –Sometimes called a Core Container Spring uses a BeanFactory to create, manage and locate “beans” which are basically instances of a class Typical usage is an XML bean factory which allows configuration via XML files

12 Beans are created in order based on the dependency graph –Often they are created when the factory loads the definitions Spring will instantiate beans as late as possible in order to avoid conflicts –Can override this behavior in bean You can also override this in the factory or context but this is not recommended How are beans created?

13 How are beans injected?

14 Multiple bean config files There are 2 ways to load multiple bean config files (allows for logical division of beans) –Use the import tag –Load multiple config files using Resources in the application context constructor Recommended by the spring team Not always possible though ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( new String[] {"applicationContext.xml", "applicationContext- part2.xml"});

15 Bean properties? The primary method of dependency injection Can be another bean, value, collection, etc. This can be written in shorthand as follows

16 Anonymous vs id Beans that do not need to be referenced elsewhere can be defined anonymously This bean is not anonymous This bean is anonymous

17 What is an inner bean? It is a way to define a bean needed by another bean in a shorthand way –Always anonymous (id is ignored) –Always prototype (non-singleton) Tony 51

18 Bean init-method

19 Bean values

20 Abstract (parent) beans

21 Working example