A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125.

Slides:



Advertisements
Similar presentations
Spring Transaction & Spring AOP
Advertisements

3 Copyright © 2005, Oracle. All rights reserved. Designing J2EE Applications.
Spring, Hibernate and Web Services 13 th September 2014.
Introduction to the Spring Framework University of Kansas January 2009 This presentation and example application are available at
Aspect-Oriented Programming In Eclipse ® Aspect-Oriented Programming in Eclipse with AspectJ Dr Helen Hawkins and Sian January.
Integrating SOA and the Application Development Framework Shaun O’Brien Principal Product Manager – Oracle JDeveloper / ADF.
Introduction to Java 2 Enterprise Edition About myself –Neutrinos, Cancer Research, IT Applications Today’s topic: J2EE –Context –Advantages –Components.
Enterprise Applications & Java/J2EE Technologies Dr. Douglas C. Schmidt Professor of EECS.
© 2005, Cornell University. Rapid Application Development using the Kuali Architecture (Struts, Spring and OJB) A Case Study Bryan Hutchinson
Pragmatic Application Building: Step by Step Jay Sissom Principal Systems Analyst Indiana University
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.
The Spring Framework A quick overview. The Spring Framework 1. Spring principles: IoC 2. Spring principles: AOP 3. A handful of services 4. A MVC framework.
Spring Framework Adam Waldal Senior Consultant. About me..  OPI is a leader in J2EE consulting with Relationships with BEA, IBM, Tibco, and many other.
UNIT-V The MVC architecture and Struts Framework.
Java Frameworks Indy Java Users Group January 29, 2003.
EJB Overview Celsina Bignoli Distributed Business Applications Server DB Client DB Server DB.
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.
Copyright 2006, Codeguild, Inc Spring Framework Fundamentals March, 2006 Larry Hamel Codeguild, Inc.
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.
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.
JBoss at Work JAW Motors Application Chapter 1-3 Jeff Schmitt October 9, 2006.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
Text 16 de mayo de 2009 Spring Framework Part I. Dependency Injection Buenos Aires, May 2009.
PicoContainer Presented by: Jim O’Hara Ed Kausmeyer Jingming Zhang.
Anti Orgla, Nortal AS Spring Framework
Opus College - overview. OpusCollege - background First project: ICT Capacity Building Mozambican Higher Education Institutions Partners: RUG Groningen,
CHEF II / Sakai Architecture. CHEF II Changes uPortal replaces Jetspeed –jsr 168 portlet, servlet compliant Spring replaces Turbine component framework.
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.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Introduction to Web Dimitar Nenchev Ivan Nakov
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
Spring Framework. About spring Spring is the most popular application development framework for enterprise Java. Millions of developers around the world.
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
Java EE Patterns Dan Bugariu.  What is Java EE ?  What is a Pattern ?
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
Katari Globant 2008 (update to 2010). Katari  Katari is a framework to use as a starting point to develop new web applications.  Incorporates architecture,
Spring and DWR Frameworks for Rich Web Enterprise Application Thomas Wiradikusuma Presentation to the 20 th.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
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.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Testing Spring Applications Unit Testing.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Aspect Oriented Programming Adlux Consultancy Services Pvt Ltd
Kansas City Java User’s Group Jason W. Bedell July 12, 2006
问题 Code scattering Blocks of duplicated code Blocks of complementary code, and different modules implementing complementary parts of the concern Code.
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Overview of the Spring Framework Introducing.
Spring Framework BT Team 25/02/ Spring A lightweight framework that addresses each tier in a Web application. Presentation layer – An MVC framework.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring JDBC Simplifying.
L’origine dei mali: le dipendenze tra componenti Stefano Leli 14° Workshop DotNetMarche Venerdì 16 aprile
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions and Spring MVC Buenos Aires, June 2009.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework.
Enterprise Java v050228MVC1 Model, View, Controller Web Architecture.
J2EE Platform Overview (Application Architecture)
J2EE Lecture 6: Spring – IoC and Dependency Injection
Spring Framework Power to the POJO.
Chengyu Sun California State University, Los Angeles
By Ru Shen Department of Computer Science UAlbany, 2008
Intro to Spring CJUG - January 2013.
Chengyu Sun California State University, Los Angeles
Introduction to Spring Framework and Dependency Injection
CS520 Web Programming Spring – Aspect Oriented Programming
Presentation transcript:

A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125

What is Spring? A Web Application Framework Multi-tier full stack solution Development within the J2EE guidelines Simple programming model, complex layer of tools Essence of Spring: provide services to reusable POJOs One stop shop for all enterprise requirements while still maintaining modularity Lightweight framework: less complexity, more interoperability Follows the Model-View-Controller architecture

Why Spring? Non-invasive Framework Consistent programming model, usable in any environment Promotes code reuse Promotes good programming practices, program to interfaces Facilitates extraction of config values into property\XML files Spring is consistent across the framework Promotes architectural choice Promotes pluggability

Spring Features Inversion of Control (IoC) container Aspect-Oriented Programming (AOP) Framework Data access abstraction Significant JDBC simplification Transaction management MVC Web Framework Simplification of working with JNDI, JTA etc. Support for Java Messaging Service (JMS) Support for comprehensive testing at every phase

