Top Banner
72
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Java Edge.2008.Web.Frameworks.Catagorized
Page 2: Java Edge.2008.Web.Frameworks.Catagorized

2

Agenda

Page 3: Java Edge.2008.Web.Frameworks.Catagorized

3

Agenda

• Introduction

• The evolution of WAFs

• Welcome to the jungle

• Categorizing by example

• Comparison

• The future

Page 4: Java Edge.2008.Web.Frameworks.Catagorized

4

Page 5: Java Edge.2008.Web.Frameworks.Catagorized

5

Introduction

# define

“Ask nine developers for a definition of

components, and you will get eighteen

opinions”

Java Frameworks and Components-Accelerate Your Web Application Development

Page 6: Java Edge.2008.Web.Frameworks.Catagorized

6

Introduction

What is WAF?

• A reusable, skeletal, semi-complete modular platform that can

be specialized to produce custom web applications

• A set of supporting libraries, scripting languages, services

and interfaces that provide a skeletal structure for an

application

• Makes application development easier, faster by supplying

pre-built parts

Page 7: Java Edge.2008.Web.Frameworks.Catagorized

7

Introduction

Why use WAFs?

• Focus on solving business problems

• Code higher levels of abstractions

• Reduce time, effort & resources

• Avoid reinventing the wheel

• Reduce Technology churn & risk

• Avoid lock-in to on proprietary dead end architecture

• OSS is based on commonly accepted standards

• WAFs are tested and continuously refined

• Base on commonly accepted standards

• Easily deployed within existing enterprise infrastructures

Page 8: Java Edge.2008.Web.Frameworks.Catagorized

8

Page 9: Java Edge.2008.Web.Frameworks.Catagorized

9

Evolution

Page 10: Java Edge.2008.Web.Frameworks.Catagorized

10

Evolution :: Technology

New APIs appear because developers discover

limitations in existing languages and tools. “

1991 1995 1997 1998

HTML draft CGIServlet

1.0

JSP

0.98

1980

MVC (Xerox)

1994

Design

Patterns

(GoF) Ajax / Wicket

1996

Java 1.0 /

Applets

2000

Jakarta

Struts 1.0

2006

GWT

2002

Spring

Framework

1999

J2EE 1.2

SDK

2007

SOUI /

SOFEA

2001

.com

bubble

Web 1.0 Web 2.0

20052003 20041992 1993

Page 11: Java Edge.2008.Web.Frameworks.Catagorized

11

Evolution :: Technology

1991 1995 1997 1998

HTML draft CGIServlet

1.0

JSP

0.98

1980

MVC (Xerox)

1994

Design

Patterns

(GoF) Ajax / Wicket

1996

Java 1.0 /

Applets

2000

Jakarta

Struts 1.0

2006

GWT

2002

Spring

Framework

1999

J2EE 1.2

SDK

2007

SOUI /

SOFEA

2001

.com

bubble

Web 1.0 Web 2.0

20052003 20041992 1993

• 1995 – CGI (Common Gateway Interface)

• Standard for interfacing external applications with web servers

• Provides a dynamic web page that reflects user inputs

• Starts a separate process for each request

• Resource intensive, does not scale well

Page 12: Java Edge.2008.Web.Frameworks.Catagorized

12

Evolution :: Technology

1991 1995 1997 1998

HTML draft CGIServlet

1.0

JSP

0.98

1980

MVC (Xerox)

1994

Design

Patterns

(GoF) Ajax / Wicket

1996

Java 1.0 /

Applets

2000

Jakarta

Struts 1.0

2006

GWT

2002

Spring

Framework

1999

J2EE 1.2

SDK

2007

SOUI /

SOFEA

2001

.com

bubble

Web 1.0 Web 2.0

20052003 20041992 1993

• 1997 - Servlets

• Java's CGI abstraction

• Java code that extends functionality of a web server

• Receives a request and generates a response

Page 13: Java Edge.2008.Web.Frameworks.Catagorized

13

Evolution :: Technology

1991 1995 1997 1998

HTML draft CGIServlet

