Introduction to Inversion Of Control (IOC). IOC Definition (based on Wikipedia)  Consider the way in which an object obtains references to its dependencies.

Slides:



Advertisements
Similar presentations
Welcome to CODE SPREAD Simple Concepts of Coding | Programming.
Advertisements

PHP functions What are Functions? A function structure:
Spring Auto wiring Auto wiring Resolves the beans that need to be injected by inspecting the elements in ApplicationContext.
Inner Classes. Nested Classes  An nested class is a class that is defined inside another class.  To this point we have only studied top-level classes.
Spring, Hibernate and Web Services 13 th September 2014.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Liang,Introduction to Java Programming,revised by Dai-kaiyu 1 Chapter 10 Object-Oriented Modeling.
Spring.Net Steinar Dragsnes steinar.dragsnes at viz.no.
Week 3 Recap CSE 115 – Spring Constructor Special capability of a class that sets up the initial state of the object. Constructor definitions are.
The Spring Framework: A brief introduction to Inversion of Control James Brundege
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Lecture 2 - Struts ENTERPRISE JAVA. 2 Contents  Servlet Deployment  Servlet Filters  Model View Controllers  Struts  Dependency Injection.
CVSQL 2 The Design. System Overview System Components CVSQL Server –Three network interfaces –Modular data source provider framework –Decoupled SQL parsing.
Dependency Injection and Model-View-Controller. Overview Inversion of Control Model-View-Controller.
Java Frameworks Indy Java Users Group January 29, 2003.
Design Patterns Standardized Recurring model Fits in many location Opposite of customization Fundamental types of pattern Choose and use as desired and.
Spring Overview, Application demo -Midhila Paineni 09/23/2011 Spring Overview, Application demo9/8/20151.
An Introduction to Software Architecture
Setting up for TTD in Visual Studio 2012 Project | Manage NuGet Packages Select the online tab Search for Nunit Select the Nunit package Follow these instructions.
Parsley Introduction Kui Huang Oct. 13, Topics Background Dependency Injection Object Lifecycle Message Bus Sample FW Extensions.
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.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
PicoContainer Presented by: Jim O’Hara Ed Kausmeyer Jingming Zhang.
Tech Talk Go4 Factory Patterns Presented By: Matt Wilson.
CHEF II / Sakai Architecture. CHEF II Changes uPortal replaces Jetspeed –jsr 168 portlet, servlet compliant Spring replaces Turbine component framework.
DEPENDENCY INJECTION & INVERSION OF CONTROL. WHAT’S GOING TO BE COVERED Quick intro to C# for Java developers Dependency Injection Inversion of Control.
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 Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02.
Spring Training 17/09/ Dependency Injection.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework,
CET203 SOFTWARE DEVELOPMENT Session 1A Revision of Classes.
Reformatted slides from the textbook, C++ How to Program, 6/e Pearson Education, Inc. All rights reserved Chapter 3. [Lecture 02] Introduction to.
.  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.
Object Oriented Software Development
Alternative Architectures: Inversion of Control Mike Hadlow mikehadlow.blogspot.com.
Introducing Allors Applications, Tools & Platform.
UPortal 3: Sneak PreviewJA-SIG Winter Conference 2005 uPortal 3 sneak preview Eric Dalquist, Peter Kharchenko Unicon Inc.
Getting Started with the Open Services Gateway Initiative (OSGi) CNT 5517 Dr. Sumi Helal, Ph.D. Professor Computer & Information Science & Engineering.
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 ©
The State Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Bulding a Modular Application with Coherence David Whitmarsh Independent Contractor Technical Architect Investment Banks
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Give a few Reasons for using Java?
Classes, Interfaces and Packages
Introduction – ORM, Helloworld Application
L’origine dei mali: le dipendenze tra componenti Stefano Leli 14° Workshop DotNetMarche Venerdì 16 aprile
Dependency Injection with Guice Technion – Institute of Technology Author: Gal Lalouche - Technion 2016 ©
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework.
350 parts. i-bank functional structure ▪technical modules – authentication – auditing – user profile – OTP functionality – notifications – push.
Presented by Alexey Vedishchev Developing Web-applications with Grails framework American University of Nigeria, 2016 Part VI: Mapping URLs.
Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems.
CS520 Web Programming Spring – Inversion of Control Chengyu Sun California State University, Los Angeles.
Spring Fling Phillip Warner. Spring Framework ● Dependency Injection (DI) Framework – “Inversion of Control” ● Facilitates Good Programming Practices.
GoF Patterns (GoF) popo.
Delegates and Events 14: Delegates and Events
Activities and Intents
Managed Extensibility Framework
AVG 24th 2015 ADVANCED c# - part 1.
Developing a Model-View-Controller Component for Joomla Part 2
An Introduction to Software Architecture
Tuesday Brown Bag Inversion of Control with Howard Abrams
Lesson 5: More on Creational Patterns
Leveraging ColdSpring To Make Better Applications
Designing For Testability
Dependency Inversion principle
Dependency Injection Mechanism
Presentation transcript:

