Anti Orgla, Nortal AS Spring Framework 08.04.2014.

Slides:



Advertisements
Similar presentations
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Advertisements

Web Applications Development Using Coldbox Platform Eddie Johnston.
Margus Hanni, Nortal AS Spring MVC Viited varasematele materjalidele… 2012 – TÜ - Spring MVC – Roman Tekhov.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Spring MVC Margus Hanni, Nortal AS
Object-Oriented Analysis and Design
Session-01. Layers Struts 2 Framework The struts 2 framework is used to develop MVC-based web application. Struts 1.0 was released in June The.
Struts 2.0 an Overview ( )
UNIT-V The MVC architecture and Struts Framework.
Lecture 2 - Struts ENTERPRISE JAVA. 2 Contents  Servlet Deployment  Servlet Filters  Model View Controllers  Struts  Dependency Injection.
Dependency Injection and Model-View-Controller. Overview Inversion of Control Model-View-Controller.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
1 Java Database Connection (JDBC) There are many industrial-strength DBMS's commercially available in the market. Oracle, DB2, and Sybase are just a few.
Spring Overview, Application demo -Midhila Paineni 09/23/2011 Spring Overview, Application demo9/8/20151.
UPortal Developers MIT August 2004 Persistence Strategy for uPortal 3 Mike DeSimone the r-smart group
BEST PRACTICES - Java By Configuration Use global-forwards/results Helps to avoid duplicate jsp files and redundancy forward mapping.
Separation of Concerns Technion – Institute of Technology Author: Gal Lalouche - Technion 2015 © 1.
ASP.NET and Model View Control Jesper Tørresø ITNET2 F08.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
Writing Widgets & Custom Script API for BOY Xihui Chen
Design Patterns Phil Smith 28 th November Design Patterns There are many ways to produce content via Servlets and JSPs Understanding the good, the.
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.
JSP Architecture Outline  Model 1 Architecture  Model 2 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.
Dr. Magdi AMER Unit 2 Introduction to Database. Intro Many programs need to save information on disk. The role of DB system is to provide a layer of abstraction.
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
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.
Inversion Of Control & Dependency Injection Break Apart The Dependencies Oren Eini Senior Developer We! Consulting Group
A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125.
Domain Driven Web Development With WebJinn Sergei Kojarski College of Computer & Information Science Northeastern University joint work with David H. Lorenz.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Forms with Spring MVC Handling Form.
JSF Framework Java Server Faces Presented by Songkran Totiya (6/10/2014)
Alternative Architectures: Inversion of Control Mike Hadlow mikehadlow.blogspot.com.
Introduction to Spring Web Flow Andrew Petro Software Developer Unicon, Inc. Jasig 2011 Westminster, CO 23 May 2011 © Copyright Unicon, Inc., Some.
Struts Framework Anna Paščenko. What is Struts?  An open source framework for building Java web applications.
Creating competitive advantage Copyright © 2003 Enterprise Java Beans Presenter: Wickramanayake HMKSK Version:0.1 Last Updated:
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
Date : 3/04/2010 Web Technology Solutions Class: PHP Web Application Frameworks.
CSI 3125, Preliminaries, page 1 JDBC. CSI 3125, Preliminaries, page 2 JDBC JDBC stands for Java Database Connectivity, which is a standard Java API (application.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Introduction to Reasonable Server Faces Aaron Zeckoski
ESG-CET Meeting, Boulder, CO, April 2008 Gateway Implementation 4/30/2008.
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.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring JDBC Simplifying.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Singleton Academy, Pune. Course syllabus Singleton Academy Pune – Course Syllabus1.
Jean-Claude Trachsel Senior Consultant, Trivadis AG The good news.
By Jonathan Smith. Road Map Introduction Company Information Project Overview Java Web Design and Development Summary Relation to IUP Acknowledgments.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java program to connect to any database.
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems.
Instructor: Jinze Liu Fall /8/2016Jinze University of Kentucky 2 Database Project Database Architecture Database programming.
Web Technology Solutions
CS3220 Web and Internet Programming Database Access with JDBC
CS320 Web and Internet Programming Database Access with JDBC
Chengyu Sun California State University, Los Angeles
HW#4 Making Simple BBS Using JDBC
The Model Layer What is Model?
CS520 Web Programming Spring – Aspect Oriented Programming
CS3220 Web and Internet Programming Database Access with JDBC
CS3220 Web and Internet Programming Database Access with JDBC
Plug-In Architecture Pattern
Presentation transcript:

Anti Orgla, Nortal AS Spring Framework

Web appication framework? How do you handle your requests? How do you access your database? How do you manage your session? Code reuse? Maybe it’s already been done?

Web application framework Typically frameworks provide libraries: Database Access Session management Request management Transaction management UI Templates Cache, Security, Ajax, Web Services, etc…

How to get a String from DB? public static String getName(Connection con, int id) { Statement stmt = null; String query = "select name from user_info where id = ?"; try { stmt = con.createStatement(); stmt.setInt(1, id); ResultSet rs = stmt.executeQuery(query); if(rs.next()) { return rs.getString("name"); }else{ return null; } } catch (SQLException e ) { //handle the exception } finally { if (stmt != null) { stmt.close(); }

Easier way? public static String getName(int id) { return jdbcTemplate.queryForObject("select name from user_info where id = ?", String.class, id); }

Spring Framework One of the most popular Open source application framework Very flexible Available since 2002 (v4.0 dets.2013) Did I say it is very flexible?

Spring Framework Inversion of Control Dependency Injection static vs runtime abstractions vs implementations

Dependency injection public interface UserDao { User getByUserName(String name); public class JdbcUserDao implements UserDao { public User getByUserName(String name) { // load user from DB private UserDao userDao; Universal abstraction

Dependency injection public interface UserDao { User getByUserName(String name); public class JdbcUserDao implements UserDao { public User getByUserName(String name) { // load user from DB private UserDao userDao; One possible implementation. Spring will create and register it

Dependency injection public interface UserDao { User getByUserName(String name); public class JdbcUserDao implements UserDao { public User getByUserName(String name) { // load user from DB private UserDao userDao; Injection is made as an abstraction

IoC in Spring Spring handles the infrastructure (bean creation, dependency lookup and injection) Developer focuses on application specific logic You can describe how your application is coupled, not couple it yourself!

XML based configuration Bean can also be defined and injected in XML.

MVC – What was that?

Model-View-Controller Controller: executes business logic, data actions etc. Forms a model object and passes it to view for rendering Model: object for passing data between controller and view View: takes model data from the controller and presents it to the end user

Model-View-Controller Separation of different layers An application might have more than one user interface Different developers may be responsible for different aspects of the application.

Spring MVC IoC again – framework handles the infrastructure, you focus on application specific things.

Architecture - DispatcherServlet

Let’s write some MVC! Code demo..

Built-in conversion There are some standard built-in public String int long longParam) {...

Type conversion You can also define your own PropertyEditors PropertyEditorSupport implements PropertyEditor

Custom types public class DateRange { private Date start; private Date end; public DateRange(Date start, Date end) { this.start = start; this.end = end; } public int getDayDifference() { // calculate }

Custom type editor public class DateRangeEditor extends PropertyEditorSupport { private DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy"); public void setAsText(String text) throws IllegalArgumentException { String[] parts = text.split("-"); Date start = dateFormat.parse(parts[0]); Date end = dateFormat.parse(parts[1]); setValue(new DateRange(start, end)); } public String getAsText() { DateRange dateRange = (DateRange) getValue(); return dateFormat.format(dateRange.getStart()) + "-" + dateFormat.format(dateRange.getEnd()); } String to custom type Custom type to String

Register and public class MyController public void initBinder(WebDataBinder binder) { binder.registerCustomEditor(DateRange.class, new DateRangeEditor()); public String DateRange range) {... }

Non-intrusive Very important feature of a framework is non-intrusiveness. Spring MVC normally lets you do stuff according to MVC pattern. But it doesn’t prevent you from violating MVC if you really want to.

Code examples.. Code demo..

Sources of wisdom Spring has great documentation: Java BluePrints - Model-View-Controller html html Model-View-Controller Inversion of control