1.0

JSP

0.98

1980

MVC (Xerox)

1994

Design

Patterns

(GoF) Ajax / Wicket

1996

Java 1.0 /

Applets

2000

Jakarta

Struts 1.0

2006

GWT

2002

Spring

Framework

1999

J2EE 1.2

SDK

2007

SOUI /

SOFEA

2001

.com

bubble

Web 1.0 Web 2.0

20052003 20041992 1993

• 1998 – JSP (JavaServer Pages)

• Embed Java code, directives & actions in markup

• Compiled & converted to a Servlet

• Extend static content with standard / custom tag libraries

Page 14: Java Edge.2008.Web.Frameworks.Catagorized

14

Evolution :: Technology

1991 1995 1997 1998

HTML draft CGIServlet

1.0

JSP

0.98

1980

MVC (Xerox)

1994

Design

Patterns

(GoF) Ajax / Wicket

1996

Java 1.0 /

Applets

2000

Jakarta

Struts 1.0

2006

GWT

2002

Spring

Framework

1999

J2EE 1.2

SDK

2007

SOUI /

SOFEA

2001

.com

bubble

Web 1.0 Web 2.0

20052003 20041992 1993

• 2005 – Ajax (asynchronous JavaScript and XML)

• Web development techniques (XHR, DOM, JS, JSON)

• Used for creating interactive web applications / RIA

• Communicates with a server in the background

• Does not interfere with the current state of the page

Page 15: Java Edge.2008.Web.Frameworks.Catagorized

15

Evolution :: Technology

Britney Spears, Circus Album Released

November 28, 2008

Page 16: Java Edge.2008.Web.Frameworks.Catagorized

16

Evolution :: Architecture

MVC (Model View Controller)• First described by Xerox (1980)

• A design pattern for separating concerns

• Model – data, business logic

• View – UI, data representation

• Controller – mediates between model and view

• Changes in view / model don’t effect each other

• Separation of development roles

Model

ControllerView

State

Change

State

Query

View

Selection

User

Actions

Change

Notifications

Page 17: Java Edge.2008.Web.Frameworks.Catagorized

17

Evolution :: Architecture

MVC in WAF• Controller

• Processes request

• Handles navigation logic

• Interacts with the business logic

• Populates the model

• Model

• Contains the data needed to render view

• View

• Pulls data from model

• Renders the response

Page 18: Java Edge.2008.Web.Frameworks.Catagorized

18

Evolution :: Architecture

MVC Model 1• Request and response are handled by same component

• JSP is Controller + View

• The good

• Simple to implement

• Development-deployment cycles are short

• The bad

• Hard to maintain / test / reuse - mish-mash of markup and code

• Hard to manage work flow

JSP

(View)

JavaBeans

(Model) DataBrowser

request

response

Page 19: Java Edge.2008.Web.Frameworks.Catagorized

19

Evolution :: Architecture

MVC Model 2• A Servlet functions as a controller

• Processes requests

• Initiates business operations

• Handles control flow

• Decoupling of application flow from presentation

• Better separation of responsibilities (developer / designer)

• No business logic in view

• Not dependent on JSP

JSP

(View)

JavaBeans

(Model) DataBrowser

request

response

Servlet

(Controller)

create/

update

access

dispatch

Page 20: Java Edge.2008.Web.Frameworks.Catagorized

20

Page 21: Java Edge.2008.Web.Frameworks.Catagorized

21

Welcome to the jungle

Overview

• A plethora of Java web frameworks has evolved

• Each has its special design concept, advantage and

disadvantage

• It often takes months to learn a new framework

• It becomes increasingly difficult to choose the right

framework to use

Page 22: Java Edge.2008.Web.Frameworks.Catagorized

22

Welcome to the jungle

web

Page 23: Java Edge.2008.Web.Frameworks.Catagorized

23

Welcome to the jungle

Why so many?• No standards for application architecture*

• Only standards for low level abstractions (Servlet, JSP)

• J2EE blue prints suggestion (2002)

• OSS attempted to fill in the gap

• No coordination / knowledge sharing

