(Spring Framework Workshop) By www.spring66.com 2552, 22 Supported by KT ZMICO Securities.

Slides:



Advertisements
Similar presentations
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Advertisements

Spring 3.0 MVC - Introduction By, Srinivas Reddy.S
Persistence Jim Briggs 1. 2 Database connectivity: JDBC Java Database Connectivity An API for connecting Java programs (applications, applets and servlets)
Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Apache Struts Technology
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.
© 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
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Address - #22, 1 st Floor, Station View Road, Kodambakkam, Chennai JTech Soft Solutions Website:
The Spring Framework: A brief introduction to Inversion of Control James Brundege
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.
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.
Spring Roo CS476 Aleksey Bukin Peter Lew. What is Roo? Productivity tool Allows for easy creation of Enterprise Java applications Runs alongside existing.
NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework.
Spring Overview, Application demo -Midhila Paineni 09/23/2011 Spring Overview, Application demo9/8/20151.
CSCI 6962: Server-side Design and Programming JDBC Database Programming.
Introduction to the Spring Framework Rajesh. Spring Mission Statement J2EE should be easier to use OO design is more important than any implementation.
Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.
© D. Wong  Indexes  JDBC  JDBC in J2EE (Java 2 Enterprise Edition)
JBoss at Work JAW Motors Application Chapter 1-3 Jeff Schmitt October 9, 2006.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,
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.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
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.
Component frameworks Roy Kensmil. Historical trens in software development. ABSTRACT INTERACTIONS COMPONENT BUS COMPONENT GLUE THIRD-PARTY BINDING.
Introduction to Web Dimitar Nenchev Ivan Nakov
Java Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125.
Enterprise Java Beans. Model 1 J2EE – Web View Model/View/Controller Model View Control Data base Web Server Model One Architecture HTTP Request HTTP.
INTEGRATION OF BACKBONE.JS WITH SPRING 3.1. Agenda New Features and Enhancements in Spring 3.1 What is Backbone.js and why I should use it Spring 3.1.
Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
Spring and DWR Frameworks for Rich Web Enterprise Application Thomas Wiradikusuma Presentation to the 20 th.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
JAVA EE 6 Best Practices for Migrating Spring to WTF ?!?
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Kansas City Java User’s Group Jason W. Bedell July 12, 2006
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Overview of the Spring Framework Introducing.
Spring JDBC Dima Ionut Daniel. Contents What is Spring JDBC? Overview Spring JDBC Core SQL Exceptions Database Connection Batch Operations Handling BLOB/CLOB.
Singleton Academy, Pune. Course syllabus Singleton Academy Pune – Course Syllabus1.
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions and Spring MVC Buenos Aires, June 2009.
Apache Struts Technology A MVC Framework for Java Web Applications.
J AVA T RAINING IN A HMEDABAD By TOPS Technologies 1 TOPS Technologies Java Course.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
J2EE Lecture 6: Spring – IoC and Dependency Injection
Field of Dreams An Online Sporting Goods Marketplace
Overall Architecture and Component Model
Introduction to J2EE Architecture
By Ru Shen Department of Computer Science UAlbany, 2008
Intro to Spring CJUG - January 2013.
CS5220 Advanced Topics in Web Programming Spring – Web MVC
The Model Layer What is Model?
ESIS Consulting LLC (C) ESIS Consulting LLC. All rights reserved
CS5220 Advanced Topics in Web Programming Spring – Web MVC
Component-based Applications
Developing and testing enterprise Java applications
Presentation transcript:

(Spring Framework Workshop) By , 22 Supported by KT ZMICO Securities

@roofimon TA TA TA

Agenda Impossible is nothing Why Spring? New Features and Enhancements in Spring 3.0New Features and Enhancements in Spring 3.0 –Core Container 3.0 –Persistence with Spring JDBC –AOP –Transaction with Annotation –EhCache (Apply AOP) –Spring Web MVC with Web Annotation

Basic Requirements JDK Maven 2.0.x Apache Derby Netbeans, Eclipse, Vi, Whatever IDE Skeleton Source from – 3/svn/branches/1.0.PREhttp://code.google.com/p/spring66-training- 3/svn/branches/1.0.PRE Full – 3.googlecode.com/svn/trunk/

( ) Building Spring2 Enterprise Application Development J2EE without EJB Professional Spring Framework Spring2 in Action Pro Spring2 Spring Recipe

Java ? Design Pattern: SUN Application Server, API Design Pattern ? Light Weight

My Basic Requirements for Lightweight Container Lifecycle management Lookup Configuration Dependency resolution

lightweight Container (Value Added) Transaction Thread management Object pooling Clustering Management Remoting Exposing remote services Consuming remote services Customization and extensibility AOP

What actually Spring is? Framework that … –make Enterprise Java easier to use –promote good programming practice –enabling a POJO-based programming model that is applicable in a wide range of environments Some said Spring is just a glue for connecting all state of the art technologies together via its Application Context. Heart and Soul of Spring is Dependency Injection and Aspect Oriented Programming.

Main Components

Layer of Application

Dependency Injection Inversion Of Control IOC Hollywood Principle: "Don't call me, I'll call you."

Why IoC is Matter? Removes explicit dependence on container APIs Because components don't need to look up collaborators at runtime, they're much simpler to write and maintain Application code is much easier to test A good IoC implementation preserves strong typing Dependencies are explicit No more Application Server dependent

Bean? Bean is a service Service = Interface+Implement+Descriptor Bean Bean Factory Application Context Application Context Spring Application Context

Configuration applicationContect.xml

