Internet Engineering Course Web Application Architectures.

89
Internet Engineering Internet Engineering Course Course Web Application Architectures

Transcript of Internet Engineering Course Web Application Architectures.

Internet Engineering Internet Engineering CourseCourse

Web Application Architectures

AgendaAgenda

1. Application servers2. J2EE3. .Net4. Comparison between J2EE and

.Net

1. Application Servers1. Application Servers

In the beginning, there was darkness and cold. Then, …

Centralized, non-distributed

terminals

mainframe

terminals

Application ServersApplication Servers

In the 90’s, systems should be client-server

Application ServersApplication Servers

Today, enterprise applications use the multi-tier model

Three-TierThree-Tier ArchitectureArchitecture

Web Application Web Application ArchitectureArchitecture

Application ServersApplication Servers

“Multi-tier applications” have several independent components

An application server provides the infrastructure and services to run such applications

Application ServersApplication Servers

Application server products can be separated into 3 categories:◦J2EE-based solutions◦Non-J2EE solutions (PHP, ColdFusion,

Perl, etc.)◦And the Microsoft solution (ASP/COM

and now .NET with ASP.NET, VB.NET, C#, etc.)

J2EE Application ServersJ2EE Application Servers

Major J2EE products:◦BEA WebLogic◦IBM WebSphere◦Sun iPlanet Application Server◦Oracle 9iAS◦HP/Bluestone Total-e-Server◦Borland AppServer◦Jboss (free open source)

Web Server and Application Web Server and Application ServerServer

Web Server

(HTTP Server)

App Server 1

App Server 2

Internet Browser

HTTP(S)

What is J2EE?What is J2EE?

It is a public specification that embodies several technologies

Current version is 1.4J2EE defines a model for

developing multi-tier, web based, enterprise applications with distributed components

J2EEJ2EE ArchitectureArchitecture

J2EE BenefitsJ2EE Benefits

High availabilityScalabilityIntegration with existing systemsFreedom to choose vendors of

application servers, tools, components

Multi-platform

J2EE BenefitsJ2EE Benefits

Flexibility of scenarios and support to several types of clients

Programming productivity:◦ Services allow developer to focus on business◦ Component development facilitates maintenance

and reuse◦ Enables deploy-time behaviors◦ Supports division of labor

Main technologiesMain technologies

JavaServer Pages (JSP)ServletEnterprise JavaBeans (EJB)

JSPs, servlets and EJBs are application components

JSPJSP

Used for web pages with dynamic contentProcesses HTTP requests (non-blocking call-

and-return) Accepts HTML tags, special JSP tags, and

scriptlets of Java codeSeparates static content from presentation

logicCan be created by web designer using

HTML tools

ServletServlet

Used for web pages with dynamic contentProcesses HTTP requests (non-blocking call-

and-return)Written in Java; uses print statements to

render HTMLLoaded into memory once and then called

many timesProvides APIs for session management

A Sample ScenarioA Sample Scenario

WebServer

Client(1) get a.jsp (2) process

JVM

JSP

OtherComponents

Database

(4) result

(5) HTTP file

Servlet

(3) gen. Servlet Servlet Impl.

EJBEJB

EJBs are distributed components used to implement business logic (no UI)

Developer concentrates on business logicAvailability, scalability, security,

interoperability and integrability handled by the J2EE server

Client of EJBs can be JSPs, servlets, other EJBs and external aplications

Clients see interfaces

J2EE Multi-tier ModelJ2EE Multi-tier Model

J2EE Application ScenariosJ2EE Application Scenarios

Multi-tier typical application

J2EE Application J2EE Application ScenariosScenarios

Stand-alone client

J2EE Application ScenariosJ2EE Application Scenarios

Web-centric application

J2EE Application ScenariosJ2EE Application Scenarios

Business-to-business

J2EE Services and APIsJ2EE Services and APIs

Java Message Service (JMS)◦Implicit invocation◦Communication is loosely coupled,

reliable and asynchronous◦Supports 2 models:

point-to-point publish/subscribe

JMSJMS

Point-to-point◦Destination is “queue”

JMSJMS

Publish-subscribe◦Destination is “topic”

J2EE Services and APIsJ2EE Services and APIs

JNDI - Naming and directory services◦Applications use JNDI to locate

objects, such as environment entries, EJBs, datasources, message queues

◦JNDI is implementation independent◦Underlying implementation varies:

LDAP, DNS, DBMS, etc.

J2EE Services and APIsJ2EE Services and APIs

Transaction service:◦Controls transactions automatically◦You can demarcate transactions

explicitly◦Or you can specify relationships

between methods that make up a single transaction

J2EE Services and APIsJ2EE Services and APIs

Security◦ Java Authentication and Authorization Service (JAAS)

is the standard for J2EE security◦ Authentication via userid/password or digital

certificates◦ Role-based authorization limits access of users to

resources (URLs, EJB methods)◦ Embedded security realm

J2EE Services and APIsJ2EE Services and APIs

J2EE Connector Architecture◦Integration to non-J2EE systems,

such as mainframes and ERPs.◦Standard API to access different EIS◦Vendors implement EIS-specific

resource adaptersSupport to Corba clients

J2EE Services and APIsJ2EE Services and APIs

JDBCJavaMailJava API for XML Parsing (JAXP)Web services APIs

3. EJB – a closer look3. EJB – a closer look

Home InterfaceHome Interface

Methods to create, remove or locate EJB objects

The home interface implementation is the home object (generated)

The home object is a factory

Remote InterfaceRemote Interface

Business methods available to clients

The remote interface implementation is the EJB object (generated)

The EJB object acts as a proxy to the EJB instance

Stub/Skeleton-Layer

Remoting in JavaRemoting in JavaSeveral possibilities: RMI/CORBA

◦ RMI can use JRMP or IIOP as a transport protocol◦ Not pluggable – changes in the code are necessary

Client Server

Stub Skeleton

Remote Reference Manager

Transport Layer

EJB – The Big PictureEJB – The Big Picture

EJB at runtimeEJB at runtime

Client can be local or remote

EJB at runtimeEJB at runtime

Types of EJBTypes of EJB

EJB Taxonomy

Sta te ful

Sta te le ss

Se ssio nBe a n

BM P

C M P

EntityBe a n M e ssa g e Drive nBe a n

Ente rp rise Be a n

New!

Session BeanSession Bean

Stateful session bean: ◦Retains conversational state (data)

on behalf of an individual client◦If state changed during this

invocation, the same state will be available upon the following invocation

◦Example: shopping cart

Session BeanSession Bean

Stateless session bean:◦Contains no user-specific data◦Business process that provides a

generic service◦Container can pool stateless beans◦Example: shopping catalog

Entity BeanEntity Bean

Represents business data stored in a database persistent object

Underlying data is normally one row of a table

A primary key uniquely identifies each bean instance

Allows shared access from multiple clientsCan live past the duration of client’s sessionExample: shopping order

Entity BeanEntity Bean

Bean-managed persistence (BMP): bean developer writes JDBC code to access the database; allows better control for the developer

Container-managed persistence (CMP): container generates all JDBC code to access the database; developer has less code to write, but also less control

Message-Driven BeanMessage-Driven Bean

Message consumer for a JMS queue or topic

Benefits from EJB container services that are not available to standard JMS consumers

Has no home or remote interfaceExample: order processing –

stock info

Example of EJB ApplicationExample of EJB ApplicationIt consists of number of clients accessing

session beans and entity beansEach Session bean provides specialized

processing on behalf of cliente.g. Travel Agent session bean makes travel

reservations while Flight Scheduler bean schedules planes to fly on various routes.

Each Entity Bean represent different type of business entity.

e.g.Passengers, seats, planes, flights are entity beans

Example EJB ApplicationExample EJB Application

JBoss- J2EE ProductJBoss- J2EE Product

FIND OUT MORE ABOUT

TODAY’S MOST SUCCESSFUL OPEN

SOURCE- DEVELOPED PPLICATION

SERVER

What is Jboss?What is Jboss? Created in 1999, JBoss is the product of an

OpenSource developer community dedicated to developing the best J2EE-compliant application server in the market

With 1000 developers worldwide and a steadily growing number of downloads per month, reaching 72,000 for October ’01 (per independent www.sourceforge.net), JBoss is arguably the most downloaded application server in the world today

Distributed under an LGPL license, JBoss is absolutely FREE for use. No cost. Period.

JBoss- Application ServerJBoss- Application Server

Introduction to .NET Framework

.NET – What Is It?.NET – What Is It?

Software platformLanguage neutralIn other words:

.NET is not a language (Runtime and a library for writing and executing written programs in any compliant language)

What Is .NETWhat Is .NET.Net is a new framework for

developing web-based and windows-based applications within the Microsoft environment.

The framework offers a fundamental shift in Microsoft strategy: it moves application development from client-centric to server-centric.

.NET – What Is It?.NET – What Is It?

Operating System + Hardware

.NET Framework

.NET Application

Base Class Library

Common Language Specification

Common Language Runtime

ADO.NET: Data and XML

VB VC++ VC#

Visu

al S

tud

io.N

ET

ASP.NET: Web Servicesand Web Forms

JScript …

WindowsForms

Framework, Languages, And ToolsFramework, Languages, And Tools

The .NET FrameworkThe .NET Framework.NET Framework Services.NET Framework Services

Common Language RuntimeWindows® FormsASP.NET

◦Web Forms◦Web Services

ADO.NET, evolution of ADOVisual Studio.NET

Common Language Runtime Common Language Runtime (CLR)(CLR)CLR works like a virtual machine in executing all languages. All .NET languages must obey the rules and standards imposed by CLR. Examples:◦ Object declaration, creation and use◦ Data types, language libraries◦ Error and exception handling◦ Interactive Development Environment

(IDE)

Common Language Common Language RuntimeRuntime Development

◦ Mixed language applications Common Language Specification (CLS) Common Type System (CTS) Standard class framework Automatic memory management

◦ Consistent error handling and safer execution

◦ Potentially multi-platform Deployment

◦ Removal of registration dependency◦ Safety – fewer versioning problems

Common Language Common Language RuntimeRuntimeMultiple Language SupportMultiple Language Support• CTS is a rich type system built into the

CLR– Implements various types (int, double, etc)– And operations on those types

• CLS is a set of specifications that language and library designers need to follow– This will ensure interoperability between

languages

Intermediate Language Intermediate Language (IL)(IL)

.NET languages are not compiled to machine code. They are compiled to an Intermediate Language (IL).

CLR accepts the IL code and recompiles it to machine code. The recompilation is just-in-time (JIT) meaning it is done as soon as a function or subroutine is called.

The JIT code stays in memory for subsequent calls. In cases where there is not enough memory it is discarded thus making JIT process interpretive.

LanguagesLanguages Languages provided by MS

◦ VB, C++, C#, J#, JScript Third-parties are building

◦ APL, COBOL, Pascal, Eiffel, Haskell, ML, Oberon, Perl, Python, Scheme, Smalltalk…

Compilation in .NETCompilation in .NET

C#

VB.NET

C++

Perl

Com

pile

r

MSIL +Metadata

Loader/Verifier JIT

Managed Code

ExecutionGarbage

Collection,Security,

Multithreading,...

Windows Forms

• Framework for Building Rich Clients– RAD (Rapid Application Development)– Rich set of controls– Data aware– ActiveX® Support– Licensing– Accessibility– Printing support– Unicode support– UI inheritance

ASP.NETASP.NETASP.NET, the platform services that allow to program Web Applications and Web Services in any .NET language

ASP.NET Uses .NET languages to generate HTML pages. HTML page is targeted to the capabilities of the requesting Browser

ASP.NET “Program” is compiled into a .NET class and cached the first time it is called. All subsequent calls use the cached version.

ASP.NET

• Logical Evolution of ASP– Supports multiple languages– Improved performance– Control-based, event-driven execution model– More productive– Cleanly encapsulated functionality

ASP.NET Web FormsASP.NET Web Forms

Allows clean cut code◦Code-behind Web Forms

Easier for tools to generateCode within is compiled then

executed Improved handling of state

informationSupport for ASP.NET server

controls◦Data validation◦Data bound grids

ASP.NET Web ServicesASP.NET Web Services

A technical definition◦“A programmable application

component accessible via standard Web protocols”

Web Services

• It is just an application…

• …that exposes its features and capabilities over the network…

• …using XML…

• …to allow for the creation of powerful new applications that are more than the sum of their parts…

ADO.NET(Data and XML)

• New objects (e.g., DataSets)

• Separates connected / disconnected issues

• Language neutral data access

• Uses same types as CLR

• Great support for XML

Visual Studio.NETVisual Studio.NETDevelopment tool that contains a

rich set of productivity and debugging features

Summary of .NETSummary of .NETThe .NET Framework

◦Dramatically simplifies development and deployment

◦Provides robust and secure execution environment

◦Supports multiple programming languages

Comparison between Comparison between J2EE and .NETJ2EE and .NET

J2EE – Enterprise JavaJ2EE – Enterprise Java

J2EE: Java 2 Enterprise Edition Superset of Java 2 Standard Edition

(J2SE) Adds enterprise features to Java

Libraries Defined through the Java

Community Process (JCP) Wholly owned property of Sun

Microsystems

J2EE Solutions vs Microsoft .Net J2EE Solutions vs Microsoft .Net Solutions Solutions

SimilaritiesSimilaritiesBoth multi-tiered, similar computing technologies

Both support “standards”Both offer different tools & ways to achieve the same goal.

A lot of parallelism can be seen.Very difficult to compare and qualify the comparison because each has its own advantages & disadvantages.

Microsoft .Net vs. J2EE ComparisonMicrosoft .Net vs. J2EE ComparisonLanguageLanguage

C# and Java both derive from C and C++. MS says: “C# combines the power of VC++ with

the ease of usage of VB” Significant features include garbage

collection, hierarchical namespaces) are present in both.