• No framework is perfect for all scenarios

• Every framework has pros & cons

• Technology Trends / Tipping point

• Personal Taste / “Feel”

• Developers have different preferences

* JSF (2004) was a first attempt for standardization

Page 24: Java Edge.2008.Web.Frameworks.Catagorized

24

Page 25: Java Edge.2008.Web.Frameworks.Catagorized

25

Let’s categorize

1. Request / Response Oriented• What is your request / response?

2. Components Oriented• Write like desktop deliver over web

3. SOUI / SOFEA• New trend in town: “fat client” meets SOA

Page 26: Java Edge.2008.Web.Frameworks.Catagorized

26

Page 27: Java Edge.2008.Web.Frameworks.Catagorized

27

Request / Response frameworks

Key characteristics

• Similar to CGI specification

• Low level of abstractions

• Controllers and actions handle requests directly

• Requests are stateless

• Server side sessions -> statefullness

• Logic is mapped to URLs

• Actions are mapped to pages

• URLs determines page flow

• Common Design Patterns

• Front Controller, Command

Page 28: Java Edge.2008.Web.Frameworks.Catagorized

28

Request / Response frameworks

Architecture

Browser

request

response

FrontServlet

forward

Request

Processor

JavaBeans

Action /

Command

execute

get

business

date

JSP

fill with

business

data

Controller

View Model

Page 29: Java Edge.2008.Web.Frameworks.Catagorized

29

Request / Response frameworks

• Advantages

• Simple - low entry barrier

• Fast learning curve

• High popularity

• Easy visualization of markup

• Disadvantages

• Limited UI controls

• Hard to maintain work flow

• Low level abstraction

• Low reusability

• Procedural

Page 30: Java Edge.2008.Web.Frameworks.Catagorized

30

Request / Response frameworks

Examples:

•Spring MVC •Struts 2 •WebWork

Page 31: Java Edge.2008.Web.Frameworks.Catagorized

31

Request / Response frameworks

Example: Spring MVC

• Overview

• Integrates with the Spring container

• Not a full-stack web framework

• Based on a Servlet “Front Controller”

• Specific controllers are invoked to handle request

• Promotes a clean separation of responsibilities (MVC)

• Low abstraction interfaces are coupled to the Servlet API

Page 32: Java Edge.2008.Web.Frameworks.Catagorized

32

Request / Response frameworks

SpringMVC: Architecture

Front Controller

(Dispatcher Servlet)

Handler Mapper

ControllerController

Controller

HandlerInterceptor

View

template

Browser

JavaBeansJavaBeans

JavaBeans