Spring Modules

“Don't call us, we’ll call you” Inversion of Control – The Dependency Injection flavor Framework code invokes application code and coordinates overall workflow Callback interfaces to allow clean acquisition and release of resources Application classes expose their dependencies, as methods that the framework can call at runtime “Push” config: dependencies pushed on application objects Setter, Constructor and Method injection Allows a layer of indirection: facilitates hot swapping No dependency on container APIs

IoC Example – Setter Injection public interface WeatherService { Double getHistoricalHigh(Date date); } public class WeatherServiceImpl implements WeatherService { private WeatherDAO weatherDao; public void setWeatherDao(WeatherDAO weatherDao) { this.weatherDao = weatherDao; } public Double getHistoricalHigh(Date date) { WeatherData wd = weatherDao.find(date); if (wd != null) return new Double(wd.getHigh()); return null; } public class StaticDataWeatherDAOImpl implements WeatherDAO {... }

IoC Example – Setter Injection Add setter information to configuration file: applicationContext.xml <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "

IoC Example – Constructor Injection public interface WeatherService { Double getHistoricalHigh(Date date); } public class WeatherServiceImpl implements WeatherService { private final WeatherDao weatherDao; public WeatherServiceImpl(WeatherDao weatherDao) { this.weatherDao = weatherDao; } public Double getHistoricalHigh(Date date) { WeatherData wd = weatherDao.find(date); if (wd != null) return new Double(wd.getHigh()); return null; } public class StaticDataWeatherDAOImpl implements WeatherDAO {... }

IoC Example – Setter Injection Add constructor information to configuration file: applicationContext.xml

The new OOP? Aspect-Oriented Programming Enables us to think about concerns or aspects of the system Concerns like transaction management, logging and failure monitoring Traditional OOP problems: code duplication, loose typing, intrusive special-purpose frameworks AOP facilitates cross-cutting modules applied declaratively with no tradeoffs Spring has a proxy-based approach to AOP Proxies maintain a chain of advice applying to methods Spring AOP provides an extensible pointcut model It is the future of middleware with a fixed set of services applied flexibly to POJOs

AOP Example public class AccountManagerImpl implements AccountManager { private MailSender mailSender; private Simpl Message message; private AccountDao accountDao; public void setMailSender(MailSender mailSender) { this.mailSender = mailSender; } public void setMessage(Simpl Message message) { this.message = message; } public void setAccountDao(AccountDao accountDao) { this.accountDao = accountDao; } private void sendMail(Exception ex) { Simpl Message msg = new Simpl Message(this.message); msg.setText("Encountered exception " + ex.getMessage()); this.mailSender.send(msg); }...

AOP Example public Account getAccount(String accountId) throws AccountNotFoundException, DataAccessException { try{ return this.accountDao.findAccount(accountId); } catch(AccountNotFoundException ex){ sendMail(ex); throw ex; } catch (DataAccessException ex) { sendMail(ex); throw ex; }...

AOP Example public void createAccount(Account account) throws DataAccessException, { try{ if (isInvalid(account)) { throw new InvalidAccountException(account); } this.accountDao.saveAccount(account); } catch (IOException ex) { sendMail(ex); throw ex; } catch (DataAccessException ex) { sendMail(ex); throw ex; } }

AOP Example An aspect class that implements the exception notification policy public class NotificationThrowsAdvice implements ThrowsAdvice { private MailSender mailSender; private Simpl Message message; public void setMailSender(MailSender mailSender) { this.mailSender = mailSender; } public void setMessage(Simpl Message message) { this.message = message; } public void afterThrowing(Exception ex) throws Throwable { Simpl Message msg = new Simpl Message(this.message); msg.setText("Encountered exception " + ex.getMessage()); this.mailSender.send(msg); } }

AOP Example Now apply the advice to multiple objects managed by the Spring container: <bean id=" NotificationThrowsAdvice" class="com.mycompany. NotificationThrowsAdvice"> <bean id="accountManagerBeanNameProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> accountManagerTarget NotificationThrowsAdvice

AOP Example The same class now updated: public class AccountManagerImpl implements AccountManager { private AccountDao accountDao; public void setAccountDao(AccountDao accountDao) { this.accountDao = accountDao; } public Account getAccount(String accountId) throws AccountNotFoundException, DataAccessException { return this.accountDao.findAccount(accountId); } public void createAccount(Account account) throws DataAccessException { this.accountDao.saveAccount(account); }

DAO Support and JDBC Spring provides abstract DAO base classes These facilitate access to database resources Provides a layer of abstraction over JDBC Focus is on connection setup and exception handling Spring provides an exception hierarchy for data access methods Hierarchy common to both JDBC and O/R mapping Promotes uniform exceptions across the application Facilitates portability

View Technologies Spring does not favor a particular view technology: view agnostic Supports myriad out of the box options as well as custom views All that is required: link logical view name to link resolver and create the resource Support for the ubiquitous JavaServer Pages Support for FreeMarker and Velocity templating tools Support for Tiles for more complex views with considerable layout Support for XML and XSLT based layouts Support for document-based views like Excel and PDFs

Thank You