Different Syntax but same result. Java runs on any platform with a Java VM. C#

only runs in Windows for the foreseeable future.

C# is implicitly tied into the CLR and is compiled entirely into native code. Java code runs as Java Virtual Machine and executes byte code

Microsoft .Net vs. J2EE Microsoft .Net vs. J2EE ComparisonComparisonJava vs. C#Java vs. C#

// This is a comment in Java codeclass HelloWorld{ public static void main(String[] args){ for(int i= 1; i<= 100; i++) System.out.println("Hello!");  }

}// This is a comment in C#using System;class HelloWorld{static void Main(){ for(int i=1; i<=100; i++)     Console.WriteLine("Hello");  }}

}

Microsoft .Net vs. J2EE ComparisonMicrosoft .Net vs. J2EE ComparisonPresentation LayerPresentation Layer

ASP(+) vs. JSP ASP(+) can use Visual Basic, C#,

and possibly other languages for code snippets.

JSPs use Java code (snippets, or JavaBean references), compiled into Java

Win Forms/Web Forms Vs Swing/Java Server Faces

Microsoft .Net vs. J2EE - A technical Microsoft .Net vs. J2EE - A technical ComparisonComparison

Common Elements Common Elements

Concepts J2EE .NET Presentation JSP/Servlets ASP.NET Business Logic EJB/Servlets Code Behind,

