csci5211: Computer Networks and Data Communications

advertisement
Internet Engineering Course
Web Application Architectures
Agenda
1.
2.
3.
4.
Application servers
J2EE
.Net
Comparison between J2EE and .Net
1. Application Servers

In the beginning, there was darkness and
cold.Then, …
mainframe
terminals
terminals
Centralized, non-distributed
Application Servers

In the 90’s, systems should be client-server
Application Servers

Today, enterprise applications use the multitier model
Three-Tier Architecture
Web Application Architecture
Application Servers
“Multi-tier applications” have several
independent components
 An application server provides the
infrastructure and services to run such
applications

Application 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 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 Server
App Server 1
Internet Browser
Web Server
(HTTP Server)
HTTP(S)
App Server 2
What is J2EE?
It is a public specification that embodies
several technologies
 Current version is 1.4
 J2EE defines a model for developing multitier, web based, enterprise applications
with distributed components

J2EE Architecture
J2EE Benefits
High availability
 Scalability
 Integration with existing systems
 Freedom to choose vendors of application
servers, tools, components
 Multi-platform

J2EE 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 technologies
JavaServer Pages (JSP)
 Servlet
 Enterprise JavaBeans (EJB)

 JSPs, servlets
and EJBs are application components
JSP





Used for web pages with dynamic content
Processes HTTP requests (non-blocking call-andreturn)
Accepts HTML tags, special JSP tags, and scriptlets of
Java code
Separates static content from presentation logic
Can be created by web designer using HTML tools
Servlet
Used for web pages with dynamic content
 Processes HTTP requests (non-blocking call-and-return)
 Written in Java; uses print statements to render HTML
 Loaded into memory once and then called many times
 Provides APIs for session management

A Sample Scenario
(1) get a.jsp
Client
(5) HTTP file
Web
Server
(2) process
Other
Components
JSP
(3) gen. Servlet Servlet
Impl.
(4) result
Servlet
Database
JVM
EJB
EJBs are distributed components used to implement
business logic (no UI)
 Developer concentrates on business logic
 Availability, 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 Model
J2EE Application Scenarios

Multi-tier typical application
J2EE Application Scenarios

Stand-alone client
J2EE Application Scenarios

Web-centric application
J2EE Application Scenarios

Business-to-business
J2EE Services and APIs

Java Message Service (JMS)
◦ Implicit invocation
◦ Communication is loosely coupled, reliable
and asynchronous
◦ Supports 2 models:
 point-to-point
 publish/subscribe
JMS

Point-to-point
◦ Destination is “queue”
JMS

Publish-subscribe
◦ Destination is “topic”
J2EE 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 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 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 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
adapters

Support to Corba clients
J2EE Services and APIs
JDBC
 JavaMail
 Java API for XML Parsing (JAXP)
 Web services APIs

3. EJB – a closer look
Home 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 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

Remoting in Java

Several possibilities: RMI/CORBA
◦ RMI can use JRMP or IIOP as a transport protocol
◦ Not pluggable – changes in the code are necessary
Client
Stub
Server
Stub/Skeleton-Layer
Remote Reference Manager
Transport Layer
Skeleton
EJB – The Big Picture
EJB at runtime
Client can be local or remote
EJB at runtime
Types of EJB
EJB Taxonomy
EnterpriseBean
SessionBean
EntityBean
Stateful
BMP
Stateless
CMP
MessageDrivenBean
New!
Session 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 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 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 clients
 Can live past the duration of client’s session
 Example: shopping order

Entity 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 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 interface
 Example: order processing – stock info

Example of EJB Application
It consists of number of clients accessing session
beans and entity beans
 Each Session bean provides specialized processing
on behalf of client
e.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 Application
JBoss- J2EE Product
FIND OUT MORE ABOUT
TODAY’S MOST SUCCESSFUL OPEN
SOURCE- DEVELOPED PPLICATION
SERVER
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 Server
Introduction to .NET Framework
.NET – What Is It?
Software platform
 Language neutral
 In other words:

