ions and Diif Between J2EE and NET
-
Upload
sriram-reddy-palamakula -
Category
Documents
-
view
225 -
download
0
Transcript of ions and Diif Between J2EE and NET
-
8/3/2019 ions and Diif Between J2EE and NET
1/98
Comparing J2EE with .NET
- ACCU 2002 -
Slides (mostly ) byMichael Stal, Senior Principal EngineerSIEMENS AG, Dept. CT SE 2E-Mail: mailto:[email protected]: http://www.stal.de
Markus Voelter, CTO, MATHEMA [email protected]
http://www.voelter.de
mailto:[email protected]://www.stal.de/mailto:[email protected]://www.voelter.de/http://www.voelter.de/mailto:[email protected]://www.stal.de/mailto:[email protected] -
8/3/2019 ions and Diif Between J2EE and NET
2/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 2
Goal
This is intended to be an objectivecomparisons of the two platforms
It will contain criteria to base a decisionwhich platform to use
Interoperability issues
-
8/3/2019 ions and Diif Between J2EE and NET
3/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 3
Agenda
Motivation
Comparison Visions: Sun ONE and .NET
Layer-by-Layer comparison of the infrastructures
Summary
Literature
-
8/3/2019 ions and Diif Between J2EE and NET
4/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 4
Web Frameworks
Workflow Engine
Web-based and -related Protocols (HTTP, SMTP, ...)
Service Description, Discovery, Integration (UDDI)
Service Description (WSDL)
Service Context (Who, Where, When, Why, ....)
Virtual Machine
Micro/Macro Services
IntegrationLayer
Legacy
Backend Server
MainframeFrontend
Layer
(Web Server)
Web Service User/Provider
Core Services (Calendar, Preferences, Transactions, ...)
Core elements of Web Frameworks
Clients
-
8/3/2019 ions and Diif Between J2EE and NET
5/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 5
.NET The MicrosoftWay of Life
.NET DevicesTabletPC, PocketPC, ....
.NET Servers
SQL Server, Biztalk, Commerce, Exchange, Mobile Information,
Host Integration, Application Center
.NET Foundation Services (Hailstorm)
Passport, Calendar, Directory & Search, Notification & Messaging,
Personalization, Web-Store/XML, Dynamic Delivery of Software and Services
Common Language Runtime
(Memory Management, Common Type System, Lifecycle Monitor)
.NET Framework & Tools
Base Classes
(ADO.NET, XML, Threading, IO, ....)
ASP.NET(Web Services, Web Forms,
ASP.NET Application
Services)
Windows Forms(Controls, Drawing,
Windows
Application Services)
-
8/3/2019 ions and Diif Between J2EE and NET
6/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 6
Sun ONE (Open NetEnvironment)
Service Interface
ServiceContainer
(J2EE, EJB, JSP,J2SE, J2ME,
MIDP, Java Card)
ProcessManagement
ServiceIntegration
(SQL, JDBC, XML,XSLT, XP, JMS,
RMI, J2EE Connectors,...)
Service PlatformSmart Management
(SNMP, CIM, WBEM, JMX)
Smart Delivery(XML, HTML, XHTML,
WML, VoiceXML,XSLT, HTTP, SSL,XP, SOAP, WSDL,UDDI, ebXML, ...)
Web Services
Smart Process(ebXML, XAML)
Smart Policy
(LDAP, Kerberos, PKI,OASIS Security))
Service Creation and Assembly(JB, JSP, EJB)
-
8/3/2019 ions and Diif Between J2EE and NET
7/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 7
Layer-By-Layer Comparison
-
8/3/2019 ions and Diif Between J2EE and NET
8/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 8
Hello World Example
In C# and Java:using System;
namespace MyNameSpace {public class MyClass {
public static void Main(String [] args) {Console.WriteLine(Hello, C#!);}
}}
package MyPackage;
public class MyClass {public static void main(String [] args) {
System.out.println(Hello, Java!);}
}
-
8/3/2019 ions and Diif Between J2EE and NET
9/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 9
Layers
Runtime System
Object model
Base classes
- Reflection, Enterprise
- Component model- Database access- XML- Server Pages- Remoting- Web Services- More Enterprise APIs
-
8/3/2019 ions and Diif Between J2EE and NET
10/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 10
The Runtime System
-
8/3/2019 ions and Diif Between J2EE and NET
11/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 11
.NET Runtime
It is called the Common Language Runtime (CLR) It is intended for any language compiled to the MSIL
Provides integration for several languages
Provides support for non-OO languages (e.g. tailrecursion)
C#
VB.NET
C++
Perl
Compiler
MSIL +
Metadata
Loader/
Verifier JIT
ManagedCode
Execution
GarbageCollection,Security,
Multithreading,...
-
8/3/2019 ions and Diif Between J2EE and NET
12/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 12
Java Virtual Machine
The JVM is intended for Java and interprets Java Byte Code. Other languages can be compiled to Java bytecode, however
(e.g. Ada)
Just-in-Time compilers exist for different environments andOSs
Java
C
ompiler
CLASS-Files
Classloader/Verifier JIT
NativeCode
Hotspot
InterpreterGarbage
Collection,Security ManagerCall-in+Call-out,Multithreading,
...
-
8/3/2019 ions and Diif Between J2EE and NET
13/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 13
Commonalities andDifferences
Commonalities: Basic concepts are similar
Differences:
Java is intended for interpretation (e.g. type-dependent primitives i_add, ...)
Java allows for custom class loaders and securitymanagers
.NET CLR provides a command set that alsosupports functional languages
-
8/3/2019 ions and Diif Between J2EE and NET
14/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 14
The Object Model
-
8/3/2019 ions and Diif Between J2EE and NET
15/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 15
Object Model (.NET)
In .NET, everything is an object
Types
Value Types Reference Types
System ValueTypes
User ValueTypes
Enumerations
InterfacesPointers
Self-describingTypes
ArraysClasses
Delegates Boxed Values
User-Defined
-
8/3/2019 ions and Diif Between J2EE and NET
16/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 16
System.Object
The mother of all .NET classes
public class Object {public virtual int GetHashCode();public virtual bool Equals();public virtual String ToString();public static bool Equals(object a, object b);public static bool ReferenceEquals(object a,
object b);
public Type GetType();protected object MemberWiseClone();protected virtual Finalize();
}
-
8/3/2019 ions and Diif Between J2EE and NET
17/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 17
Object Model (.NET)
.NET distinguishes between values typesand reference types: value types reside on the stack
reference types reside on the heap
In C#, there is no difference betweenprimitive types and classes Automatic boxing/unboxing provides transparency
Special strongly-typed functionreferences called delegates
and events)
-
8/3/2019 ions and Diif Between J2EE and NET
18/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 18
Object Model (Java)
Java has primitive types and classes. No automatic boxing/unboxing
Types
Primitive Types Reference Types
InterfacesArrays
Classes
-
8/3/2019 ions and Diif Between J2EE and NET
19/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 19
java.lang.Object
The Mother of all Java classes
public class Object {public Object();public boolean equals(Object obj);public final Class getClass();public int hashCode();public final void notify();public final void notifyAll();public String toString();public final void wait() throws InterruptedException;public final void wait(long timeout) throws
InterruptedException;public final void wait(long timeout, int nanos)
throws InterruptedException;protected Object clone() throws CloneNotSupportedException;protected void finalize() throws Throwable;}
-
8/3/2019 ions and Diif Between J2EE and NET
20/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 20
Object Model (Java)
Primitive types cannot be transparentlyused as an object. Special Holder classesare necessary.
There are no special function references.
Java uses Observer Pattern withcallback interfaces and inner classes
Integer i_ref = new Integer(7);List l = ...l.add( i_ref );
-
8/3/2019 ions and Diif Between J2EE and NET
21/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 21
.NET-Types that are notavailable in Java
Delegates & Events:
class MyClass {...public void somebodyTurnedOnTheLight( int which ) {
...}}
class AnotherClass {...public delegate void LightTurnedOn(int which);
public event LightTurnedOn OnLightTurnedOn;...OnLightTurnedOn+= new
LightTurnedOn(MyClass.somebodyTurnedOnTheLight);}
-
8/3/2019 ions and Diif Between J2EE and NET
22/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 22
.NET-Types that are notavailable in Java contd
Enumerations (value type):
Jagged and unjagged Arrays:
Structs (value types):
Structs are implicitly sealed they do not support inheritancepublic struct Name {
public String First;public String Last;
}
int [2][] a; a[0] = new int[]{1}; a[1] = new int[]{1,2};int [,] a = new int[2,2];
enum Color : byte { RED = 1, BLUE = 2, GREEN = 3 };
-
8/3/2019 ions and Diif Between J2EE and NET
23/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 23
Commonalities andDifferences
Commonalities: Interfaces are completely abstract classes Support single inheritance for classes (implementation
inheritance) and multiple interface inheritance Default-Initialization of Variables Namespace-Concept (Java-Package and .NET-Namespace) Similar visibility attributes (public, private, ...) Future: Generic types in .NET and Java (Generics) Class Constructors (static initializer in Java)
Differences In .NET there is no difference between primitive types and
classes. Multiple languages support in .NET In Java all methods are implicitly virtual. In .NET this has to
be made explicit virtual, override, new). Java maps packages to directories. .NET doesnt.
-
8/3/2019 ions and Diif Between J2EE and NET
24/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 24
Metainformation
Java and .NET provide a reflection API to load and instantiate classes
and inspect classes (introspection).
In addition, .NET allows to annotatemany aspects of a system (classes,members, operations) with so-called
Attributes
-
8/3/2019 ions and Diif Between J2EE and NET
25/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 25
.NET Examples
Using an Atttribute
There are several predefined attributes(WebService, WebMethod, ...)
Defining an Attribute
[AuthorIs(Michael)]class MyClass { ... }
[AttributeUsage(AttributeTargets.All)]public class AuthorIsAttribute : Attribute {private string m_Name;public AuthorIsAttribute(string name) { m_Name = name;}
}
-
8/3/2019 ions and Diif Between J2EE and NET
26/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 26
.NET Examples contd
Accessing and using Type informationusing System;using System.Reflection;
namespace ComponentClient {
class Client {static void Main(string[] args) {Assembly a = Assembly.LoadFrom("Component.dll");Type [] allTypes = a.GetTypes();Type t = allTypes[0];object o = Activator.CreateInstance(t);
MethodInfo mi = t.GetMethod("algorithm");double d = (double) mi.Invoke(o, new object[]{21.0});}
}}
-
8/3/2019 ions and Diif Between J2EE and NET
27/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 27
Java Example
Accessing and using Type information: Note that packages are not the same as
assemblies!!
import java.lang.reflect.*;
try {Class c = Class.forName(MyPrintComponent);Object o = c.newInstance();Method m = c.getMethod(print, new Class[]{ String.class });m.invoke(o, new Object[]{Hallo, Java!});
}catch (Exception e) {// handle it here
}
C li i d
-
8/3/2019 ions and Diif Between J2EE and NET
28/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 28
Commonalities andDifferences
Commonalities: Very similar APIs
Differences:
.NET allows additional, user-defined metainformation with attributes
Java Reflection is sometimes a bit more clumsy(because of primitive types and classes)
.NET allows to actually create new artifacts atruntime and instantiate them or store them inassemblies.
-
8/3/2019 ions and Diif Between J2EE and NET
29/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 29
Statements
Both platforms support basically thesame statements
Differences:
switch-Statement allows Strings, but nofallthrough:
string name = address.name;switch (name) {
case Maier: Console.WriteLine(Nice to meet you, Hans!);break;
case Mueller,case Huber: Console.WriteLine(You owe me some money!);
break;default: Console.WriteLine(I dont know you);
break;}
-
8/3/2019 ions and Diif Between J2EE and NET
30/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 30
Statements (contd)
Differences: Iterators in .NET:
Note that these are still no internal iterators as inSmalltalk, for example!
foreach (Elem i in MyContainer) { Console.WriteLine(i); }...
class MyContainer : IEnumerable, IEnumerator {public IEnumerator GetEnumerator() {
return (IEnumerator)this;}public void Reset() { ... }public bool MoveNext() { ... }
public object Current { get { ... } }}
-
8/3/2019 ions and Diif Between J2EE and NET
31/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 31
Statements (contd)
Differences: Iterators in Java:
for (Iterator i = MyContainer.iterator(); i.hasNext();)doSomething(i.next());
...class MyContainer implements Iterator {
public boolean hasNext() {}public Object next() {...}public void remove() {...}public Iterator iterator() { return this; }
}
-
8/3/2019 ions and Diif Between J2EE and NET
32/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 32
Statements (contd)
Differences: Properties in .NET, where Java uses Coding
conventions
Class MyClass { ...
public double x {set { if (x < 0)
throw new ArgumentException (< 0);m_x = value;
}
get { return m_x; }} ...
// User:MyClass m = new MyClass(); m.x = 22;
-
8/3/2019 ions and Diif Between J2EE and NET
33/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 33
Statements (contd)
Differences: .NET supports Indexers, Java does not.
Indexers also work with non-integer keys, such asstrings
object[17] = 22;
// In class:Int [] m_a;public double this[int pos] {
get { return m_a[pos]; }set { m_a[pos] = value; }
}
-
8/3/2019 ions and Diif Between J2EE and NET
34/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 34
Statements (contd)
Differences: .NET supports operator overloading!
public static Point operator+(Point op1, Point op2) {
return new Point(op1.x+op2.x,op1.y+op2.y);}
...
Point p = new Point(1,2) + new Point(2,3);
-
8/3/2019 ions and Diif Between J2EE and NET
35/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 35
Statements (contd)
Differences: .NET allows pass-by-reference of method
arguments
class Test {
public void Print(int i) { Console.WriteLine(i); }public void Inc(ref int i) { i++; }public int SetInitial(out int i) { i = 42; }...
}
Test t = ...; int i;t.SetInitial(out i);t.Inc(ref i);t.Print();
-
8/3/2019 ions and Diif Between J2EE and NET
36/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 36
Statements (contd)
Exceptions in Java Exceptions have to be declared in the throws-clause
Exceptions in .NET Exceptions are not declared
public int insert(int i) throws OverLimitException;{ }
// only way to tell you about// OverLimitException thrown belowpublic int insert(int i) { }
-
8/3/2019 ions and Diif Between J2EE and NET
37/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 37
Important Base Classes
.NET Java
GUI Windows.Forms
Web.Forms
SWING, AWT
Kommunikation System.Net:Connection,HttpWebRequest,...
Java.net: Sockets, URL,...
Container System.Collections:
ArrayList, BitArray,Maps, Queue, List,Stack
java.util: Lists, Maps,
Sets, Trees, Vectors
No big conceptual differences here.
-
8/3/2019 ions and Diif Between J2EE and NET
38/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 38
Multithreading
-
8/3/2019 ions and Diif Between J2EE and NET
39/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 39
Multithreading in .NET
.NET uses delegates for multithreading The ThreadStart in the example below
There are monitors for synchronization
The lock in the example belowclass GlobalData {
int m_Value;public int Value { set { lock(this) { m_Value = value; } } }
}class Worker {
GlobalData m_Global;public Worker(GlobalData global) {m_Global = global; }public void loop() { m_global.Value = 42; Thread.Sleep(100); }
}// somewhere else:GlobalData g = new GlobalData();
Thread t = new Thread(new ThreadStart(new Worker().loop));t.Start(); t.Join(); 1
-
8/3/2019 ions and Diif Between J2EE and NET
40/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 40
Multithreading in Java
In Java there is also a class Thread
For synchronization there is thesynchronizedkeyword
class GlobalData {int m_Value;public synchronized int setValue { return m_Value; }
}class Worker implements Runnable {
GlobalData m_Global;public Worker(GlobalData global) { m_Global = global; }public void run() { m_Global.setValue(42); Thread.sleep(100); }
}// somewhere else:GlobalData g = new GlobalData();
Thread t = new Thread(new Worker());t.start(); t.join(); 1
Commonalities and
-
8/3/2019 ions and Diif Between J2EE and NET
41/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 41
Commonalities andDifferences
Commonalities: Threading is very similar!
Both use some forms of monitor forsynchronization
Differences: In Java, synchronization is better integrated into
the Java language
Java provides better synchronization and threadcommunication (wait, notify, ...).
-
8/3/2019 ions and Diif Between J2EE and NET
42/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 42
Deployment
-
8/3/2019 ions and Diif Between J2EE and NET
43/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 43
Assemblies in .NET
Assembly=Set of Types
Manifest
Module 1
Resources
Type 1IL-Code
Type 2IL-Code
Type 3IL-Code
name
version
Sharedname
Hash
Files
ReferencedAssemblies
Types
Security
CustomAttributes ProductInformation
Metadata
-
8/3/2019 ions and Diif Between J2EE and NET
44/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 44
Assemblies in .NET
Private Assemblies are typically onlyuseful by the owning application
Shared Assemblies are stored in a
common cache and can be used byseveral applications. They are signed by a key
They are versioned!!
Runtime uses Application Domains as anabstraction for (potentially remote)processes.
-
8/3/2019 ions and Diif Between J2EE and NET
45/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 45
Java JAR files
.jar files are similar to .NETs assemblies They can be shared or private
They can be signed
They contain types
resources
optionally, metadata in manifest files.
There is no versioning!
Commonalities and
-
8/3/2019 ions and Diif Between J2EE and NET
46/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 46
Commonalities andDifferences
Commonalities: Assemblies and JAR files provide deployment
components
Differences: Much better versioning support in .NET (side-by-
side execution)
-
8/3/2019 ions and Diif Between J2EE and NET
47/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 47
Component Models
Server-Side Components in
-
8/3/2019 ions and Diif Between J2EE and NET
48/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 48
Server-Side Components in.NET
Now Componentis used like in EJB/COM+
To use container-provided services like
synchronisation or transactions COM+services can be used
COM+-Interop provides these features.
-
8/3/2019 ions and Diif Between J2EE and NET
49/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 49
Java Component Models
Client Components and ServerComponents
JavaBeans are Client Components
normal Java classes following some conventions optionally providing metainformation (BeanInfo
class)
public class MyJavaBean {private int color;
public void setColor(int v) { color = v; }public int getColor() { return color; }// a lot of more ...
}
// BeanInfo class not shown here!
-
8/3/2019 ions and Diif Between J2EE and NET
50/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 50
Server Components in Java
Enterprise JavaBeans (EJBs) alwaysreside in a Container that providestechnical aspects (sep. of concerns)
Client
3) Use bean
Naming
Service
1) lookup home
JNDI
4) remove
Application Server (Container)
Remote Bean
Interface
Remote Bean
Home Interface
2) find bean
2) create bean
BeanInstance
EnterpriseBean
EJBContext
4
ejbCreateejb...
DeploymentDescriptor
EJBJar
bean-methods
EJBHome
EJBObject
new
EJB Run-time
Server Components in Java
-
8/3/2019 ions and Diif Between J2EE and NET
51/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 51
Server Components in Javacontd
4 Types of Beans Stateless Session-Beans (Service Components)
Stateful Session Beans (Session Components)
Entity-Beans (Entity Components)
Message-Driven Beans (asynch. ServiceComponents)
A bean is (theoretically) portable acrosscontainers (Application Servers) fromdifferent vendors.
Commonalities and
-
8/3/2019 ions and Diif Between J2EE and NET
52/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 52
Commonalities andDifferences
Commonalities: Server Components are available (Assemblies +
COM+, EJB).
Interop with legacy components in .NET using
COM+, in Java using CORBA)
Differences: EJB are a more mature and proven model
Special APIs to connect to legacy systems (JavaConnector API)
-
8/3/2019 ions and Diif Between J2EE and NET
53/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 53
Database Access in .NET
In .NET there is ADO.NET connectionless
Data Source
DataSetCommandCommand
Connection
DataReader
DataSet
Client
Managed Provider
i i l
-
8/3/2019 ions and Diif Between J2EE and NET
54/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 54
.NET-Beispiel
using System;using System.Data;using System.Data.SqlClient;
string myConnection =
server=myserver;uid=sa;pwd=;database=StockTickerDB;string myCommand = SELECT * from StockTable;SqlDataSetCommand datasetCommand = new
SqlDataSetCommand(myCommand, myConnection);DataSet myDataSet = new DataSet();datasetCommand.FillDataSet(myDataSet, StockTable);
DataTable myTable =ds.Tables[StockTable];foreach (DataRow row in myTable.Rows) {
Console.WriteLine(Value of {0} is {1},row[LongName], row[Value]);
}
O
-
8/3/2019 ions and Diif Between J2EE and NET
55/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 55
ADO.NET
ADO.NET is XML based (XML Infoset) DataSet dynamically builds an XML schema inside
to store the data Relational data and XML data can be handled in a
similar way!!ADO.NET works offline once the data is
fetched Updating is partly automatic using DataSets
Currently there are two ManagedProviders: SQL Server ADO
D b A i J
-
8/3/2019 ions and Diif Between J2EE and NET
56/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 56
Database Access in Java
Java provides JDBC to access relationaldata
ODBCDB
ODBC Driver
JDBC/
ODBC Bridge
Driver ManagerConnection
Statement
PreparedStatement
Callable
Statement
Resultset
Application
J E l
-
8/3/2019 ions and Diif Between J2EE and NET
57/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 57
Java Example
import java.sql.*;// without error handling:Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);Connection
con=DriverManager.getConnection(jdbc:odbc:stocks,,);
Statement stmt = con.CreateStatement();ResultSet rs = stmt.executeQuery(SELECT * from stocks);while (rs.next()) {
System.out.println(rs.getString(COMPANYNAME));}rs.close();
stmt.close();con.close();
D t b A i J
-
8/3/2019 ions and Diif Between J2EE and NET
58/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 58
Database Access in Java
There are several other APIs: Embedded SQL in the form of SQLJ (uses JDBC
internally)
Proprietary ODBMS APIs
Standardized JDO API to provide (more or lesstransparent) persistence for Java Objects
XML is handled differently!
Java Connector API provides access to other
connection oriented legacy systems (such as SAPR3)
Commonalities and
-
8/3/2019 ions and Diif Between J2EE and NET
59/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 59
Commonalities andDifferences
Commonalities: Decoupling of the concrete data model and the
user (using DataSets and ResultSets)
Differences: ADO.NET uses XML extensively, JDBC has a more
relational flavor
JDBC is connection oriented, ADO.NET alwaysworks non-connected, or offline
.NET DataSets are a kind of In-Memory-Database-Cache.
XML
-
8/3/2019 ions and Diif Between J2EE and NET
60/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 60
XML
XML d NET
-
8/3/2019 ions and Diif Between J2EE and NET
61/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 61
XML and .NET
.NET is very XML-centric Web Services (SOAP)
Configuration Files
Result sets of a database access (ADO.NET)
XML processing itself
Note that formally, many .NET features
are based on the XML infoset (XMLsemantics) and do not necessarilyrequire megabytes of text data!!
XML d NET td
-
8/3/2019 ions and Diif Between J2EE and NET
62/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 62
XML and .NET contd
The System.Xml Namespace provides awhole lot of classes DOM processing using XmlNode & Sons
XPath and XslTransform
XmlTextReader und XmlTextWriter similar toSAX in that they are both stream-based, but .NETuses a Pull-Model
XML d J
-
8/3/2019 ions and Diif Between J2EE and NET
63/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 63
XML und Java
There are several standards and tools available DOM, SAX Xerces/Xalan, JDOM JAX{M,B,R,RPC} Castor
However, Javas libraries have not been designedwith XML as a basis (Javas too old ) JAXP (Java API for XML Parsing) supports DOM
and SAX.
Currently under development JAXM (Java API for XML Messaging) JAXB (Java API for XML Data Binding) JAXR (Java API for XML Registries) JAX/RPC (Java API for XML based RPC)
R ti
-
8/3/2019 ions and Diif Between J2EE and NET
64/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 64
Remoting
Somebody knows anice picture here?
R ti i NET
-
8/3/2019 ions and Diif Between J2EE and NET
65/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 65
Remoting in .NET
Application Domain B
Client
FormattersChannels
Envoy Sinks
Real Proxy
Transparent Proxy
Servant
FormattersChannels
Server Context Sinks
Object Context Sinks
Network
Application Domain A
R ti i NET ( td)
-
8/3/2019 ions and Diif Between J2EE and NET
66/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 66
Remoting in .NET (contd)
.NET Remoting provides pluggabletransports and formatters currently TCP and HTTP transport and binary and SOAP formatters
Contexts are automatically propagated(very neat feature!!)
Only very simple lifecycle managementoptions for servants (compared to EJB or
CORBA) Singleton (one object for all calls) SingleCall (new instance for each call) Client-Activated based on leases
Remoting in NET (contd)
-
8/3/2019 ions and Diif Between J2EE and NET
67/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 67
Remoting in .NET (contd)
Objects can be marshalled by value(Serializable)
Asynchronous invocations are easilypossible without touching the servant
Remoting in Java
-
8/3/2019 ions and Diif Between J2EE and NET
68/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 68
Stub/Skeleton-Layer
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 Server
Stub Skeleton
Remote Reference Manager
Transport Layer
Commonalities and
-
8/3/2019 ions and Diif Between J2EE and NET
69/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 69
Commonalities andDifferences
Commonalities: Relatively easy to use
Unterschiede:
.NET Remoting can be extended more flexibly Java provides Interop with CORBA
Asynchronous invocations are not easily possiblewith Java
Web
-
8/3/2019 ions and Diif Between J2EE and NET
70/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 70
Web
ASP.NET
-
8/3/2019 ions and Diif Between J2EE and NET
71/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 71
(Server-Side Scripting)
ASP.NET Architecture:
IIS 5Web
Server
Client
(1) get a.apx (2) process
.NETEngine
.NETAssembly
OtherAssemblies
Database
(3) result(4) HTTP file
ASP NET Example
-
8/3/2019 ions and Diif Between J2EE and NET
72/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 72
ASP.NET Example
A simple loginscreen:
ASP NET Example (contd)
-
8/3/2019 ions and Diif Between J2EE and NET
73/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 73
ASP.NET Example (cont d)
Please specify your name andpassword
Login
Password
ASP NET Example (contd)
-
8/3/2019 ions and Diif Between J2EE and NET
74/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 74
ASP.NET Example (cont d)// lot of details omittednamespace LoginPage {
public class WebForm1 : System.Web.UI.Page {protected TextBox PasswordText, LoginText;protected Button EnterButton;protected Label MessageLabel;private void InitializeComponent() {
this.EnterButton.Click +=new System.EventHandler(this.EnterButton_Click);this.Load += new System.EventHandler(this.Page_Load);
}private void EnterButton_Click(object sender, System.EventArgs e) {
if (!(LoginText.Text.Equals("aladdin") &&PasswordText.Text.Equals("sesam"))) {
MessageLabel.Text = " Wrong name or password!";
}else {Session["user"] = "aladdin";Response.Redirect("UserArea.aspx");
}}
}}
Java Server Pages and
-
8/3/2019 ions and Diif Between J2EE and NET
75/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 75
gServlets
Java also allows for server-side scripting JSPs are based on Servlets
Web
ServerClient
(1) get a.jsp (2) process
JVM
JSP
OtherComponents
Database
(4) result
(5) HTTP file
Servlet
(3) gen. Servlet ServletImpl.
Java Example
-
8/3/2019 ions and Diif Between J2EE and NET
76/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 76
Java Example
Java Example
-
8/3/2019 ions and Diif Between J2EE and NET
77/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 77
Java Example
Bean und JSP-Seite:
// Datei MyPerson.javapackage MyPackage;import java.lang.*;
public class MyPerson {public String getFirstName() { return "Michael"; }public String getLastName() { return "Stal"; }
}// Datei MyTest.jsp: Your name is:
Commonalities and
-
8/3/2019 ions and Diif Between J2EE and NET
78/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 78
Differences
Commonalities: Pages are precompiled to accelerate access Similar syntax and concepts ASP.NET provides GUI components using
Webcontrols, Java provides Taglibs. Differences:
All .NET languages can be used for ASP.NETscripting
Servlets/JSP are available for a wide range ofwebservers
Many open source implementations, frameworksand tools for Java
Web Services in NET
-
8/3/2019 ions and Diif Between J2EE and NET
79/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 79
Web Services in .NET
.NET provides a very comfortable andwell-integrated way to build them:
namespace WebService1 {public class Service1 : System.Web.Services.WebService {
// lot of stuff omitted[WebMethod]public double DM_to_Euro(double value) {
return value / 1.95583;}[WebMethod]
public double Euro_to_DM(double value) {return value * 1.95583;
}}
}
Web Services in NET (forts )
-
8/3/2019 ions and Diif Between J2EE and NET
80/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 80
Web Services in .NET (forts.)
Using it is also simple Some steps have been ommitted
Webservices are just a special way ofremoting
BUT: Microsoft does not provide ebXML compliance Currently they can only be used with MS server
localhost.Service1 s1 = new localhost.Service1();double result = s1.Euro_to_DM(200);
Web Services in Java
-
8/3/2019 ions and Diif Between J2EE and NET
81/98
Markus Voelter/Michael Stal
Comparing J2EE with .NETFolie 81
Web Services in Java
Sun ONE will provide a Web Service API forJava, completely ebXML compliant
Currently there are many proprietary solutions Some specific SOAP toolkits:
- Apache SOAP
- IBM Web Services Toolkit- GLUE
Some integrated with the major application servers- Silverstream- IONA - Weblogic- ...
Sun works at standard APIs JAXM
Commonalities and
-
8/3/2019 ions and Diif Between J2EE and NET
82/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 82
Differences
Commonalities: Both.NET and Java try to be standards-compliant
(SOAP, WSDL, UDDI).
Handling very similar: WSDLbased generators that
create proxies Differences:
For Java there are different solutions, whereas.NET provides only one, natively
Currently, standards are interpreted differently, soInterop Java-.NET is only limited. But this willhopefully change!!
More Enterprise APIs
-
8/3/2019 ions and Diif Between J2EE and NET
83/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 83
More Enterprise APIs
Enterprise APIs
-
8/3/2019 ions and Diif Between J2EE and NET
84/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 84
Enterprise APIs
Naming: JNDI in Java (as an interface to CORBANaming,
LDAP, ...)
Active Directory in .NET (Windows-specific)
Message-orientierte Middleware: JMS in Java
JAXM is on the horizon (XML based messaging)
.NET can use MSMQ, and remoting can be usedasynchronously
Legacy-Integration
-
8/3/2019 ions and Diif Between J2EE and NET
85/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 85
Legacy-Integration
In .NET using the Microsoft HostIntegration Server.
In Java using the Connector API
Comparison: Java provides a muchsimpler way. Connectors can beimplemented relatively straight forward.
Interoperability
-
8/3/2019 ions and Diif Between J2EE and NET
86/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 86
Interoperability
Java provides access to C/C++ usingJNI (Java Native Interface). Relativelycomplex call-in, call-out.
.NET provides PInvoke:
class PInvokeTest {
[DllImport("user32.dll")]static extern int MessageBoxA(int hWnd, string m, string c, int t);static void Main(string[] args) {
MessageBoxA(0, "Hello DLL", "My Window", 0);}}
Interoperability contd
-
8/3/2019 ions and Diif Between J2EE and NET
87/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 87
Interoperability cont d
In .NET there is a way to interop withCOM+ and COM+ Services.
Java provides CORBA interop
JMS provides integration with MoMs In .NET, the interop between .NET
languages is almost perfect and easy Use the same assemblies, class libraries
Languages had to be adapted a little bit (e.g.Managed C++ does not provide multipleinheritance)
Mobile and Embedded
-
8/3/2019 ions and Diif Between J2EE and NET
88/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 88
Mobile and Embedded
Profiles and devices
-
8/3/2019 ions and Diif Between J2EE and NET
89/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 89
Profiles and devices
There are the following variants of Java J2SE (Java 2 Platform Standard Edition)
J2EE (Java 2 Platform Enterprise Edition)
J2ME (Java 2 Platform Micro Edition)
- Configurations,
- and Profiles
JavaCard
Profiles and devices contd
-
8/3/2019 ions and Diif Between J2EE and NET
90/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 90
Profiles and devices cont d
.NET Universe .NET: Framework for Standard und Enterprise .NET Compact Framework for Windows CE (and other
embedded OS)
- Design Goals:
> Resource saving> Adaptability regarding device properties> Compatibility with the standard IDEs> Easy integration> Seamless connectivity
- No ASP.NET, Reflection.Emit, Optimized JIT- Depending on machine stack- Simplified versioning and security, but
similar formats
Profiles and devices contd
-
8/3/2019 ions and Diif Between J2EE and NET
91/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 91
Profiles and devices cont d
.NET Mobile Web SDK Abstraction for the developer
Several markup languages (WML, HTML, ...)
Configurable and extendible
ASP.NET can be used
Emulators for devices are available for testing anddebugging purposes
Extends ASP.NET with special controls
Selecting one of the two
-
8/3/2019 ions and Diif Between J2EE and NET
92/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 92
Selecting one of the two
.NET and/or Java ?
-
8/3/2019 ions and Diif Between J2EE and NET
93/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 93
.NET and/or Java ?
.NET is a product, Java and J2EE is aspecification
Both adress the web (among other things)
For real big systems J2EE is better suited
The rule-of-thumb Java is platform-independent,.NET is language independentmust be considered carefully:
ECMA works on the standardization of C# and parts of .NET Other languages can be compiled to the JVM
.NET and/or Java ?
-
8/3/2019 ions and Diif Between J2EE and NET
94/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 94
.NET and/or Java ?
.NET language independence is not for free andnot completely transparent
In a real project you might want to use onlyonelanguage But sometimes...
#pragma onceusing namespace System; // .NET mit C++namespace CPPBase {
public __gc class CPPBaseClass {public: virtual System::String __gc* Echo(System::String __gc *s);};}System::String __gc * CPPBase::CPPBaseClass::Echo(System::String __gc *s){ return s; }
.NET and/or Java ?
-
8/3/2019 ions and Diif Between J2EE and NET
95/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 95
.NET and/or Java ?
Windows Applications are probably better donewith .NET than Java (maybe IBMs SWT changesthis ?)
Java should be used when platform (or vendor-) independence is necessary
Java is more mature
There will also be Java for .NET (Rational) But syntax is not the issue!
Both can be used for web services - .NET is
nicer, J2EE is more scalable
Analysts proclaim a fifty/fifty situation for Javaand .NET
Management Summary - 1
-
8/3/2019 ions and Diif Between J2EE and NET
96/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 96
Management Summary 1
.NET JavaController/Owner Microsoft Sun + JCP-Partner
Status Product Line Specification and manyimplementations
Languages C#, C++, Eiffel#, VB, .... Java + possibly others
Communicationmiddleware (RPC,Messaging, Web)
.NET Remoting, MSMQ,Web Services (no ebXML)
RMI/CORBA, JMS, WebServices (standardcompliant)
Server Components COM+ Enterprise JavaBeans
XML-Support Consistent Currently not yetcompletely integrated
Server Pages ASP.NET JSP/Servlets
Management Summary - 2
-
8/3/2019 ions and Diif Between J2EE and NET
97/98
Markus Voelter/Michael Stal Comparing J2EE with .NETFolie 97
Management Summary 2
.NET JavaDatabase access ADO.NET (ADO) JDBC / SQLJ and others
Base libraries Many many classes onSystem.*
Many many classes onjava.*
GUI-Libs Windows.FormsWeb.Forms
Swing/AWT
Runtime .NET CLR Java JVM
Interop (call-in/call-out) PInvoke JNI
InteropMiddleware COM/COM+ (COMInterop)
CORBA, JMS
Legacy Integration Host Integration Server JCA
The End
-
8/3/2019 ions and Diif Between J2EE and NET
98/98
The End
Thank you very much!!