Remoted Classes

Language Java C#, VB.NET Platform Any Windows DB Connectivity JDBC ADO.NET (OLE-

DB, ODBC) Web Services JWSDP Web Services Messaging JMS MTS Runtime JRE CLR Transaction JTA/JTS, XA Com+, DTC Distributed computing RMI, CORBA, SOAP SOAP, DCOM XML Parser JAXP, Others Built-in

(System.XML)

Criteria J2EE .NET Comments

Ease Of Use (Development Environment) ** ****

VB.net and C# are easier to use than J2EE

Scalability *** **Execute Java Code on

Mainframe

Single Language Multiple Platforms **** *

Java Can run on many platforms through the JVM

Multiple Languages Single Platform * ****

VB,C#,J# all run in the same run-time environment

Reliability ** **** VB/Com development in 1993

Performance *** *** Equal Performance

Speed of development * *** VB code easiar to learn

Reuse **** **Deploy same code on multiple

platforms and multiple projects

Open Standards ***** * Java, JVM are open standards

Overall 56% 51%

Microsoft .Net vs. J2EE ScorecardMicrosoft .Net vs. J2EE Scorecard

A typicalA typical .NET Enterprise Solution.NET Enterprise Solution

SQLServer

IIS on W2k Server

.NET managed

componentASP.NET