Introduction to Inversion Of Control (IOC)

IOC Definition (based on Wikipedia)  Consider the way in which an object obtains references to its dependencies.  Often done by a lookup method.  This approach has the disadvantage that an explicit dependence is introduced on a particular lookup mechanism, so the caller is dependent on a particular environment as well as on the object it obtains.  With inversion of control the object is passed its dependencies through constructor arguments (constructor injection) or after construction through setter methods (setter injection).  Also called 'dependency injection‘ (DI) since the dependences of an object are 'injected' into it.

IOC Advantages  IOC/DI decouples objects from specific lookup mechanisms and implementations of the objects it depends on.  Greater flexibility is obtained for production applications as well as for testing.  In particular, dependencies on a particular deployment environment can be removed from the code, making it much easier to test functionality in a simple standalone environment.  One consequence - it becomes faster and easier to test; quality of the software is improved.

Dependency Injection Styles  Setter Injection  Setters are provided in the JavaBean style using standard property naming conventions.  This style is used for the examples in this presentation.  Constructor Injection  Parameters to constructors are provided, and set during object creation by the IOC container, with possible post-construction invocation of a configurable initialization method.  There are some concerns (handling of many or optional parameters) and dangers (possible circular dependencies) in using this DI style.  Interface Injection  Objects implement dedicated interfaces that provide them with objects from which they can look up dependencies (other services).  This style creates its own dependencies, is quite involved to set up and maintain, and is not generally recommended.

IOC Support in the Spring Framework

Example – Application Configuration  Application – A Named Entity Resolution service will be provided by a configured set of components  One approach is to provide a factory and factory methods that provide a configured component bundle.  A second approach is to design the components as JavaBeans, provide setters for configuration dependencies, and use an IOC container to allow external configuration.

UML Diagram

Configuration Alternatives  ResolutionManager  IResolver (ResolverBasic, ResolverMaximized)  IBlockStrategy (LnameZipBlockStrategy, SsnBlockStrategy, …)  IMatchStrategy (MatchStrategyMaximized, …)  ErdSvmClassifier (not shown in UML diagram) (ErdSvmLightClassifier, ErdLibSvmClassifier, …)

Spring XML IOC Configuration  File: mockTestConfig1.xml 

Programmatic Usage  private static final String TEST_CONFIG_PATH_1 = "src/com/thomson/research/erd/engine/config/mockTestConfig1.xml";  private static final String SPRING_RESOLUTION_MANAGER_ID = "resolutionManager"; …  String curDir = System.getProperty("user.dir");  String fullConfigPath = curDir + "/" + TEST_CONFIG_PATH_1;  XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource(  fullConfigPath));  ResolutionManager rm = (ResolutionManager) factory .getBean(SPRING_RESOLUTION_MANAGER_ID); …   // Execute/test the resolve(...) method.  List emList = rm.resolve(permutationList); Configuration information is read by framework here. Configuration is applied here. Configured ResolutionManager is used here.

For More Information…   