`

ModelView

ModelView

Controller

View Model

Page 33: Java Edge.2008.Web.Frameworks.Catagorized

33

Request / Response frameworks

SpringMVC: Advantages

• Highly flexible

• Many parts of the framework are pluggable

• No restriction to use framework functionality

• Strong REST foundations

• URLs are mapped to controllers

• Wide choice of view technologies

• JSP / FreeMarker / Velocity

• Easy testing

• DI of mock classes

• Lightweight environment

• Build enterprise-ready applications using POJOs

Page 34: Java Edge.2008.Web.Frameworks.Catagorized

34

Request / Response frameworks

SpringMVC: Disadvantages

• Comes with very little out of the box

• No Ajax support

• Too flexible - confusing

• Same task can be accomplished in different ways

• Configuration

• A lot of XML files

• Dependency on Spring framework

• Developers must understand Spring concepts

Page 35: Java Edge.2008.Web.Frameworks.Catagorized

35

Page 36: Java Edge.2008.Web.Frameworks.Catagorized

36

Component frameworks

Key characteristics

• Abstraction

• Hides the internals of the request handling

• Encapsulation

• Components handle their state and behaviour

• Components are responsible to render themselves

• Component tree (composition)

• Event driven

• User actions translated into messages

• Messages are dispatched to the components

• Similar to desktop GUI toolkits

• Common Design Patterns

• Composition, observer, factory, dependency injection

Page 37: Java Edge.2008.Web.Frameworks.Catagorized

37

Component frameworks

Architecture

<root>

<panel>

<panel>

<label/>

<textField/>

...

</panel>

<button/>

</panel>

</root>

View Technology Component Tree Markup

Submit

Username

Password

Root

Panel

Label TextField

ButtonPanel ...

Page 38: Java Edge.2008.Web.Frameworks.Catagorized

38

Component frameworks

• Advantages

• Object-oriented

• Advocates reuse

• Rich component libraries

• Familiar to desktop application developers

• Disadvantages

• Complexity

• Hard to customize components

• Scalability

Page 39: Java Edge.2008.Web.Frameworks.Catagorized

39

Component frameworks

Examples:

• Wicket • JSF • Tapestry

Page 40: Java Edge.2008.Web.Frameworks.Catagorized

40

Component frameworks

Example: Apache Wicket

• Overview

• Open source, contributed to Apache in 2007

• Swing like coding

• Components are:

• created in java

• composed into a component tree

• rendered into HTML markup

• Java widgets are bound to markup using “wicket id’s”

• Reuse HTML like Java

Page 41: Java Edge.2008.Web.Frameworks.Catagorized

41

Component

Label

WebComponent MarkupContainer

Page WebMarkupContainer

WebPage Panel Link

Component frameworks

Wicket: Architecture

awt.Component

awt.Container

JContainer

JComponent

JPanel JLabel JButton

awt.Window

awt.Frame

JFrame

Swing Wicket

Page 42: Java Edge.2008.Web.Frameworks.Catagorized

42

Component frameworks

Wicket: Architecture

Submit

Username

Password

Model

View Controller

Component

updatesconsults

rendersreceives

input

Id=submitBtn

HTML

< >

<input

type=”button”

wicket:id =

”submitBtn”/>

...

Page 43: Java Edge.2008.Web.Frameworks.Catagorized

43

Component frameworks

Wicket: Advantages

• Fast learning curve

• Simplicity / familiarity with Swing & OOP

• Clean templates

• Code centric – develop in Java

• Harness OOP power

• IDE & tools support / refactoring

• Rich component library

• Component composition and reuse

• Self contained

• Custom components made easy

Page 44: Java Edge.2008.Web.Frameworks.Catagorized

44

Component frameworks

Wicket: Disadvantages• Maintainability

• Java <--> HTML sync.

• HTML is scattered across pages

• Complex internals

• API is big

• No structured “best practices”

• No client side validations

• Not suitable for dynamic pages

• No central flow management

Page 45: Java Edge.2008.Web.Frameworks.Catagorized

45

Page 46: Java Edge.2008.Web.Frameworks.Catagorized

46

SOUI / SOFEA frameworks

SOUI / SOFEA frameworks

• SOUI – Service Oriented User Interface

• “MVC is dead”, 2007, Nolan Wright and Jeff Haynie

• Appcelerator

• SOFEA – Service Oriented Front End Architecture

• “Life above the Service Tier “, 2007, Prasad, Rajat Taneja and Vikrant Todankar

• Thin Server Architecture Working Group

Page 47: Java Edge.2008.Web.Frameworks.Catagorized

47

SOUI / SOFEA frameworks

SOUI / SOFEA frameworks

• Overview

• An architectural style for designing the presentation tier

• Presentation tier is moved from server to client

• MVC is implemented in client

• Backend is SOA architecture

Page 48: Java Edge.2008.Web.Frameworks.Catagorized

48

SOUI / SOFEA frameworks

Thin client application architecture

• Server (presentation layer)

• Serves web pages (application download)

• Drives application flow

• Manages data interchange:

browser <-> business layer

• Client (browser)

• Renders and displays markup

Model

View Controller

View

Client

Server

Web

Framework

Page 49: Java Edge.2008.Web.Frameworks.Catagorized

49

SOUI / SOFEA frameworks

Thin client application flaws

• Data interchange is not structured

• String name / value pairs

• No types / no data constraints

• Tight coupling of presentation flow & data interchange

• Presentation flow is driven by request (GET / POST)

• Every request forces a presentation flow

• “Back button“ problem

• Not real MVC

• Controller does not notify view of changes in model

• Limited interaction

• Peer-to-peer not supported

Page 50: Java Edge.2008.Web.Frameworks.Catagorized

50

SOUI / SOFEA frameworks

SOUI / SOFEA: Principles• Decouple presentation tier

• Application download

• Presentation flow

• Data interchange

• Presentation flow must be driven by client

• Client sate must be managed in client

• “Front Controller” is an anti-pattern

• Support for rich data structures

• No HTML (XML / JSON)

• No more object <-> string conversions

Model

ControllerView

Client

Server / Service

Web

Framework

Page 51: Java Edge.2008.Web.Frameworks.Catagorized

51

SOUI / SOFEA frameworks

SOUI / SOFEA: Principles - continued

• MVC in presentation tier

• Controller manages: client state, flow, data interchange

• Eliminate server side driven presentation

• Separate client and server concerns

• Client is responsible for the view

• Server is responsible for services

Page 52: Java Edge.2008.Web.Frameworks.Catagorized

52

SOUI / SOFEA frameworks

SOUI / SOFEA: Motivation

• Separation of responsibilities

• Server-side developer can focus on business logic

• Less complex applications

• Client is developed separately

• Improved protocol

• REST / SOAP to interface with SOA

• Maximize decoupling

• Client is independent of models &implementation technologies

Page 53: Java Edge.2008.Web.Frameworks.Catagorized

53

SOUI / SOFEA frameworks

SOUI / SOFEA: Model

• Download server (web server)

• Enables application download

• Application container

• Application is downloaded and runs in client container

• Browser / JVM / Flash runtime

• Service Interface

• Web services

• Data interchange

• XML/JSON enforce data structures, types & constraints

• Simple message-based contract

Page 54: Java Edge.2008.Web.Frameworks.Catagorized

54

SOUI / SOFEA frameworks

Architecture

SOA Business

Services

REST

SOAP

Service

Interface

Download

Server

View

Model

Controller

Client

Application

Application Container

Application

Download

(AD)

Data

Interchange

(DI)

Presentation

Flow

(PF)

Intenet

Page 55: Java Edge.2008.Web.Frameworks.Catagorized

55

SOUI / SOFEA frameworks

SOUI / SOFEA: Advantages

• Cleaner architectural model

• Decoupling of presentation flow and data interchange

• Strict separation of development roles

• Language-agnostic

• Services can now be written in any programming language

• Decoupling of the client and server

• Linked by a lightweight message contract

• Easier testing

• Create client-only prototypes

• Use local mockups of services

Page 56: Java Edge.2008.Web.Frameworks.Catagorized

56

SOUI / SOFEA frameworks

SOUI / SOFEA: Advantages - continued

• Performance / responsiveness

• Presentation layer is moved to client

• Scalability

• Application runs in client

• Orchestration

• Integration of services from different platforms

Page 57: Java Edge.2008.Web.Frameworks.Catagorized

57

SOUI / SOFEA frameworks

SOUI / SOFEA: Disadvantages• Security

• Security attacks on client (code hacking, access to OS)

• State is saved in the client / client validations

• Control

• Less control on execution

• Vertical Aspects

• No centralized interception point (logging, auditing)

• Responsiveness

• Application download can take time

• Complexity

• More technology / layers

Page 58: Java Edge.2008.Web.Frameworks.Catagorized

58

SOUI / SOFEA frameworks

Examples:

•GWT •Flex •Open Laszlo

Page 59: Java Edge.2008.Web.Frameworks.Catagorized

59

SOUI / SOFEA frameworks

Example: GWT (Google Web Toolkit)

• Overview

• Developing and debugging Ajax applications in Java

• Compiler translates Java into Javascript, CSS & HTML

• Programmatic layouting

• Announced at JavaOne, 2006

• OSS, Appache License ver 2.0

BrowserJavaScriptJava

Page 60: Java Edge.2008.Web.Frameworks.Catagorized

60

SOUI / SOFEA frameworks

GWT: Features• Runs in two modes

• Hosted mode – run Java bytecode in JVM / client side debugging

• Web mode – application is deployed as JS + HTML to browser

• Cross browser compatibility

• Highly optimized output

• Good web support

• Browser history management

• Powerful DOM access

• Bookmarks

• Rich components

Page 61: Java Edge.2008.Web.Frameworks.Catagorized

61

SOUI / SOFEA frameworks

GWT: Architecture

HTTP Web Server

Browser

Front End Back End

Java Web Server

RPC

Asdf asd sdf asdf asdf

asdf dsf sdf sdf

Asdf asd sdf asdf asdf

asdf dsf sdf sdf

Asdf asd sdf asdf asdf

asdf dsf sdf sdf

Asdf asd sdf asdf asdf

asdf dsf sdf sdf

Asdf asd sdf asdf asdf

asdf dsf sdf sdf

JS

JS

Engine

{ }

Servlet

Container

JSON/XML

HTTP

View + Controller Model

SOAHTTP

<<Service>>

Servlet

<<Service>>

PHP Script

Page 62: Java Edge.2008.Web.Frameworks.Catagorized

62

SOUI / SOFEA frameworks

GWT: Advantages

• Fast and responsive

• Zero turnaround in hosted mode

• Write pure Java

• IDE & tools support

• Refactoring

• Debugging

• No markup / JavaScript mix

Page 63: Java Edge.2008.Web.Frameworks.Catagorized

63

SOUI / SOFEA frameworks

GWT: Disadvantages• Developer / Designer overlap

• Designer cannot use design tools

• Markup is hard to tweak / CSS hooks

• Runs as JavaScript in browser

• No concurrency

• Limited reflection

• Form processing

• No data binding

• No built in form validation

• Missing best practices

• Architectural decisions are left to the developer

• Limited search engine optimization

Page 64: Java Edge.2008.Web.Frameworks.Catagorized

64

Page 65: Java Edge.2008.Web.Frameworks.Catagorized

65

Comparison

Which is best?

• Choose the right type of framework for the job

• There is always one tool that is a better fit

• No one framework provides a solution for all issues

• Identify and priorities the requirements

Page 66: Java Edge.2008.Web.Frameworks.Catagorized

66

Comparison

So how do we choose ?

Page 67: Java Edge.2008.Web.Frameworks.Catagorized

67

Comparison

Evaluation criteria• Speed of development

• Learning curve, complexity

• Scalability

• Lifetime and maintainability

• Documentation

• Source, Guides, JavaDoc, Books

• Tool support

• IDE’s, plug-ins

• Popularity

• Work force, developer community, places in use

• Technical support

• Standard compliance

Page 68: Java Edge.2008.Web.Frameworks.Catagorized

68

Comparison

Evaluation criteria - continued• Separation of responsibilities

• Business logic / markup

• Power / Ease of use

• Design of markup, tags, templating

• Flexibility

• Change view technology

• Change default behaviour

• Transparent Infrastructure

• What goes on under the hood

• Can you get out of the framework?

• Extensibility

Page 69: Java Edge.2008.Web.Frameworks.Catagorized

69

Comparison :: Summary

Separation of

responsibilities - + ++

Speed of

development ++ + +

Scalability + - ++

Maintainability - + -

Community

Support ++ + -

Transparency ++ + -

Security ++ + -

TargetSimple user

interaction / Fast Complex UI

Responsive UI /

Scalability

Request / Response

Frameworks

Component

Framework

SOUI / SOFEA

Framework

Page 70: Java Edge.2008.Web.Frameworks.Catagorized

70

Page 71: Java Edge.2008.Web.Frameworks.Catagorized

71

The Future

• Are we on the right track?• Is diet going out of fashion?

• Survival of the fittest• Software evolution

• Frameworks evolve, rather than being explicitly developed

• Best of breed• Consolidation? (Struts + WebWorks)

• New technologies

• E.g. JavaFX, Comet / AJAX push

Page 72: Java Edge.2008.Web.Frameworks.Catagorized

72

Thank

You !