WindowsClient

Browser

A typical J2EE Enterprise A typical J2EE Enterprise SolutionSolution

DB Server

Java App Server

EJBServlet

JSP

Java Client

Browser

Porting Java Pet Store (Example) Porting Java Pet Store (Example) to .NETto .NET

14000

7500

9000

5000

2500

15500

11500Java Pet Store

Lines of Code Required

User Interface

4,410

Data TierMiddle Tier

2,865

.NET Petshop

14,273

5,891

ConfigurationTotal Lines of Code

710

5,404

761 412 74

2,566

Forrester Report: The State of Forrester Report: The State of Technology AdoptionTechnology Adoption Source: Source: http://download.microsoft.com/download/c/7/5/c75837dc-90bb-44d8-ae70-db7bcc5980b9/TheStateofTechnologyAdoption.pdf

Microsoft .Net vs. J2EE ComparisonMicrosoft .Net vs. J2EE Comparison CLR vs JVMCLR vs JVM

C# ManagedC/C++

Lots of otherLanguages

VB.Net

CLRRuntime Services

MSIL

Windows OS

Java

JRE (JVM)Runtime Services

Byte Codes

Mac Unix LinuxWin

Both are ‘middle layers’ between an intermediate language & the underlying OS

..Net DisadvantagesNet Disadvantages

Security .NET better than prior frameworks (DNA, DCOM,

ActiveX, etc.), but still based on Windows Immaturity

Version 1.0 issues, likely to change in future Language changes for developers new to .NET

Application migration to .NET costly Not enough real world use yet to evaluate Vendor lock-in Future direction determined by Microsoft.

Choosing between Java/J2EE and Choosing between Java/J2EE and .Net.Net

The ultimate choice usually depends not on technical superiority, but on:Cultural/political preferencesCustomer preferenceVendor relationsCostPlatform DependencySkill set of your developers

Sources & ResourcesSources & Resources

The J2EE Tutorial. Sun Microsystems

IBM WebSphere Application Server manuals

BEA WebLogic Server manualswww.java.sun.com/j2eewww.theserverside.com

Sources & ResourcesSources & Resources

Java 2 Platform Enterprise Edition Specification, v1.3

Designing Enterprise Applications with the Java 2, Enterprise Edition. Nicholas Kassen and the Enterprise Team

Does the App Server Maket Still Exist? Jean-Christophe Cimetiere

The State of The J2EE Application Server Market. Floyd Marinescu