Title: J2EE and Microsoft 'NET Framework Enterprise Computing
1J2EE and Microsoft .NET Framework Enterprise
Computing
2Administrivia
- TA applications due tomorrow _at_ noon
- http//www.cc.gatech.edu/TA-app
- 12/2 Demo your project!
- 1 pt extra credit
- Send me email to sign up
3What is an Enterprise?
- A large organization that uses computers
- Has existing IT resources
- databases
- applications
- Has large amounts of data
- May have high transaction volumes
- Has complex multi-tier environments
4What is an Enterprise Application?
- Software that supports the purpose of the
enterprise - Examples
- Filling orders
- Tracking inventory
- Handling accounts
- Making reservations
5Evolution of Enterprise Software
- 1960s mainframes with punch card entry
- Batch jobs ran at night from punch cards
- Data usually a day behind
- 1970s mainframes with dumb terminal entry
- VSAM filesystem for data store with indexes and
keys - 1980s mainframes with personal computer clients
- SQL for access to relational databases
- Some work done locally
- 1990s Client Server
- Cost of supporting client software was high
- Limits on transaction throughput with 2 tiers
- 2000s N-tier with many different client devices
- J2EE, CORBA, and .Net for enterprise applications
6What is hard about Enterprise Software?
- Handling a variety of operating systems,
databases, and servers - Handling large numbers of users
- Handling large numbers of transactions
- Providing security
- Keeping the system up
- Allowing for growth
- Allowing for different client devices (browser,
wireless, applets, applications) - Connecting to legacy applications
7What is J2EE?
- Java 2 Platform, Enterprise Edition
- A standard architecture for creating, deploying,
and managing enterprise-level server-side
software - J2EEs Goal
- Provide components that make it faster, cheaper,
and less complex to develop and maintain
enterprise applications that are - machine, server, and database independent
- multi-tier
- scalable
- reliable
- secure
8What do we mean by the J2EE?
- Specifications
- Group developed requirements for the J2EE
platforms - Server
- Software that runs J2EE applications
- Compatibility Test Suite
- How a platform is tested to verify specification
compliance - Reference Implementation
- A sample implementation of the specifications
- Blueprints
- Best practices and guidelines
9Why use the J2EE?
- Use it for applications that
- Are machine, server, and database independent
- So you can move your application to different
machines, operating systems, and databases - Are scalable
- Can grow over time
- Require transactions
- Like debiting one account and crediting another
at the same time - Are reliable
- Stay up and handle large numbers of users
- Are secure
- Protect sensitive data
10J2EE Primary APIs
- JavaServer Pages (JSPs)
- Dynamic page creation based on client request
- Java Servlets
- Controller for routing client requests to JSP
- Enterprise JavaBeans (EJBs)
- Represent business entities and processes
- JDBC data access API
- Access data in relational databases
- The Java Naming and Directory Interface (JNDI)
- Access enterprise name and directory services
- The Java Transaction API (JTA)
- Handle distributed transactions
- Interface Definition Language (IDL)
- Access CORBA services via IIOP
11What do the APIs do?
JNDI
EJB
EJB
JTA
EJB
HTTP
Servlet
EJB
JDBC
EJB
EJB
JSP
JSP
IDL
HTML or XML
CORBA
12J2EE Secondary APIs
- Java Message Service (JMS)
- Send asynchronous messages
- JavaMail
- Send and receive e-mail
- J2EE Connector Architecture
- Connect to legacy systems
- XML Pack
- Java API for XML Processing (JAXP)
- Parse and transform XML documents
- Java API for XML Messaging (JAXM)
- Send and receive XML messages
- Java API for XML Registries (JAXR)
- Interact with XML Registries (UDDI and ebXML)
- Java API for XML-based RPC (JAX-RPC)
- Remote procedure calls(RPC) with Simple Object
Access Protocol (SOAP)
13Common Language Runtime (CLR)
- Its a VM (Java-like) on which any (supported)
language can run. - Why a VM?
- Memory Protection
- Cross-language
- Support for strong-typing across languages
- Thread support
- Compactness
- Flexibility (Reflection, Meta-programming)
- JIT compilation in the VM
- Stack-based
- 3 generation garbage collector
14Languages in CLR
- Language of choice is C (C-sharp) a Java-like
language - No inner classes
- Better type checking
- Other languages will run on CLR, but only within
the CLR constraints - Visual Basic, JScript are full fledged CLR
languages - For example, only C that is VM-safe will run
- That subset looks much like C
- Under CLR, all languages get object features
- Inheritance used extensively
- Every language gets constructors
15Supported Languages
- Languages targeted to CLR
- APL C
C COBOL - Component Pascal Curriculum Eiffel
Fortran - Haskell Java Language
Microsoft JScript Mercury - Mondrian Oberon Oz
Pascal - Perl Python
RPG Scheme - Smalltalk Standard ML
Microsoft Visual Basic
Languages interoperate seamlessly. Can write
part of app in Scheme, part in C and part in
Smalltalk!
16Languages compile to MSIL
- Languages compile to MSIL (Microsoft Intermediate
Language) - Also known as bytecodes
- MSIL is shipped in portable executable (PE) units
- Similar to, say, .class files or applets
- Includes meta-data about types
- An application is made up of assemblies
17Reuse
- Tries to get maximum reuse of components/assemblie
s (like Smalltalk)
We get this in the .NET world via assemblies.
18Assemblies
- In general, a static assembly can consist of four
elements - The assembly manifest, which contains assembly
metadata (required). - Type metadata.
- Microsoft intermediate language (MSIL) code that
implements the types. - A set of resources.
19Assemblies can be spread across the network
20Assemblies are the security unit
- Each assembly has a set of corresponding grants
- Each grant allows certain permissions
- DnsPermission, Environment, FileDialog, FileIO,
IsolatedStorage, Reflection, Registry, Security,
UI, WebPermission, SocketPermission - The set of grants establishes a security policy
- Grants are determined by CLR managed code
security policy system.
21Assemblies
- They are also the basic unit for
- Versioning
- Types
- Reference Scope Boundary
- Deployment
- Side-by-side execution
- Can be shared via the Global Assembly Cache (like
a Squeak Image).
22Application Domains
- Processes provide nice separation of applications
with separate address, security and run control.
But causes problems with IPC. - Application Domains allow multiple applications
to run in same box, share memory and security
rights, but also have isolation and individual
security and run control if desired. So a
process can run multiple applications!
23Class Library
- Data classes support persistent data management
and include SQL classes. - XML classes enable XML data manipulation and XML
searching and translations. - Windows Forms support development of Windows GUI
applications across CLR - Web Forms include classes that enable you to
rapidly develop web GUI applications.
24Forms
25C System.Object
- Public methods
- Equals
- GetHashCode
- GetType
- ToString
- Overriding inherited behaviors is common
26C Code and Manifest
using System class MainApp public static
void Main() Console.WriteLine
("Hello World using C!")
.assembly extern mscorlib .publickeytoken
(B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 1024110 .assembly Hello // ---
The following custom attribute is added
automatically do not uncomment. ------- //
.custom instance void mscorlibSystem.Diagnostics
.DebuggableAttribute.ctor(bool, // bool)
( 01 00 00 01 00 00 ) .hash algorithm
0x00008004 .ver 0000 .module Hello.exe
// MVID 58AD9DFD-63A6-462A-8AD5-42CBC95AA147
.subsystem 0x00000003 .file alignment 512
.corflags 0x00000001 // Image base
0x03330000
27Web, Windows, Whatever
- Part of the idea is to smooth transitions between
Windows and Web - Web interfaces become easier for Windows
developers - Windows apps become .NET Web-based apps
28Data lt-gt XML, Everywhere
- All CLR data can be serialized to XML
- All XML can be expanded into CLR data
- Thus, anything can be shipped around on the Web
- Typing through XML Schema
- Pluggable Architecture
29XML Schema
- ltxsdcomplexType name"Person"gt
- ltxsdsequencegt
- ltxsdchoicegt
- ltxsdelement name"name"
type"xsdstring" - xsinillable"true" /gt
- ltxsdelement name"id"
type"xsdstring" /gt - lt/xsdchoicegt
- ltxsdany processContents"lax"/gt
- lt/xsdsequencegt
- lt/xsdcomplexTypegt
- ltxsdcomplexType name"AgedPerson"gt
- ltxsdcomplexContent mixed"false"gt
- ltxsdextension base"targetPerson"gt
- ltxsdchoicegt
- ltxsdelement name"age"
type"xsddouble" /gt - ltxsdelement name"timeOnEarth"
type"xsddouble" /gt - lt/xsdchoicegt
- lt/xsdextensiongt
- lt/xsdcomplexContentgt
30Example Instance
- ltnsdon
- xmlnsns"uuid048b2fa1-d557-473f-ba4c-
- acee78fe3f7d"
- gt
- ltnamegtDon Boxlt/namegt
- ltniceStuffForDon/gt
- lt/nsdongt
31Second Example Instance
- ltnsdon
- xmlnsns"uuid048b2fa1-d557-473f-ba4c-acee78f
e3f7d" - xmlnsxsi"http//www.w3.org/2001/XMLSchema-in
stance" - xsitype"nsAgedPerson"
- gt
- ltnamegtDon Boxlt/namegt
- ltniceStuffForDon/gt
- ltagegt26lt/agegt
- lt/nsdongt
32A Simpler Schema
- ltelement name"Book"gt
- ltcomplexTypegt
- ltelement name"author" type"xsdstring"/gt
- ltelement name"preface" type"xsdstring"/gt
- ltelement name"intro" type"xsdstring"/gt
- lt/complexTypegt
- lt/eBookgt
33Another Example Instance
- lteBookgt
- ltauthorgtHenry Fordlt/authorgt
- ltprefacegtPrefatory textlt/prefacegt
- ltintrogtThis is a book.lt/introgt
- lt/eBookgt
34XML Schema Defined Types
35Class Library Type Hierarchy
36Reading in XML Data
- XmlReader reader
- new XmlTextReader("http//foo.com/don.
xsd") - XmlSchema schema XmlSchema.Load(reader, null)
- schema.Compile(null) // turn xml into objects
- reader.Close()
37Serialized Classes
public class OrderForm public DateTime
OrderDate private int foo
ltOrderFormgt ltOrderDategt12/12/01lt/OrderDategt
lt/OrderFormgt
Note Only public instance data and properties
are serialized with XML.
38ALL Interprocess Communication via SOAP
- ALL Interprocess communication (across network or
on same machine) is through SOAP - Simple Object Access Protocol
- Its a way of exchanging data and even calling
other methods/threads, all via XML and plain old
HTTP requests
39SOAP 1.2
- SOAP is a lightweight protocol intended for
exchanging structured information in a
decentralized, distributed environment. SOAP uses
XML technologies to define an extensible
messaging framework, which provides a message
construct that can be exchanged over a variety of
underlying protocols. The framework has been
designed to be independent of any particular
programming model and other implementation
specific semantics.
40Example SOAP Request
- ltsoapEnvelope xmlnssoap"http//schemas.xmlsoap.
org/soap/envelope/"gt - ltsoapBodygt
- ltxTransferFunds xmlnsx"urnexamples-orgban
king"gt - ltfromgt22-342439lt/fromgt
- lttogt98-283843lt/togt
- ltamountgt100.00lt/amountgt
- lt/xTransferFundsgt
- lt/soapBodygt
- lt/soapEnvelopegt
41Example SOAP Response
ltsoapEnvelope xmlnssoap"http//schemas.xmlsoap.
org/soap/envelope/"gt ltsoapBodygt
ltxTransferFundsResponse xmlnsx"urnexamples-org
banking"gt ltbalancesgt
ltaccountgt ltidgt22-342439lt/idgt
ltbalancegt33.45lt/balancegt
lt/accountgt ltaccountgt
ltidgt98-283843lt/idgt
ltbalancegt932.73lt/balancegt
lt/accountgt lt/balancesgt
lt/xTransferFundsResponsegt lt/soapBodygt
lt/soapEnvelopegt
42Example SOAP Fault
ltsoapEnvelope xmlnssoap"http//schemas.xmlsoap.
org/soap/envelope/"gt ltsoapBodygt
ltsoapFaultgt ltfaultcodegtsoapServerlt/fau
ltcodegt ltfaultstringgtInsufficient
fundslt/faultstringgt ltdetailgt
ltxTransferError xmlnsx"urnexamples-orgbank
ing"gt ltsourceAccountgt22-34243
9lt/sourceAccountgt
lttransferAmountgt100.00lt/transferAmountgt
ltcurrentBalancegt89.23lt/currentBalancegt
lt/xTransferErrorgt
lt/detailgt lt/xTransferFundsgt
lt/soapBodygt lt/soapEnvelopegt
43Soap Request with Security
ltsoapEnvelope xmlnssoap"http//schemas.xmlsoap.
org/soap/envelope/"gt ltsoapBodygt
ltxTransferFunds xmlnsx"urnexamples-orgbanking
"gt ltfromgt22-342439lt/fromgt
lttogt98-283843lt/togt ltamountgt100.00lt/amountgt
lt!-- security credentials --gt
ltcredentialsgt ltusernamegtdavelt/usernamegt
ltpasswordgtevadlt/passwordgt
lt/credentialsgt lt/xTransferFundsgt
lt/soapBodygt lt/soapEnvelopegt
44MS .Net
45ASP.NET
- ASP gt Active Server Pages
- Put most of the computation in the server
- Very simple model to use
- ADO.NET is the database connection part
46Calling Web Services
- Any class can be converted into an XML Web
Service with just a few lines of code, and can be
called by any SOAP client.
47Take-away lessons
- VMs are important
- Even Microsoft thinks so
- Distributed apps are important, but to do so
requires standard protocols - Ways of serializing data (XML)
- Ways of doing RPC (SOAP)
- Design Decisions Good and Bad
48Limitations of the .NET Framework
- What if youre not on the network?
- Maybe thats not an issue?
- Mapping between XML and any object is hard
- Any object is controlled by compiler. XML can
be written by anybody with a text editor. - Theres a whole bunch of class support for
modified serializers and compilers
49J2EE versus Microsofts .NET
- J2EE has been around longer
- .NET released in 2002
- but Microsoft Transaction Server (MTS) and
Component Object Model (COM) are older - Dec 2001 survey shows 78 using J2EE
- 22 using .NET
- Microsoft claims better performance with Pet
Store example - but Sun says it isnt a fair comparison
- Microsoft used stored procedures
- Pet store is an example, not a speed test
50Next Time
- Extreme Programming (last lecture!)
- 12/2 Demo your project!
- 1 pt extra credit
- Send me email to sign up
- 12/4 Final Exam review
- Come prepared with questions