Comparing J2EE with.NET - ACCU 2002 - Slides (mostly ) by Michael Stal, Senior Principal Engineer SIEMENS AG, Dept. CT SE 2

Slides:



Advertisements
Similar presentations
Números.
Advertisements

Trend for Precision Soil Testing % Zone or Grid Samples Tested compared to Total Samples.
Trend for Precision Soil Testing % Zone or Grid Samples Tested compared to Total Samples.
AGVISE Laboratories %Zone or Grid Samples – Northwood laboratory
Trend for Precision Soil Testing % Zone or Grid Samples Tested compared to Total Samples.
PDAs Accept Context-Free Languages
ALAK ROY. Assistant Professor Dept. of CSE NIT Agartala
EuroCondens SGB E.
Worksheets.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 12 Introduction to ASP.NET.
Copyright © 2013 Elsevier Inc. All rights reserved.
Addition and Subtraction Equations
Communicating in J2EE.
21 Copyright © 2005, Oracle. All rights reserved. Oracle Application Server 10g Transaction Support.
18 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Introduction to Web Services.
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
J2EE Overview.
Add Governors Discretionary (1G) Grants Chapter 6.
CALENDAR.
CHAPTER 18 The Ankle and Lower Leg
Connecting to Databases. connecting to DB DB server typically a standalone application Server runs on localhost for smaller sites –i.e. Same machine as.
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
The 5S numbers game..
突破信息检索壁垒 -SciFinder Scholar 介绍
A Fractional Order (Proportional and Derivative) Motion Controller Design for A Class of Second-order Systems Center for Self-Organizing Intelligent.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Welcome. © 2008 ADP, Inc. 2 Overview A Look at the Web Site Question and Answer Session Agenda.
The basics for simulations
Figure 3–1 Standard logic symbols for the inverter (ANSI/IEEE Std
J2EE Architecture Overview
Dynamic Access Control the file server, reimagined Presented by Mark on twitter 1 contents copyright 2013 Mark Minasi.
Microsoft.NET Object Oriented Software Engineering Based on a presentation by Murat Can Ganiz.
Copyright © [2002]. Roger L. Costello. All Rights Reserved. 1 XML Schemas Reference Manual Roger L. Costello XML Technologies Course.
Progressive Aerobic Cardiovascular Endurance Run
31242/32549 Advanced Internet Programming Advanced Java Programming
FAFSA on the Web Preview Presentation December 2013.
MaK_Full ahead loaded 1 Alarm Page Directory (F11)
Facebook Pages 101: Your Organization’s Foothold on the Social Web A Volunteer Leader Webinar Sponsored by CACO December 1, 2010 Andrew Gossen, Senior.
Executional Architecture
2011 WINNISQUAM COMMUNITY SURVEY YOUTH RISK BEHAVIOR GRADES 9-12 STUDENTS=1021.
Before Between After.
2011 FRANKLIN COMMUNITY SURVEY YOUTH RISK BEHAVIOR GRADES 9-12 STUDENTS=332.
ST/PRM3-EU | | © Robert Bosch GmbH reserves all rights even in the event of industrial property rights. We reserve all rights of disposal such as copying.
Subtraction: Adding UP
Presentation 7 part 2: SOAP & WSDL.
Numeracy Resources for KS2
1 Non Deterministic Automata. 2 Alphabet = Nondeterministic Finite Accepter (NFA)
2.4 Bases de Dados Estudo de Caso. Caso: Caixa Eletrônico Caixa Eletrônico com acesso à Base de Dados; Cada cliente possui:  Um número de cliente  Uma.
Static Equilibrium; Elasticity and Fracture
Resistência dos Materiais, 5ª ed.
1 © 2004, Cisco Systems, Inc. All rights reserved. CCNA 1 v3.1 Module 9 TCP/IP Protocol Suite and IP Addressing.
Lial/Hungerford/Holcomb/Mullins: Mathematics with Applications 11e Finite Mathematics with Applications 11e Copyright ©2015 Pearson Education, Inc. All.
A Data Warehouse Mining Tool Stephen Turner Chris Frala
1 Non Deterministic Automata. 2 Alphabet = Nondeterministic Finite Accepter (NFA)
Introduction Embedded Universal Tools and Online Features 2.
Schutzvermerk nach DIN 34 beachten 05/04/15 Seite 1 Training EPAM and CANopen Basic Solution: Password * * Level 1 Level 2 * Level 3 Password2 IP-Adr.
An architecture for webb applications, J2EE
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB JavaForum.
J2EE vs..NET Nigam Patel. Topics Background –Web Services, J2EE and.NET Similarities Differences Conclusion –Pros and Con (J2EE and.NET)
Intro to dot Net Dr. John Abraham UTPA – Fall 09 CSCI 3327.
第十四章 J2EE 入门 Introduction What is J2EE ?
Enterprise Java v120131Intro to JavaEE1 Java EE 5 TM Introduction.
.Net – The First Glance What Is.Net, Why Use.Net.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Presentation transcript:

Comparing J2EE with.NET - ACCU Slides (mostly ) by Michael Stal, Senior Principal Engineer SIEMENS AG, Dept. CT SE 2 Web: Markus Voelter, CTO, MATHEMA AG

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 2 Goal  This is intended to be an objective comparisons of the two platforms  It will contain criteria to base a decision which platform to use  Interoperability issues

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 3 Agenda  Motivation  Comparison Visions: Sun ONE and.NETVisions: Sun ONE and.NET Layer-by-Layer comparison of the infrastructuresLayer-by-Layer comparison of the infrastructures  Summary  Literature

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 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 Integration Layer Legacy Backend Server Mainframe Frontend Layer (Web Server) Web Service User/Provider Core Services (Calendar, Preferences, Transactions,...) Core elements of Web Frameworks Clients

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 5.NET – The Microsoft Way of Life.NET Devices TabletPC, 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)

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 6 Sun ONE (Open Net Environment) Service Interface Service Container (J2EE, EJB, JSP, J2SE, J2ME, MIDP, Java Card) Process Management Service Integration (SQL, JDBC, XML, XSLT, XP, JMS, RMI, J2EE Connectors,...) Service Platform Smart 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)

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 7 Layer-By-Layer Comparison

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 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!“); }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 9 Layers  Runtime System  Object model  Base classes -Reflection,  Enterprise -Component model -Database access -XML -Server Pages -Remoting -Web Services -More Enterprise APIs

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 10 The Runtime System

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 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. tail recursion) C# VB.NET C++ Perl Compiler MSIL + Metadata Loader/ Verifier JIT Managed Code Execution Garbage Collection, Security, Multithreading,...

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 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 and OSs Java Compiler CLASS- Files Classloader/ Verifier JIT Native Code Hotspot Interpreter Garbage Collection, Security Manager Call-in+Call-out, Multithreading,...

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 13 Commonalities and Differences  Commonalities: Basic concepts are similarBasic concepts are similar  Differences: Java is intended for interpretation (e.g. type- dependent primitives i_add,...)Java is intended for interpretation (e.g. type- dependent primitives i_add,...) Java allows for custom class loaders and security managersJava allows for custom class loaders and security managers.NET CLR provides a command set that also supports functional languages.NET CLR provides a command set that also supports functional languages

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 14 The Object Model

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 15 Object Model (.NET)  In.NET, everything is an object Types Value TypesReference Types System Value Types User Value Types Enumerations InterfacesPointers Self-describing Types ArraysClasses DelegatesBoxed Values User-Defined

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 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()´; }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 17 Object Model (.NET) .NET distinguishes between values types and reference types: value types reside on the stackvalue types reside on the stack reference types reside on the heapreference types reside on the heap  In C#, there is no difference between primitive types and classes Automatic boxing/unboxing provides transparencyAutomatic boxing/unboxing provides transparency  Special strongly-typed function references called delegatescalled delegates and events)and events)

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 18 Object Model (Java)  Java has primitive types and classes. No automatic boxing/unboxingNo automatic boxing/unboxing Types Primitive TypesReference Types InterfacesArrays Classes

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 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; }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 20 Object Model (Java)  Primitive types cannot be transparently used as an object. Special Holder classes are necessary.  There are no special function references. Java uses Observer Pattern with callback interfaces and inner classes Integer i_ref = new Integer(7); List l =... l.add( i_ref );

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 21.NET-Types that are not available 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); }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 22.NET-Types that are not available in Java cont‘d  Enumerations (value type):  Jagged and unjagged Arrays:  Structs (value types): Structs are implicitly sealedStructs are implicitly sealed they do not support inheritancethey do not support inheritance public 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 };

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 23 Commonalities and Differences  Commonalities: Interfaces are „completely abstract classes“Interfaces are „completely abstract classes“ Support single inheritance for classes (implementation inheritance) and multiple interface inheritanceSupport single inheritance for classes (implementation inheritance) and multiple interface inheritance Default-Initialization of VariablesDefault-Initialization of Variables Namespace-Concept (Java-Package and.NET-Namespace)Namespace-Concept (Java-Package and.NET-Namespace) Similar visibility attributes (public, private,...)Similar visibility attributes (public, private,...) Future: Generic types in.NET and Java (Generics)Future: Generic types in.NET and Java (Generics) Class Constructors (static initializer in Java)Class Constructors (static initializer in Java)  Differences In.NET there is no difference between primitive types and classes.In.NET there is no difference between primitive types and classes. Multiple languages support in.NETMultiple languages support in.NET In Java all methods are implicitly virtual. In.NET this has to be made explicit virtual, override, new).In Java all methods are implicitly virtual. In.NET this has to be made explicit virtual, override, new). Java maps packages to directories..NET doesn‘t.Java maps packages to directories..NET doesn‘t.

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 24 Metainformation  Java and.NET provide a reflection API to load and instantiate classesto load and instantiate classes and inspect classes (introspection).and inspect classes (introspection).  In addition,.NET allows to annotate many aspects of a system (classes, members, operations) with so-called Attributes

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 25.NET Examples  Using an Atttribute There are several predefined attributes (WebService, WebMethod,...)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;} }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 26.NET Examples cont‘d  Accessing and using Type information using 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}); }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 27 Java Example  Accessing and using Type information: Note that packages are not the same as assemblies!!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 }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 28 Commonalities and Differences  Commonalities: Very similar APIsVery similar APIs  Differences:.NET allows additional, user-defined meta information with attributes.NET allows additional, user-defined meta information with attributes Java Reflection is sometimes a bit more clumsy (because of primitive types and classes)Java Reflection is sometimes a bit more clumsy (because of primitive types and classes).NET allows to actually create new artifacts at runtime and instantiate them or store them in assemblies..NET allows to actually create new artifacts at runtime and instantiate them or store them in assemblies.

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 29 Statements  Both platforms support basically the same statements  Differences: switch -Statement allows Strings, but no fallthrough:switch -Statement allows Strings, but no fallthrough: 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 don’t know you”); break; }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 30 Statements (cont‘d)  Differences: Iterators in.NET:Iterators in.NET: Note that these are still no „internal iterators“ as in Smalltalk, for example!Note that these are still no „internal iterators“ as in Smalltalk, 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 {... } } }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 31 Statements (cont‘d)  Differences: Iterators in Java: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; } }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 32 Statements (cont‘d)  Differences: Properties in.NET, where Java uses Coding conventionsProperties 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;

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 33 Statements (cont‘d)  Differences:.NET supports Indexers, Java does not..NET supports Indexers, Java does not. Indexers also work with non-integer keys, such as stringsIndexers also work with non-integer keys, such as strings object[17] = 22; // In class: Int [] m_a; public double this[int pos] { get { return m_a[pos]; } set { m_a[pos] = value; } }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 34 Statements (cont‘d)  Differences:.NET supports operator overloading!.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);

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 35 Statements (cont‘d)  Differences:.NET allows pass-by-reference of method arguments.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();

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 36 Statements (cont‘d)  Exceptions in Java Exceptions have to be declared in the throws-clauseExceptions have to be declared in the throws-clause  Exceptions in.NET Exceptions are not declaredExceptions are not declared public int insert(int i) throws OverLimitException; { … } // only way to tell you about // OverLimitException thrown below public int insert(int i) { … }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 37 Important Base Classes.NETJava GUIWindows.Forms Web.Forms SWING, AWT KommunikationSystem.Net: Connection, HttpWebRequest,... Java.net: Sockets, URL,... ContainerSystem.Collections: ArrayList, BitArray, Maps, Queue, List, Stack java.util: Lists, Maps, Sets, Trees, Vectors No big conceptual differences here.

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 38 Multithreading

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 39 Multithreading in.NET .NET uses delegates for multithreading The „ThreadStart“ in the example belowThe „ThreadStart“ in the example below  There are monitors for synchronization The “lock” in the example belowThe “lock” in the example below class 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

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 40 Multithreading in Java  In Java there is also a class „Thread“  For synchronization there is the synchronized keyword 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

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 41 Commonalities and Differences  Commonalities: Threading is very similar!Threading is very similar! Both use some forms of monitor for synchronizationBoth use some forms of monitor for synchronization  Differences: In Java, synchronization is better integrated into the Java languageIn Java, synchronization is better integrated into the Java language Java provides better synchronization and thread communication (wait, notify,...).Java provides better synchronization and thread communication (wait, notify,...).

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 42 Deployment

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 43 Assemblies in.NET  Assembly=Set of Types Manifest Module 1 Resources Type 1 IL-Code Type 2 IL-Code Type 3 IL-Code name version Sharedname Hash Files Referenced Assemblies Types Security Custom Attributes Product Information Metadata

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 44 Assemblies in.NET  Private Assemblies are typically only useful by the owning application  Shared Assemblies are stored in a common cache and can be used by several applications. They are signed by a keyThey are signed by a key They are versioned!!They are versioned!!  Runtime uses Application Domains as an abstraction for (potentially remote) processes.

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 45 Java JAR files .jar files are similar to.NET‘s assemblies They can be shared or privateThey can be shared or private They can be signedThey can be signed  They contain typestypes resourcesresources optionally, metadata in manifest files.optionally, metadata in manifest files.  There is no versioning!

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 46 Commonalities and Differences  Commonalities: Assemblies and JAR files provide „deployment“ componentsAssemblies and JAR files provide „deployment“ components  Differences: Much better versioning support in.NET (side-by- side execution)Much better versioning support in.NET (side-by- side execution)

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 47 Component Models

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 48 Server-Side Components in.NET  Now Component is used like in EJB/COM+  To use container-provided services like synchronisation or transactions COM+ services can be used  COM+-Interop provides these features.

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 49 Java Component Models  Client Components and Server Components  JavaBeans are Client Components normal Java classes following some conventionsnormal Java classes following some conventions optionally providing metainformation (BeanInfo class)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!

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 50 Server Components in Java  Enterprise JavaBeans (EJBs) always reside in a Container that provides technical 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 Bean Instance EnterpriseBean EJB Context 4 ejbCreate ejb... Deployment Descriptor EJB Jar bean-methods EJB Home EJB Object new EJB Run-time

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 51 Server Components in Java cont‘d  4 Types of Beans Stateless Session-Beans (Service Components)Stateless Session-Beans (Service Components) Stateful Session Beans (Session Components)Stateful Session Beans (Session Components) Entity-Beans (Entity Components)Entity-Beans (Entity Components) Message-Driven Beans (asynch. Service Components)Message-Driven Beans (asynch. Service Components)  A bean is (theoretically) portable across containers (Application Servers) from different vendors.

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 52 Commonalities and Differences  Commonalities: Server Components are available (Assemblies + COM+, EJB).Server Components are available (Assemblies + COM+, EJB). Interop with legacy components in.NET using COM+, in Java using CORBA)Interop with legacy components in.NET using COM+, in Java using CORBA)  Differences: EJB are a more mature and proven modelEJB are a more mature and proven model Special APIs to connect to legacy systems (Java Connector API)Special APIs to connect to legacy systems (Java Connector API)

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 53 Database Access in.NET  In.NET there is ADO.NET “connectionless”“connectionless” Data Source DataSetCommandCommand Connection DataReader DataSet Client Managed Provider

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 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”]); }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 55 ADO.NET  ADO.NET is XML based (XML Infoset) DataSet dynamically builds an XML schema inside to store the dataDataSet dynamically builds an XML schema inside to store the data Relational data and XML data can be handled in a similar way!!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 DataSetsUpdating is partly automatic using DataSets  Currently there are two Managed Providers: SQL ServerSQL Server ADOADO

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 56 Database Access in Java  Java provides JDBC to access relational data ODBC DB ODBC Driver JDBC/ ODBC Bridge Driver ManagerConnection Statement Prepared Statement Callable Statement Resultset Application

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 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();

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 58 Database Access in Java  There are several other APIs: Embedded SQL in the form of SQLJ (uses JDBC internally)Embedded SQL in the form of SQLJ (uses JDBC internally) Proprietary ODBMS APIsProprietary ODBMS APIs Standardized JDO API to provide (more or less transparent) persistence for Java ObjectsStandardized JDO API to provide (more or less transparent) persistence for Java Objects XML is handled differently!XML is handled differently! Java Connector API provides access to other „connection oriented“ legacy systems (such as SAP R3)Java Connector API provides access to other „connection oriented“ legacy systems (such as SAP R3)

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 59 Commonalities and Differences  Commonalities: Decoupling of the concrete data model and the user (using DataSets and ResultSets)Decoupling of the concrete data model and the user (using DataSets and ResultSets)  Differences: ADO.NET uses XML extensively, JDBC has a more relational flavorADO.NET uses XML extensively, JDBC has a more relational flavor JDBC is connection oriented, ADO.NET always works non-connected, or offlineJDBC is connection oriented, ADO.NET always works non-connected, or offline.NET DataSets are a kind of In-Memory-Database- Cache..NET DataSets are a kind of In-Memory-Database- Cache.

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 60 XML

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 61 XML and.NET .NET is very XML-centric Web Services (SOAP)Web Services (SOAP) Configuration FilesConfiguration Files Result sets of a database access (ADO.NET)Result sets of a database access (ADO.NET) XML processing itselfXML processing itself  Note that formally, many.NET features are based on the XML infoset („XML semantics“) and do not necessarily require megabytes of text data!!

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 62 XML and.NET cont‘d  The System.Xml Namespace provides a whole lot of classes DOM processing using XmlNode & SonsDOM processing using XmlNode & Sons XPath and XslTransformXPath and XslTransform XmlTextReader und XmlTextWriter similar to SAX in that they are both stream-based, but.NET uses a Pull-ModelXmlTextReader und XmlTextWriter similar to SAX in that they are both stream-based, but.NET uses a Pull-Model

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 63 XML und Java  There are several standards and tools available DOM, SAXDOM, SAX Xerces/Xalan, JDOMXerces/Xalan, JDOM JAX{M,B,R,RPC}JAX{M,B,R,RPC} CastorCastor  However, Java‘s libraries have not been designed with XML as a basis (Java‘s too old )  JAXP (Java API for XML Parsing) supports DOM and SAX.  Currently under development JAXM (Java API for XML Messaging)JAXM (Java API for XML Messaging) JAXB (Java API for XML Data Binding)JAXB (Java API for XML Data Binding) JAXR (Java API for XML Registries)JAXR (Java API for XML Registries) JAX/RPC (Java API for XML based RPC)JAX/RPC (Java API for XML based RPC)

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 64 Remoting Somebody knows a nice picture here?

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 65 Remoting in.NET Application Domain B Client Formatters Channels Envoy Sinks Real Proxy Transparent Proxy Servant Formatters Channels Server Context Sinks Object Context Sinks Network Application Domain A

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 66 Remoting in.NET (cont‘d) .NET Remoting provides pluggable transports and formatters currently TCP and HTTP transport andcurrently TCP and HTTP transport and binary and SOAP formattersbinary and SOAP formatters  Contexts are automatically propagated (very neat feature!!)  Only very simple lifecycle management options for servants (compared to EJB or CORBA) Singleton (one object for all calls)Singleton (one object for all calls) SingleCall (new instance for each call)SingleCall (new instance for each call) Client-Activated based on leasesClient-Activated based on leases

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 67 Remoting in.NET (cont‘d)  Objects can be marshalled by value (Serializable)  Asynchronous invocations are easily possible without touching the servant

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 68 Stub/Skeleton-Layer Remoting in Java  Several possibilities: RMI/CORBA RMI can use JRMP or IIOP as a transport protocolRMI can use JRMP or IIOP as a transport protocol Not pluggable – changes in the code are necessaryNot pluggable – changes in the code are necessary ClientServer StubSkeleton Remote Reference Manager Transport Layer

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 69 Commonalities and Differences  Commonalities: Relatively easy to useRelatively easy to use  Unterschiede:.NET Remoting can be extended more flexibly.NET Remoting can be extended more flexibly Java provides Interop with CORBAJava provides Interop with CORBA Asynchronous invocations are not easily possible with JavaAsynchronous invocations are not easily possible with Java

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 70 Web

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 71 ASP.NET (Server-Side Scripting)  ASP.NET Architecture: IIS 5 Web Server Client (1) get a.apx(2) process.NET Engine.NET Assembly Other Assemblies Database (3) result (4) HTTP file

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 72 ASP.NET Example  A simple login screen:

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 73 ASP.NET Example (cont‘d) Please specify your name and password Login Password

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 74 ASP.NET Example (cont‘d) // lot of details omitted namespace 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"); }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 75 Java Server Pages and Servlets  Java also allows for server-side scripting JSPs are based on ServletsJSPs are based on Servlets Web Server Client (1) get a.jsp(2) process JVM JSP Other Components Database (4) result (5) HTTP file Servlet (3) gen. Servlet Servlet Impl.

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 76 Java Example

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 77 Java Example  Bean und JSP-Seite: // Datei MyPerson.java package MyPackage; import java.lang.*; public class MyPerson { public String getFirstName() { return "Michael"; } public String getLastName() { return "Stal"; } } // Datei MyTest.jsp: Your name is:

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 78 Commonalities and Differences  Commonalities: Pages are precompiled to accelerate accessPages are precompiled to accelerate access Similar syntax and conceptsSimilar syntax and concepts ASP.NET provides „GUI components“ using Webcontrols, Java provides Taglibs.ASP.NET provides „GUI components“ using Webcontrols, Java provides Taglibs.  Differences: All.NET languages can be used for ASP.NET scriptingAll.NET languages can be used for ASP.NET scripting Servlets/JSP are available for a wide range of webserversServlets/JSP are available for a wide range of webservers Many open source implementations, frameworks and tools for JavaMany open source implementations, frameworks and tools for Java

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 79 Web Services in.NET .NET provides a very comfortable and well-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 / ; } [WebMethod] public double Euro_to_DM(double value) { return value * ; }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 80 Web Services in.NET (forts.)  Using it is also simple Some steps have been ommittedSome steps have been ommitted  Webservices are „just a special way of remoting“  BUT: Microsoft does not provide ebXML complianceMicrosoft does not provide ebXML compliance Currently they can only be used with MS serverCurrently they can only be used with MS server localhost.Service1 s1 = new localhost.Service1(); double result = s1.Euro_to_DM(200);

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 81 Web Services in Java  Sun ONE will provide a Web Service API for Java, completely ebXML compliant  Currently there are many proprietary solutions Some specific SOAP toolkits:Some specific SOAP toolkits: -Apache SOAP -IBM Web Services Toolkit -GLUE Some integrated with the major application serversSome integrated with the major application servers -Silverstream -IONA -Weblogic -...  Sun works at standard APIs JAXMJAXM

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 82 Commonalities and Differences  Commonalities: Both.NET and Java try to be standards-compliant (SOAP, WSDL, UDDI).Both.NET and Java try to be standards-compliant (SOAP, WSDL, UDDI). Handling very similar: WSDLbased generators that create proxiesHandling very similar: WSDLbased generators that create proxies  Differences: For Java there are different solutions, whereas.NET provides only one, nativelyFor Java there are different solutions, whereas.NET provides only one, natively Currently, standards are interpreted differently, so Interop Java-.NET is only limited. But this will hopefully change!!Currently, standards are interpreted differently, so Interop Java-.NET is only limited. But this will hopefully change!!

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 83 More Enterprise APIs

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 84 Enterprise APIs  Naming: JNDI in Java (as an interface to CORBANaming, LDAP,...)JNDI in Java (as an interface to CORBANaming, LDAP,...) Active Directory in.NET (Windows-specific)Active Directory in.NET (Windows-specific)  Message-orientierte Middleware: JMS in JavaJMS in Java JAXM is on the horizon (XML based messaging)JAXM is on the horizon (XML based messaging).NET can use MSMQ, and remoting can be used asynchronously.NET can use MSMQ, and remoting can be used asynchronously

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 85 Legacy-Integration  In.NET using the Microsoft Host Integration Server.  In Java using the Connector API  Comparison: Java provides a much simpler way. Connectors can be implemented relatively straight forward.

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 86 Interoperability  Java provides access to C/C++ using JNI (Java Native Interface). Relatively complex 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); }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 87 Interoperability cont‘d  In.NET there is a way to interop with COM+ 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…Use the same assemblies, class libraries… Languages had to be adapted a little bit (e.g. Managed C++ does not provide multiple inheritance)Languages had to be adapted a little bit (e.g. Managed C++ does not provide multiple inheritance)

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 88 Mobile and Embedded

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 89 Profiles and devices  There are the following variants of Java J2SE (Java 2 Platform Standard Edition)J2SE (Java 2 Platform Standard Edition) J2EE (Java 2 Platform Enterprise Edition)J2EE (Java 2 Platform Enterprise Edition) J2ME (Java 2 Platform Micro Edition)J2ME (Java 2 Platform Micro Edition) -Configurations, -and Profiles JavaCardJavaCard

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 90 Profiles and devices cont‘d .NET Universe.NET: Framework for Standard und Enterprise.NET: Framework for Standard und Enterprise.NET Compact Framework for Windows CE (and other embedded OS).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

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 91 Profiles and devices cont‘d .NET Mobile Web SDK Abstraction for the developerAbstraction for the developer Several markup languages (WML, HTML,...)Several markup languages (WML, HTML,...) Configurable and extendibleConfigurable and extendible ASP.NET can be usedASP.NET can be used Emulators for devices are available for testing and debugging purposesEmulators for devices are available for testing and debugging purposes Extends ASP.NET with special controlsExtends ASP.NET with special controls

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 92 Selecting one of the two

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 93.NET and/or Java ? .NET is a product, Java and J2EE is a specification  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 independent“ must be considered carefully: ECMA works on the standardization of C# and parts of.NETECMA works on the standardization of C# and parts of.NET Other languages can be compiled to the JVMOther languages can be compiled to the JVM

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 94.NET and/or Java ? .NET language independence is not for free and not completely transparent  In a real project you might want to use only one language But sometimes...But sometimes... #pragma once using 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; }

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 95.NET and/or Java ?  Windows Applications are probably better done with.NET than Java (maybe IBMs SWT changes this ?)  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!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 Java and.NET

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 96 Management Summary - 1.NETJava Controller/OwnerMicrosoftSun + JCP-Partner StatusProduct LineSpecification and many implementations LanguagesC#, C++, Eiffel#, VB,....Java + possibly others Communication middleware (RPC, Messaging, Web).NET Remoting, MSMQ, Web Services (no ebXML) RMI/CORBA, JMS, Web Services (standard compliant) Server ComponentsCOM+Enterprise JavaBeans XML-SupportConsistentCurrently not yet completely integrated Server PagesASP.NETJSP/Servlets

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 97 Management Summary - 2.NETJava Database accessADO.NET (ADO)JDBC / SQLJ and others Base librariesMany many classes on System.* Many many classes on java.* GUI-LibsWindows.Forms Web.Forms Swing/AWT Runtime.NET CLRJava JVM Interop (call-in/call-out)PInvokeJNI InteropMiddlewareCOM/COM+ (COM Interop) CORBA, JMS Legacy IntegrationHost Integration ServerJCA

Markus Voelter/Michael Stal – Comparing J2EE with.NET Folie 98 The End Thank you very much!!