Initial Context //Load Context Manually From AppConfig.class ApplicationContext context = new FileSystemXmlApplicationContext( "classpath:/applicationContext.xml"); //Lookup Bean named Clinic clinic = (Clinic)context.getBean(clinic); Collection vets = clinic.getVets();

The PetClinic

The Lightweight Container Architecture

Basic Architecture Spring JDBC Spring Core Spring Web MVC JSP jQuery Separate Web Module from Service Module by using HTTP Remoting

Basic Requirement Use Cases –View a list of veterinarians and their specialties –View information pertaining to a pet owner –Update the information pertaining to a pet owner –Add a new pet owner to the system –View information pertaining to a pet –Update the information pertaining to a pet –Add a new pet to the system –View information pertaining to a pet's visitation history –Add information pertaining to a visit to the pet's visitation history Business Rules –An owner may not have multiple pets with the same case-insensitive name

Checkout Code from Google Code Create Test Case CallisClinicServiceReady – protected Clinic clinic; – public void isCliniceReady() { – assertNotNull(clinic); –} We have done creating our first bean.

Checkout Code from Google Code Create –interface Clinic Run Test (Fail!!!!!) Create –applicationContect.xml –Copy content from Master Project – src\test\resources\org\spring66\ training3\test\petclinic\baseline Run Test !!!!!! We have done creating our first bean.

What we have done?

Why Test First Test case is META-CODE, code that explains code. Feel confident for refactor, move and share.

Checkout Code from Google Code Create interface ListDataService Create class ListDataServiceImpl – public List getElementsList() { – List list = new ArrayList(); – list.add("Tom"); – list.add("Henri"); – list.add("Jim"); – return list; – }

Go more deep into DataSource DB Connection Data Source Hibernate iBatis OpenJPA Persistence Manager Oracle MsSQL DB2 MySQL

Go more deep into DataSource Basically we must have this information for datasource –Driver Class –Driver Class Name –Connection String (URL) –Username –Password –Plus some optional parameters depends on Driver Manager (Pool Size, Wait Time, bla bla bla)

Go more deep into DataSource Basically we must have this information – – <property name="driverClassName" value="${jdbc.driverClassName}" /> –

Spring JDBC The value-add provided by the Spring Framework JDBC abstraction is perhaps best shown by the sequence of actions outlined in the table.

Spring JDBC ActionSpringYou Define connection parameters. X Open the connection. X Specify the SQL statement. X Declare parameters and provide parameter values X Prepare and execute the statement. X Set up the loop to iterate through the results (if any). X Do the work for each iteration. X Process any exception. X Handle transactions. X Close the connection, statement and resultset. X

Go more deep into Spring JDBC JdbcTemplate NamedParameterJdbcTemplate SimpleJdbcTemplate SimpleJdbcInsert and SimpleJdbcCall RDBMS Objects including MappingSqlQuery, SqlUpdate and StoredProcedure

Go more deep into Spring JDBC DataSource Prepared Statement Mapper Extractor

Move up to Service Layer The most important part of our Application. All business logics are located, here Test it carefully, change very often. ControllerService Entity A Entity B Entity C

Spring Web MVC Flow Clear separation of roles Powerful and straightforward configuration of both framework and application classes as JavaBeans. Adaptability, non-intrusiveness, and flexibility. Customizable binding and validation Customizable handler mapping and view resolution Flexible model transfer Beans whose lifecycle is scoped to the current HTTP request or HTTP Session

Spring DispatcherServlet

Dispatcher Servlet example org.springframework.web.servlet.DispatcherServlet 1 example *.form

Example-servlet.xml <bean class="org.springframework.web.servlet.view.InternalResou rceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" p:order="1"/> <bean id="messageSource" class="org.springframework.context.support.ResourceBundle MessageSource" p:basename="messages"/>

Context Hierarchy

Web Layer Need Spring Boot Strap Web Context Spring Context Web Context Spring Context org.springframework.web.context.ContextLoaderListener web.xml

Bootstrapping web applications Spring allows for seamlessly classes within your servlet container's web.xml deployment descriptor org.springframework.web.context.ContextLoaderListener contextConfigLocation /WEB-INF/applicationContext.xml

Still have xxx-servlet.xml Need to create abc-servlet.xml for mapping request from dispatcher servlet <context:component-scan base-package="com.spring66.petclinic.web"/> Also can config other parameters like binding, viewResolver,…

Still have public class ClinicController { private final Clinic public ClinicController(Clinic clinic) { this.clinic = clinic; public String welcomeHandler() { return "welcome"; }

First Controller Named ClinicController And then Copy Content from Main Project src\main\java\com\spring66\petclinic\web ====ClinicController====== mvn jetty:run –Dmaven.test.skip=true –Djetty.port=9999

First Controller, Test First Create VetControllerTests And then Copy Content from Web.text ====TestVetController====== Wowwww!!! Full of red things, so lets eliminate them.

Create VetController List All Vet Create VetController Copy content from Web.txt Part VetController There are two interesting parts: Inject clinic service into controller And Request Mapping over public Collection list() –It will handles {WebContext}/main/vet/list

OwnerController, Test First Create OwnerControllerTests And then Copy Content from Web.text ====TestOwnerController====== Wowwww!!! Full of red things, so lets eliminate them.

Lets do more action, Test First Create OwnerController –Copy content from Web.txt –Part SearchOwnerController –If it works so move forward Do some magic by adding new Owner –Copy content from Web.txt –Part AddOwnerController Create ViewUtils –Copy content from Web.txt –Part ViewUtils Create PageType.. Good u can guest, next