.NET is not a language (Runtime and a library
for writing and executing written programs in
any compliant language)
What 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 Application
.NET Framework
Operating System + Hardware
Framework, Languages, And Tools
VB
VC++
VC#
JScript
…
Common Language Specification
Windows
Forms
ADO.NET: Data and XML
Base Class Library
Common Language Runtime
Visual Studio.NET
ASP.NET: Web Services
and Web Forms
The .NET Framework
.NET Framework Services
Common Language Runtime
 Windows® Forms
 ASP.NET

◦ Web Forms
◦ Web Services
ADO.NET, evolution of ADO
 Visual Studio.NET

Common Language Runtime (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 Runtime

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 Runtime
Multiple 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 (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.
Languages

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 .NET
VB.NET
C++
Perl
Compiler
C#
MSIL +
Metadata
Garbage
Collection,
Security,
Multithreading,
...
Loader/
Verifier
JIT
Execution
Managed
Code
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.NET
ASP.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 Forms

Allows clean cut code
◦ Code-behind Web Forms
Easier for tools to generate
 Code within is compiled then executed
 Improved handling of state information
 Support for ASP.NET server controls

◦ Data validation
◦ Data bound grids
ASP.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.NET

Development tool that contains a rich set
of productivity and debugging features
Summary of .NET

The .NET Framework
◦ Dramatically simplifies development and
deployment
◦ Provides robust and secure execution
environment
◦ Supports multiple programming languages
Comparison between
J2EE and .NET
J2EE – 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 Solutions
Similarities
 Both 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 Comparison
Language
 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 Comparison
Java vs. C#
// This is a comment in Java code
class 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 Comparison
Presentation 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 Comparison
Common Elements
Concepts
 Presentation
 Business Logic
J2EE
JSP/Servlets
EJB/Servlets
Language
 Platform
Java
Any

.NET
ASP.NET
Code Behind,
Remoted Classes
C#,VB.NET
Windows

DB Connectivity
JDBC
ADO.NET (OLE-DB,
ODBC)

Web Services
Messaging
Runtime
Transaction
Distributed computing
XML Parser
JWSDP
JMS
JRE
JTA/JTS, XA
RMI, CORBA, SOAP
JAXP, Others
Web Services
MTS
CLR
Com+, DTC
SOAP, DCOM
Built-in
(System.XML)





Microsoft .Net vs. J2EE Scorecard
Criteria
Ease Of Use (Development
Environment)
Scalability
Single Language Multiple
Platforms
J2EE
**
***
****
.NET
****
Comments
VB.net and C# are easier to use than
J2EE
**
Execute Java Code on
Mainframe
*
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
*
***
VB code easiar to learn
Speed of development
Reuse
****
**
Deploy same code on multiple
platforms and multiple projects
Open Standards
*****
*
Java, JVM are open standards
Overall
56%
51%
A typical .NET Enterprise Solution
IIS on W2k Server
Browser
Windows
Client
ASP
.NET
.NET
managed
component
SQL
Server
A typical J2EE Enterprise Solution
Java App
Server
Servlet
EJB
JSP
Browser
Java
Client
DB
Server
Porting Java Pet Store (Example) to .NET
15500
14,273
Lines of Code Required
14000
.NET Petshop
11500
Java Pet Store
9000
7500
5,891
5,404
4,410
5000
2,865
2,566
710
2500
Total Lines
of Code
User
Interface
Middle Tier
761
412
74
Data Tier Configuration
Forrester Report: The State of Technology
Adoption
Source: http://download.microsoft.com/download/c/7/5/c75837dc-90bb-44d8-ae70db7bcc5980b9/TheStateofTechnologyAdoption.pdf
Microsoft .Net vs. J2EE Comparison
CLR vs JVM
C#
Java
VB Managed Lots of other
.Net C/C++ Languages
MSIL
Byte Codes
CLR
Runtime Services
JRE (JVM)
Runtime Services
Windows OS
Mac
Win Unix Linux
Both are ‘middle layers’ between an intermediate
language & the underlying OS
.Net 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 .Net
 The ultimate choice usually depends not on
technical superiority, but on:
 Cultural/political preferences
 Customer preference
 Vendor relations
 Cost
 Platform Dependency
 Skill set of your developers
Sources & Resources
The J2EE Tutorial. Sun Microsystems
 IBM WebSphere Application Server
manuals
 BEA WebLogic Server manuals
 www.java.sun.com/j2ee
 www.theserverside.com

Sources & 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
Download