J2EE versus .NET - PDF

W
Document Sample
scope of work template
							Advanced Developers Conference
10.-11. Oktober 2004




                                                                Agenda
                                                             Bemerkungen
                                                    Tec 07

                                                                     Motivation
                                                                     Comparison
           J2EE versus .NET                                           • Overall Vision: Java and .NET
                                                                      • Layer-by-Layer comparison of the infrastructures
                                                                     Summary
           Michael Stal
           Siemens AG, Corporate Technology




                                                             Bemerkungen
           Goal                                                   Some Issues

             This is intended to be an objective                     If we are going to compare .NET and
             comparisons of the two platforms                        Java, what do we mean?
                                                                      • Will we compare Java, the language, with C#?
                                                                      • Will we compare Java, the platform, with .NET, the
             In will contain criteria to base a decision                platform?
             which platform to use                                    • Will we compare the Java Virtual Machine with the
                                                                        CLR (Common Language Runtime)?
             Interoperability issues                                 In this talk we will try to cover most
                                                                     aspects.




                                                                The Naive Approach
                                                             Bemerkungen
           Layer-By-Layer Comparison                              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;

                                                              import java.lang.*;
                                                              public class MyClass {
                                                                     public static void Main(String [] args) {
                                                                             System.out.println(„Hello, Java!“);
                                                                     }
                                                              }




Dein Name – Dein Vortragstitel                                                                                             Pra 01 - S. 1
Advanced Developers Conference
10.-11. Oktober 2004




           Layers                                                       What
                                                                    Bemerkungen is                   J2EE Technology?
                                                                                    • not just a set of APIs
              High Level Overview
                                                                       J2EE Technology                            Purpose
              Runtime System
              Object model                                             Platform Specification                     Describes the minimum feature set of
                                                                                                                  J2EE APIs and standards that vendors
              Base class libraries                                                                                must provide
              Enterprise support                                       Reference implementation                   Provides a compliant and operational J2EE
                   -   Component model                                                                            platform

                   -   Database access                                 J2EE Blueprints                            Describes how to construct J2EE
                   -   XML                                                                                        applications (including JAVA Pet Store)
                   -   Server Pages                                    Compatibility Testsuite                    Validates J2EE platform compatibility to
                   -   Remoting                                                                                   guarantee code portability and eliminate
                                                                                                                  vendor lock
                   -   Web Services
                   -   More Enterprise APIs




                                                                    Bemerkungen
              What is J2EE Technology?                                     What is J2EE Technology?
           Java-based Multi-Tier Architectures: J2EE supports
           appropriate technologies for each tier




                                                                                      J2EE is based on J2SE, which includes the following enterprise APIs:
                                                                                      • Java IDL and RMI-IIOP
                                                                                      • JAAS (Java Authentication and Authorization Service)
                                                                                      • JDBC (Java Data Base Connectivity)
                                                                                      • JNDI (Java Naming and Directory Interface)
                                                                                      • JAXP (Java API for XML Parsing)




                 J2EE „standard“ Services                                  Multi-tier
                                                                    Bemerkungen                         Architecture
                                                                                                     Overview
             Servlets
             Java Server Pages
             Java RMI-IIOP and RMI-JRMP
             JavaIDL
             JNDI (Java Naming and Directory Interface)
             JMS (Java Message Service)
             Java Authentication and Authorization Service (JAAS)
             Enterprise JAVA Beans
             JDBC (Java Data Base Connectivity)
             J2EE Connector Architecture
             Java Transaction API
             JavaMail and JAF
             Java API for XML Parsing

          Of course I cannot cover them all.




Dein Name – Dein Vortragstitel                                                                                                                              Pra 01 - S. 2
Advanced Developers Conference
10.-11. Oktober 2004




              The .NET Framework Class
              Library
                                                                                                                                    The Runtime
                                                                                                                                 Bemerkungen                               System

                     In .NET we distinguish between .NET
                     Framework and .NET CF
                   System.Web                      System.Windows.Forms                                 CLR
         Services         UI                    Design         ComponentModel
         Description      HtmlControls                                                        Base Class Library Support
         Discovery        WebControls
         Protocols                                       System.Drawing                 Thread Support         COM Marshaler
         Caching          Security              Drawing2D        Printing
         Configuration    SessionState          Imaging          Text                    Type Checker        Exception Manager
                   System.Data                            System.Xml
                                                                                        Security Engine        Debug Engine
         ADO              SQL                   XSLT             Serialization
         Design           SQLTypes              XPath
                                                                                       IL to Native      Code        Garbage
                                       System                                           Compilers       Manager      Collector
         Collections      IO                  Security          Runtime
         Configuration    Net                 ServiceProcess    InteropServices
                                                                                                      Class Loader
         Diagnostics      Reflection          Text              Remoting
         Globalization    Resources           Threading         Serialization




                                                                                                                                 Bemerkungen
              Java Virtual Machine                                                                                                  .NET Runtime
                  The JVM targets Java and interprets Java Byte Code.                                                                 It is called the Common Language Runtime (CLR)
                  Other languages can also be compiled to Java bytecode (e.g.                                                         It supports all languages compiled for the MSIL
                  Ada)                                                                                                                Provides integration for several languages
                  Just-in-Time compilers exist for different environments and                                                         Provides support for non-OO languages (e.g. tail
                  OSs                                                                                                                 recursion)

                                                                                                                                      C#
                                   Compiler




                                                                                                                                              Compiler



                                                                                                                                     VB.NET
                  Java                                    CLASS-                  Classloader/
                                                                                                             JIT                                            MSIL +           Loader/
                                                           Files                     Verifier                                                                                             JIT
                                                                                                                                                           Metadata          Verifier
                                                                                                                                      C++‘
                                                     Garbage                                                                                                Garbage
                                                                                                           Native
                                                    Collection,                   Interpreter                                                              Collection,                  Managed
                                                 Security Manager                                          Code                       Perl                  Security,       Execution
                                                 Call-in+Call-out,                                                                                       Multithreading,
                                                                                                                                                                                         Code
                                                  Multithreading,
                                                         ...
                                                                                   Hotspot                                                                      ...




              Differences and                                                                                                    Bemerkungen
              Commonalities
                                                                                                                                    The Object Model

                     Commonalities:
                       • Basic infratructure is similar
                     Differences:
                       • Java is intended for interpretation (e.g. type-
                         dependent primitives i_add, ...)
                       • Java allows for custom class loaders and security
                         managers
                       • .NET is optimized for compilation and is thus
                         sometimes faster
                       • .NET CLR provides a command set that also
                         supports functional languages




Dein Name – Dein Vortragstitel                                                                                                                                                                    Pra 01 - S. 3
Advanced Developers Conference
10.-11. Oktober 2004




           Object Model (Java)                                                       java.lang.Object
                                                                                  Bemerkungen

             Java has primitive types and classes.                                         Base of all Java classes
             • No automatic boxing/unboxing                                        public class Object {
                                                                                     public Object();
                                                                                     public boolean equals(Object obj);
                                  Types
                                                                                     public final Class getClass();
                                                                                     public int hashCode();
                Primitive Types                    Reference Types
                                                                                     public final void notify();
                                          Arrays                     Interfaces      public final void notifyAll();
                                                                                     public String toString();
                                                      Classes                        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 ClineNotSupportedException;
                                                                                     protected void finalize() throws Throwable;
                                                                                   }




                                                                                  Bemerkungen
           Object Model (Java)                                                        Object Model (.NET)

             Primitive types cannot be transparently                                       In .NET, everything is a class
             used as an object. Special Holder classes
             are necessary.                                                                                                 Types

           Integer i_ref = new Integer (7);                                                       Value Types                                       Reference Types
           List l = ...
                                                                                                                                 Pointers                                  Interfaces
           l.add( i_ref );
                                                                                       System Value         User Value
                                                                                          Types               Types                                  Self-describing

             There are no special function references.                                                                                                   Types


             Java uses Observer Pattern with
                                                                                                 Enumerations
                                                                                                                                      Classes                          Arrays


             callback interfaces and inner classes                                                                       Delegates              Boxed Values


                                                                                                                                     User-Defined




                                                                                  Bemerkungen
           System.Object                                                              Object Model (.NET)

             The „mother of all .NET classes“                                              .NET distinguishes between values types
        public class Object {
                                                                                           and reference types:
         public virtual int GetHashCode();                                                  • value types reside on the stack
         public virtual bool Equals();                                                      • reference types reside on the heap
         public virtual String ToString();
         public static bool Equals(object a, object b);
                                                                                           There is no difference between primitive
         public static bool ReferenceEquals(object a,                                      types and classes
                                            object b);                                      • Automatic boxing/unboxing provides transparency
         public Type GetType();
         protected object MemberWiseClone();                                               Special strongly-typed function
         protected virtual Finalize()´;                                                    references
        }                                                                                   • called delegates
                                                                                            • and events




Dein Name – Dein Vortragstitel                                                                                                                                                          Pra 01 - S. 4
Advanced Developers Conference
10.-11. Oktober 2004




             .NET-Types that are not                                                .NET-Types that are not
                                                                                 Bemerkungen
             available in Java                                                       available in Java (cont‘d)
                 Delegates & Events:                                                    Enumerations (value type):
         class Sub {                                                                 enum Color : byte { RED = 1, BLUE = 2, GREEN = 3 };
            public void somebodyTurnedOnTheLight( int which ) {

            }
               // do something useful
                                                                                        Jagged (arrays of arrays) and unjagged
            public Sub(Pub thePub) {
                thePub.OnLightTurnedOn +=
                                                                                        Arrays:
                       new Pub.LightTurnedOn(somebodyTurnedOnTheLight);              int [2][] a; a[0] = new int[]{1}; a[1] = new int[]{1,2};
            } // ...                                                                 int [,] a = new int[2,2];
         }

         class Pub {                                                                    Structs (value types):
           public delegate void LightTurnedOn(int ID);
           public event LightTurnedOn OnLightTurnedOn;                                  • Structs are implicitly sealed:
           public void SomeoneTurnsOntheLight() {                                       • they do String First;
                                                                                     public struct not support inheritance
                                                                                                    Name {
                OnLightTurnedOn(myID);                                                      public
           } // ...                                                                         public String Last;
         }                                                                           }




             Commonalities and                                                   Bemerkungen
             Differences
                                                                                     Metainformation
                 Commonalities:                                                         Java and .NET provide a reflection API
                 • Interfaces are „completely abstract classes“
                 • Both support single inheritance for classes (implementation          • to load, execute, and instantiate classes
                   inheritance) and multiple interface inheritance
                 • Default-Initialization of variables                                  • and inspect classes (introspection).
                 • Namespace-Concept (Java-Package and .NET-Namespace)
                 • Similar visibility attributes (public, private, ...)
                 • Generic types in .NET and Java (Generics) but .NET Generics
                   much more flexible and available as runtime entities
                                                                                        In addition, .NET allows to annotate
                 • Class constructors (static initializers in Java)                     many aspects of a system (classes,
                 Differences:                                                           members, operations) with Attributes
                 • In .NET there is no difference between primitive types and
                   classes. Boxing to map between value and reference types.
                   Autoboxing now also available in Java.
                 • Multiple language support in .NET
                 • In Java all methods are implicitly virtual. In .NET this is
                   explicitely specified (virtual, override, new).
                 • Java maps packages to directories. .NET doesn‘t.




                                                                                 Bemerkungen
             Java Example                                                            .NET Examples

                 Accessing and using Type information:                                  Using an Atttribute
                 • Note that packages and namespaces are different                 [AuthorIs(„Michael“)]
                   issues!!                                                        class MyClass { ... }
         import java.lang.reflect.*;                                                    • There are several predefined attributes
                                                                                          (WebService, WebMethod, ...)
         try {
                 Class c = Class.forName(„MyPrintComponent“);
                 Object o = c.newInstance();
                 Method m = c.getMethod(„print“, new Class[]{ String.class });          Defining an Attribute
                 m.invoke(o, new Object[]{„Hallo, Java!“});
         }                                                                         [AttributeUsage(AttributeTargets.All]
         catch (Exception e) {                                                     public class AuthorIsAttribute : Attribute {
                // handle it here                                                         private string m_Name;
         }                                                                                public AuthorIsAttribute(string name) { m_Name = name;}
                                                                                   }




Dein Name – Dein Vortragstitel                                                                                                             Pra 01 - S. 5
Advanced Developers Conference
10.-11. Oktober 2004




                                                                                   Commonalities and
            .NET Example (cont‘d)                                               Bemerkungen
                                                                                     Differences
               Accessing and using Type information                                     Commonalities:
        using System;                                                                    • Very similar APIs
        using System.Reflection;
                                                                                        Differences:
        namespace ComponentClient {
               class Client {                                                            • .NET allows additional, user-defined meta
                       static void Main(string[] args) {                                   information with attributes. This will also be
                        Assembly a = Assembly.LoadFrom("Component.dll");
                        Type [] allTypes = a.GetTypes();
                                                                                           possible in Java using a similar approach.
                        Type t = allTypes[0];                                            • Java Reflection is sometimes a bit more clumsy
                        object o = Activator.CreateInstance(t);
                        MethodInfo mi = t.GetMethod("algorithm");
                                                                                           (because of primitive types and classes)
                        double d = (double) mi.Invoke(o, new object[]{21.0});            • .NET allows to actually create new artifacts at
               }
                       }                                                                   runtime and instantiate them or store them in
        }                                                                                  assemblies.




                                                                                Bemerkungen
            Statements                                                               Exceptions

               Both platforms support basically the                                     Exceptions in Java
               same language features                                                    • Exceptions have to be declared in the throws-clause. Checked
                                                                                           versus unchecked exceptions
               Some Differences:                                                     public int insert(int i) throws OverLimitException;
                • switch-Statement allows Strings, and prevents                      { … }
                  fallthrough.
                • Different iterators: foreach(et in ct) to
                  iterate container in .NET versus
                  for (ElementType: ContainerType) in                                   Exceptions in .NET
                  Java.                                                                  • Exceptions are not declared
                • Indexers, Operators not available in Java.                          // only way to tell you about
                • Properties in Java are handled by coding                            // OverLimitException thrown below
                  conventions (set, get).                                             public int insert(int i) { … }




                                                                                Bemerkungen
            Multithreading                                                           Multithreading in Java

                                                                                        In Java there is a class „Thread“ and an
                                                                                        interface Runnable
                                                                                        For synchronisation we have to use the
                                                                                        keyword synchronized
                                                                                 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




Dein Name – Dein Vortragstitel                                                                                                                       Pra 01 - S. 6
Advanced Developers Conference
10.-11. Oktober 2004




                                                                                   Commonalities and
            Multithreading in .NET                                              Bemerkungen
                                                                                   Differences
               .NET uses delegates for multithreading                                Commonalities:
                • The „ThreadStart“ in the example below                               • Threading is very similar!
               There are monitors for synchronization                                Differences:
                • The “lock” in the example below                                      • In Java, synchronization is better integrated into
        class GlobalData {
                                                                                         the language. Different design philosophies
               int m_Value;                                                            • Java provides better synchronization and thread
        }
               public int Value { set { lock(this) { m_Value = value; } } }              communication (wait, notify, ...).
        class Worker {                                                                 • In .NET it is much easier to create a thread from
               GlobalData m_Global;
               public Worker(GlobalData global) {m_Global = global; }
                                                                                         any method. Only precondition: method with no
               public void loop() { m_global.Value = 42; Thread.Sleep(100); }            result and no arguments.
        }
        // somewhere else:
        GlobalData g = new GlobalData();
        Thread t = new Thread(new ThreadStart(new Worker().loop));
        t.Start(); t.Join();          1




                                                                                Bemerkungen
            Component Models                                                       Java

                                                                                     .jar files are similar to .NET‘s assemblies
                                                                                       • They can be shared or private
                                                                                       • They can be signed

                                                                                     They contain
                                                                                       • types
                                                                                       • resources
                                                                                       • optionally, metadata in manifest files.


                                                                                     There is no versioning and jar-files are
                                                                                     just pre-deployment-time entities!




                                                                                Bemerkungen
            Java Component Models                                                  Server Components in Java

               Client Components and Server                                          Enterprise JavaBeans (EJBs) always
               Components                                                            reside in a container that hides technical
                                                                                     aspects (sep. of concerns)
               JavaBeans are Client Components                                                 JNDI    Naming

                • normal Java classes following some conventions                                       Service                                         Deployment
                                                                                                                                                        Descriptor
                                                                                     1) lookup home
                • optionally providing metainformation (BeanInfo                                                                                    EJB

                  class)
                                                                                                                              EJB                  Context
                                                                                     2) create bean                          Home                                         EJB
                                                                                     2”) find bean                                                                        Jar
                                                                                                            Remote Bean
                                                                                                           Home Interface
        public class MyJavaBean {                                                                                           new
                                                                                                                             4
                                                                                      Client
               private int color;
                                                                                                                                                   EnterpriseBean
               public void setColor(int v) { color = v; }                                                                     EJB
                                                                                                                                       ejbCreate
                                                                                                                                       ejb...
                                                                                                                                                                       Bean
                                                                                           4) remove                         Object                                  Instance
               public int getColor() { return color; }                               3) Use bean         Remote Bean                        bean-methods
               // a lot of more ...                                                                        Interface


        }                                                                                                                             EJB Run-time
                                                                                                                             Application Server (Container)

        // BeanInfo class not shown here!




Dein Name – Dein Vortragstitel                                                                                                                                                  Pra 01 - S. 7
Advanced Developers Conference
10.-11. Oktober 2004




           Server Components in Java
           cont‘d
                                                                   OSGi
                                                                Bemerkungen

                                                                   Additional Frameworks for small evices are available
             4 Types of Beans                                      such as OSGi, Pico, or Spring.
             •   Stateless Session-Beans (Service Components)      OSGi Framework: a general-purpose, secure, managed
             •   Stateful Session Beans (Session Components)       Java execution environment that supports the deployment
             •   Entity-Beans (Entity Components)                  of extensible and downloadable service applications called
             •   Message-Driven Beans (asynch. Service             bundles.
                 Components)                                       Bundle: a software component plugged into the framework
                                                                   that provides some functionality to an end-device such as a
                                                                   gas meter.
             An EJB bean is in theory portable across
                                                                   Service: a Java object implementing a concisely defined
             containers (Application Servers) from                 interface. Installed bundles can register a number of
             different vendors.                                    services that can be shared with other bundles under strict
                                                                   control of the framework.




                 OSGi Architecture                              Bemerkungen
                                                                   .NET

                                                                   Component=Assembly=Set of Types
                                                                   • Note that this
                                                                     notion of a             name                  Sharedname

                                                                                                                                Manifest
                                                                                                                                                         Files                     Types



                                                                     component is
                                                                                                                                                       Referenced
                                                                                            version                  Hash                              Assemblies                 Security
                                                                                                       Custom                                                         Product
                                                                                                      Attributes                                                    Information



                                                                     very different        Type 1
                                                                                                                                            Metadata
                                                                     from that used
                                                                                          IL-Code
                                                                                           Type 2

                                                                     with EJB or          IL-Code
                                                                                           Type 3
                                                                                                                                Module 1


                                                                     COM+                 IL-Code




                                                                                                                                Resources




                                                                Bemerkungen
           Component Model in .NET                                 Server-Side Components

             Private Assemblies are typically only                    Now Component is used like in EJB
             useful by the owning application                         To use container-provided services like
             Shared Assemblies are stored in a global                 synchronisation or transactions COM+
             assembly cache and can be used by                        services can be used
             several applications.                                    COM+-Interop provides these features.
             • They are signed by a key
             • They are versioned!!
             Runtime uses Application Domains as an
             abstraction for isolated appartments
             within a process.




Dein Name – Dein Vortragstitel                                                                                                                                                          Pra 01 - S. 8
Advanced Developers Conference
10.-11. Oktober 2004




           Using COM Components in
           .NET
                                                                                  COM Callable
                                                                               Bemerkungen                                       Wrapper

             For a COM.DLL it is possible to create a                                  .NET creates a CCW for exporting .NET
             RCW (Runtime Callable Wrapper).                                           classes as COM servers:
             This is a wrapper to access COM
             components (with typelibs) from .NET:
                                                                                                COM               COM              CCW            .NET
                                                                                                                                                                .NET
                                                                                                Client                            Wrapper                     Component

                   .NET          .NET        RCW         COM
                                                                     COM
                   Client                   Wrapper                Component




           Future of Distributed .NET:                                         Bemerkungen
           Indigo
                                                                                   Indigo Architecture
                                                                                                                                                             Messaging Services
                                                                                 Service Model
             Indigo (part of Longhorn) provides common                                                                                                        Queuing
             framework for connected systems (SOA)                               Instance
                                                                                 Manager
                                                                                            Context
                                                                                            Manager
                                                                                                        Service
                                                                                                        Methods
                                                                                                                     Type        Declarative Transacted
                                                                                                                     Integration Behaviors Methods
             • Integrates Web services, .NET Remoting, MSMQ                                                                                                   Routing

             • Extensible Architecture                                           Communication
                                                                                                                                                              Eventing
             • Vertical functionality such as security integrated in Indigo       Channels
                                                                                                                                   Policy
                                                                                                                                   Engine
                                                                                  (Datagram, Reliable, Peer, …)
             Service layer completely decoupled from                                                                               Channel
                                                                                                                                                              …
                                                                                                                                   Security
             protocol layer.                                                      Transport Channels
                                                                                                                                   Message
                                                                                  (IPC, HTTP, TCP…)
             For more details browse to                                                                                            Encoder
                                                                                                                                                             System Services

             http://msdn.microsoft.com/Longhorn/underst                           Communications Manager (Port)
                                                                                                                                                              Transaction

             anding/pillars/Indigo/default.aspx
                                                                                                                                                              Federation
                                                                                 Hosting Environments
                                                                                  ASP.NET        .container   .exe           NT Service     DllHost           …




           Indigo Connectors                                                     Ports, Channels,
                                                                               Bemerkungen                                            Services,
                                                                                 And Messages
             A Connector is based upon 4 entities:
             •   Messages are in-memory envelopes (SOAP)                               Service

             •   Services are the targets of messages                                                                     Port
                                                                                                                                      Channel
             •   Ports are representations of network addresses                                                                                           Service
             •   Channels allow sending or receiving through ports                           Message

             Applications rely on these concepts                                                                                      Channel

             directly or indirectly
                                                                                      Service
                                                                                                                                                            Service
                                                                                                                                      Channel




Dein Name – Dein Vortragstitel                                                                                                                                              Pra 01 - S. 9
Advanced Developers Conference
10.-11. Oktober 2004




           Ports And Channels                                                              Port/Channel
                                                                                        Bemerkungen                                     Architecture
            A port is a location in network space
             • Resides in a single AppDomain
                                                                                                Service                                                                 Service
             • Has one or more affiliated transport channels
             • Provides a base URI for all addresses
            Messages flow through a port                                                                                                Port B
                                                                                                                               Port A
            via channels
             • Channels impose a message exchange pattern
                                                                                                                                        Transport
             • Channels may add additional processing code
                                                                                                                  Channels                          Channels



                                                                                                                  Extensions                      Extensions




                                                                                        Bemerkungen
           Services And Addresses                                                             Hosting
            ServiceReferences are used to identify                                             Services can be self-hosted or activated on
            message recipients                                                                 demand via ASP.NET
             • Absolute URI of service + fixed headers                                         “Indigo” shares activation with ASP.NET
             • Fully interoperable                                                              • Process/AppDomain Startup/Shutdown/Cycle
             • ServiceAddress is relative version                                               • Health monitoring
            “Indigo” uses the IService interface to                                             • Management
            model message recipients                                                           URI namespace partitioning relies
             • Maps ServiceAddress to in-memory object                                         on metabase
                                                                                                • Independent of transport (HTTP, TCP, etc.)




                                                                                        Bemerkungen
           On-Demand Activation                                                               Services In Action
                                                                                                                                                                          Service
                                                                                                       Client
          Admin                             Cmd line tools
                      MMC Plugins                                   Mgmt APIs              Service                                                          Service
          Tools                              (adsutil, etc)                                 Model               Send()                                       Model                Receive()
                                                                                          Extensions                                                       Extensions
                                                                                          Proxy                                                                               Session
          Process
          Management          Metabase                   W3SVC
          Components

                                                                                                                               Port A    Port B
          Listeners       http.sys       TcpListener     Mail Listener   IPC Listener
                                                                                                                                        Transport

                                                                                                                   Channels                         Channels
                                                                                                                  Extensions                        Extensions




Dein Name – Dein Vortragstitel                                                                                                                                                Pra 01 - S. 10
Advanced Developers Conference
10.-11. Oktober 2004




           [Service]                                                                             [RemoteObject]
                                                                                              Bemerkungen

            Service-Oriented               [Service]
                                           public class Hello
                                                                                                  Object-Oriented              [RemoteObject]
                                                                                                                               public class RemObj : MarshalByRefObject
            Programming Model              {                                                      Programming Model            {
                                             [ServiceMethod]                                                                     public RemObj() {
            Opt-In Contract                  private string Greeting(string name)                 Contract based on                 Console.WriteLine(
            Schema-based
                                             {                                                    public visibility                          "Object {0} has been created.",
                                               return String.Format("Hello, {0}!", name);                                                   this.GetHashCode().ToString());
            integration                      }                                                    DLL-based integration          }

            Broad interop                      public string Salutation (string name)             No Interop                       public string Hello(string name) {
                                               {                                                                                     return
                                                 return String.Format(“Howdy, {0}!”, name);       Like .NET Remoting,                     String.Format("Hello, {0}!”, name);
                                               }                                                  CLR-focused                      }
                                           }
                                                                                                                                   ~RemObj() {
                                                                                                                                       Console.WriteLine(
                                                                                                                                            "Object {0} is being torn down.",
                                                                                                                                           this.GetHashCode().ToString());
                                                                                                                                     }
                                                                                                                               }




           Commonalities and                                                                  Bemerkungen
           Differences
                                                                                                 Database Access in Java
              Commonalities:                                                                       Java provides JDBC to access relational
               • Assemblies and JAR files provide „deployment“ components                          data
               • Server Components are available (Assemblies + COM+, EJB).
                 Available component types in COM+ restricted
                                                                                                     Application
               • Interop with legacy components in .NET using COM+, in Java
                 using CORBA)
                                                                                                                   Statement
              Differences:
               • EJB are a more mature and proven model                                                             Prepared
                                                                                                      Resultset                    Connection       Driver Manager
                                                                                                                   Statement
               • Special APIs in J2EE to connect to legacy systems (Java
                                                                                                                    Callable                           JDBC/
                 Connector Architecture)                                                                           Statement                         ODBC Bridge
               • Much better versioning support in .NET (side-by-side
                 execution)                                                                                                                          ODBC Driver
               • Future Outlook: Indigo will provide SOA container, EJB 3.0
                 will introuce the POJO approach to simplify development                                                                                 ODBC
                                                                                                                                                          DB




                                                                                              Bemerkungen
           Java Example                                                                          Database Access in Java
        import java.sql.*;                                                                         There are several other APIs:
        // without error handling:
        Class.forName(„sun.jdbc.odbc.JdbcOdbcDriver“);                                              • Embedded SQL with SQLJ (uses JDBC internally)
        Connection                                                                                  • Proprietary ODBMS APIs
           con=DriverManager.getConnection(„jdbc:odbc:stocks,““,““);
        Statement stmt = con.CreateStatement();
                                                                                                    • Standardized JDO API to provide (more or less
        ResultSet rs = stmt.executeQuery(„SELECT * from stocks“);                                     transparent) persistence for Java Objects
        while (rs.next()) {                                                                         • XML is handled differently!
               System.out.println(rs.getString(„COMPANYNAME“));
        }                                                                                           • Java Connector API provides access to other
        rs.close();                                                                                   „connection oriented“ legacy systems (such as SAP
        stmt.close();                                                                                 R3)
        con.close();




Dein Name – Dein Vortragstitel                                                                                                                                         Pra 01 - S. 11
Advanced Developers Conference
10.-11. Oktober 2004




           Database Access in .NET                                                        ADO.NET
                                                                                       Bemerkungen

             In .NET there is ADO.NET                                                       ADO.NET is XML based (XML Infoset)
             • “connectionless”                                                             • DataSet dnymically builds an XML schema inside to store the
                                                        Client                                data
                                                                                            • Relational data and XML data can be handled in a similar
                                                        DataSet
                                                                                              way!!
                                                                                            ADO.NET works offline once the data is fetched
                                Command            DataSetCommand        DataReader
                                                                                            • Updating is partly automatic using DataSets
                                                                                            Currently there are three Managed Providers:
                                                                                            • SQL Server
                                           Connection               Managed Provider        • ADO
                                                                                            • Oracle

                                          Data Source




           Commonalities and                                                           Bemerkungen
           Differences
                                                                                          XML

             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 (like ADO)
             • JDBC is mainly connection oriented, ADO.NET
               always works non-connected, or offline
             • .NET DataSets are a kind of In-Memory-Database-
               Cache.
             • In Java additional O/R solutions such as JDO or
               SQLJ without .NET counterpart.




                                                                                       Bemerkungen
           XML und Java                                                                   XML and .NET
             There are several tools available
             •   DOM, SAX                                                                   .NET is very XML-centric
             •   Xerces/Xalan, JDOM                                                         •   Web Services (SOAP)
             •   JAX{M,B,R,RPC}                                                             •   Configuration Files
             •   Castor
                                                                                            •   Result sets of a database access (ADO.NET)
             However, Java‘s libraries have not beed designed
             with XML as a basis (Java‘s too old ☺)                                         •   XML processing itself
             JAXP (Java API for XML Parsing) supports DOM
             and SAX).
                                                                                            Note that formally, many .NET features
             Currently under development
             •   JAXM (Java API for XML Messaging)                                          are based on the XML infoset („XML
             •   JAXB (Java API for XML Data Binding)                                       semantics“) and do not necessarily
             •   JAXR (Java API for XML Registries)
             •   JAX/RPC (Java API for XML based RPC)
                                                                                            require megabytes of text data!!




Dein Name – Dein Vortragstitel                                                                                                                        Pra 01 - S. 12
Advanced Developers Conference
10.-11. Oktober 2004




           XML and .NET (cont‘d)                                      Remoting
                                                                   Bemerkungen

              The System.Xml Namespace provides a
              whole lot of classes
              • DOM processing using XmlNode & Sons
              • XPath and XslTransform
              • XmlTextReader und XmlTextWriter similar to
                SAX, but using a Pull-Modell (Stream-Based)
              • Schema support
              Two approaches: one that is closer to
              the programmer‘s object model and
              another one that is closer to the DOM.




                                                                   Bemerkungen
           Remoting in Java                                             Some Facts about RMI

              Several possibilities: RMI/CORBA/SOAP                        Registry tool as naming service, started
              • RMI can use JRMP or IIOP as a transport protocol           manually or automatically.
              • Not easily pluggable – changes in the code are             On demand activation possible.
                necessary                                                  Changing lease time for DGC possible (leasing
                                                                           time = time without connection).
              Client                                  Server
                                                                           Usage of RMISecurityManager to allow class
                                                                           loading across computer boundaries.
              Stub          Stub/Skeleton-Layer      Skeleton
                                                                           Object by value out-of-the-box.
                         Remote Reference Manager                          Other protocols by imlementing proprietary
                                                                           Socket factories.
                              Transport Layer




                                                                   Bemerkungen
           Example                                                      Example (cont‘d)

              Exeptions and interface definitions                          Implementation of remote object:
        // file: BoundaryException.java                             import java.rmi.*;
                                                                    import java.rmi.server.*;
        public class BoundaryException extends Exception {}
        // file: Grid.java                                          public class GridImpl extends UnicastRemoteObject implements Grid {
                                                                            Object[][] values; final
        import java.rmi.*;                                                  static int ROWS = 20; final static int COLS = 20;
                                                                            public GridImpl() throws RemoteException {
                                                                                     values = new Object[ROWS][COLS];
        public interface Grid extends Remote {                              }
              public void setValue(int row, int col, Object val)            public boolean isOutOfBoundaries(int r, int c) {
                                                                                     if ((r < 0) || (r >= ROWS) || (c < 0) || (c >= COLS))
                    throws RemoteException, BoundaryException;                               return true;
              public Object getValue(int row, int col)                               else return false;
                    throws RemoteException, BoundaryException;              }
                                                                            public Object getValue(int row, int col)
              public int getColumns()                                                throws RemoteException, BoundaryException {
                    throws RemoteException;                                          if (isOutOfBoundaries(row, col)) throw new BoundaryException();
                                                                                     else return values[row][col];
              public int getRows()                                          }
                    throws RemoteException;                                 ...
                                                                    }
        }




Dein Name – Dein Vortragstitel                                                                                                             Pra 01 - S. 13
Advanced Developers Conference
10.-11. Oktober 2004




            Example (cont‘d)                                                    Example
                                                                             Bemerkungen                    (cont‘d)

              The Server Main                                                        Client
                                                                              import java.rmi.*;
                                                                              import java.rmi.registry.*;
         import java.rmi.*;
         import java.rmi.server.*;
                                                                              public class GridClient {
                                                                                      public static void main(String args[]) {
         public class GridServer {                                                             try {
                                                                                                        Grid g = (Grid)Naming.lookup("grid");
               public static void main(String args[]) throws                                            g.setValue(4,4, new Integer(42));
         Exception {                                                                                    Integer i = (Integer) g.getValue(4,4);
                     GridImpl svr = new GridImpl();                                                     System.out.println(i);
                                                                                                        g.setValue(33,33, new Integer(88));
                     Naming.rebind("grid", svr);                                               }
                     System.out.println("ready");                                              catch (BoundaryException b) {
                                                                                                        System.out.println("Boundary violation");
               }                                                                               }
         }                                                                                     catch (Exception e) {
                                                                                                        System.out.println(e);
                                                                                               }
                                                                                      }

                                                                              }




                                                                             Bemerkungen
            Remoting in .NET                                                      Remoting in .NET (cont‘d)
                                                                                     .NET Remoting provides pluggable
             Application Domain A                  Application Domain B              transports and formatters
                                                                                      • currently TCP and HTTP transport and
                  Client                                  Servant                     • binary and SOAP formatters
                                                                                     Contexts are automatically propagated
                                                                                     (very neat feature!!)
              Transparent Proxy
                                                      Object Context Sinks           Only very simple lifecycle management
                                                                                     options for servants (compared to EJB or
                 Real Proxy
                                                      Server Context Sinks
                Envoy Sinks
                  Channels           Network              Channels                   CORBA)
                                                                                      • Singleton (one object for all calls)
                 Formatters                               Formatters

                                                                                      • SingleCall (new instance for each call)
                                                                                      • Client-Activated based on leases




            Commonalities and                                                Bemerkungen
            Differences
                                                                                  Web

              Commonalities:
               • Relatively easy to use
              Differences:
               • .NET Remoting can be extended more flexibly
               • Java provides interoperability with CORBA
               • Asynchronous invocations not directly supported
                 by Java
               • No activation mechanism provided in .NET
                 Remoting




Dein Name – Dein Vortragstitel                                                                                                                      Pra 01 - S. 14
Advanced Developers Conference
10.-11. Oktober 2004




            Java Server Pages and
            Servlets
                                                                                              Java Example
                                                                                           Bemerkungen

               Java allows for server-side scripting
                   • JSPs are based on Servlets
                                                                                Other
                    (1) get a.jsp            (2) process
                                     Web                     JSP              Components
          Client
                                    Server
                    (5) HTTP file
                                                (3) gen. Servlet Servlet
                                                                      Impl.
                                             (4) result
                                                            Servlet
                                                                              Database


                                                             JVM




                                                                                              Complementary Technologies
                                                                                           Bemerkungen
            Java Example                                                                      in Java
               Bean and JSP:                                                                    Servlets are server-side extensions providing
                                                                                                functionality. Implemented by Servlet Engine.
        // Datei MyPerson.java
        package MyPackage;                                                                      JSPs (Java Server Pages) are scripted Web
        import java.lang.*;                                                                     pages transformed to servlets.
        public class MyPerson {                                                                 Taglibs allow to integrate additional html/xml-
               public String getFirstName() { return "Michael"; }                               ike tags.
               public String getLastName() { return "Stal"; }
        }                                                                                       Java ServerFaces use taglibs to provide Web
        // Datei MyTest.jsp:                                                                    components.
        <HTML> <BODY>
        <jsp:useBean id="person" scope="session"                                                Apache Struts provides a framework for
        class="MyPackage.MyPerson"/>                                                            implementing MVC applications.
        Your name is: <br>
        <jsp:getProperty name="person" property="firstName"/> <br>
        <jsp:getProperty name="person" property="lastName"/>
        </BODY> </HTML>




            ASP.NET                                                                        Bemerkungen
            (Server-Side Scripting)
                                                                                              ASP.NET Example

               ASP.NET Architecture:                                                            A simple login
                                                                                                screen:
                                                                                Other
                    (1) get a.apx    IIS 5   (2) process     .NET             Assemblies
          Client                     Web                   Assembly
                    (4) HTTP file   Server
                                                             .NET
                                             (3) result     Engine


                                                                              Database




Dein Name – Dein Vortragstitel                                                                                                              Pra 01 - S. 15
Advanced Developers Conference
10.-11. Oktober 2004




             ASP.NET Example (cont‘d)                                               ASP.NET
                                                                                 Bemerkungen                Example (cont‘d)
        <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"                      // lot of details omitted
        AutoEventWireup="false" Inherits="LoginPage.WebForm1" %>                  namespace LoginPage {
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >            public class WebForm1 : System.Web.UI.Page {
        <HTML>                                                                       protected TextBox PasswordText, LoginText;
        <body>                                                                       protected Button EnterButton;
        <form id="Form1" method="post" runat="server">                               protected Label MessageLabel;
        <asp:Label id="TitleLabel" runat="server">Please specify your name and       private void InitializeComponent() {
        password</asp:Label> <br>                                                        this.EnterButton.Click +=
        <asp:Label id="LoginLabel" runat="server">Login</asp:Label> <br>                  new System.EventHandler(this.EnterButton_Click);
        <asp:TextBox id="LoginText" runat="server"></asp:TextBox>                        this.Load += new System.EventHandler(this.Page_Load);
        <asp:RequiredFieldValidator id="RequiredFieldValidator" runat="server"       }
        ErrorMessage="You need to specify your name"                                 private void EnterButton_Click(object sender, System.EventArgs e) {
        ControlToValidate="LoginText"></asp:RequiredFieldValidator> <br>                 if (!(LoginText.Text.Equals("aladdin") &&
        <asp:Label id="PasswordLabel" runat="server">Password</asp:Label> <br>                   PasswordText.Text.Equals("sesam"))) {
        <asp:TextBox id="PasswordText" runat="server"                                      MessageLabel.Text = " Wrong name or password!";
        TextMode="Password"></asp:TextBox> <br>                                          }
        <asp:Button id="EnterButton" runat="server" Text="Open the entrance"             else {
        ToolTip="Press this after you have specified login and                             Session["user"] = "aladdin";
        password"></asp:Button> <br>                                                       Response.Redirect("UserArea.aspx");
        <asp:Label id="MessageText" runat="server"></asp:Label>                          }
        </form>                                                                      }
        </body>                                                                    }
        </HTML>                                                                   }




             Commonalities and                                                   Bemerkungen
             Differences
                                                                                       XML Web Services

                Commonalities:
                 • Pages are precompiled to accelerate access
                 • Similar syntax and concepts
                 • ASP.NET provides „GUI components“ using
                   Webcontrols, Java provides Taglibs.
                                                                                          .. why today‘s Web does not solve all the
                Differences:                                                              problems.
                 • All .NET languages can be used for ASP.NET
                   scripting
                 • Servlets/JSP are available for a wide range of
                   webservers
                 • Many open source implementations, frameworks
                   and tools for Java




             Why do we care about Service-Oriented                               Bemerkungen
             Architectures and Web Services                                            Services
                                                                                       What is a service?
            Cannot take single-vendor approach to IT                                   • A remotely accessible self-contained piece of coarse-grained
            (because of risk, pricing, etc.)                                             software functionality with at least one unique physical address to
                                                                                         which a service consumer can bind using a communication
             • Embracing heterogeneity                                                   protocol supported.
                                                                                       • A service exports functionality using standardized service
            Interoperability is the only viable and                                      interfaces. There might be multiple service interfaces denoting
            economic approach                                                            different types of business functionality or different types of
                                                                                         communication protocols.
            Accelerating change in IT due to globalization,                            • Services are implementation agnostic in that the implementation
                                                                                         technology used (container, programming language, middleware,
            e-business, etc.                                                             underlying server infrastructure) is not made visible.
                                                                                       • Services are singletons. In contrast to CORBA, DCOM, RMI there
            Service-Oriented Architectures/Web Services                                  are no instances.
            have ubiquitous support of all major vendors                               • Services are defined using a high level description language
                                                                                         (XML)
            Standardization




Dein Name – Dein Vortragstitel                                                                                                                        Pra 01 - S. 16
Advanced Developers Conference
10.-11. Oktober 2004




           Service-Oriented
           Architectures
                                                                                                                                                    Loosely
                                                                                                                                                 Bemerkungen                        Coupled
            Basic concepts:                                                                                                                        The central paradigm when using Service-oriented Architecture
            • Self-contained services.                                                                                                             as a principle and paradigm is loose coupling.
            • Messages exchanged between providers and consumers.                                                                                  Loosely Coupled means (see Doug Kaye‘s book „Loosely Coupled
            • Brokers/Mediators where services are registered and located.                                                                         – The Missing Pieces of Web Services“):
            A Broker in this scenario isn‘t necessarily an ORB! It might be a                                                                       • All interactions are basically asynchronous on the transport level. Higher
                                                                                                                                                      abstraction layers might be introduced to support synchronous communication.
            directory service or a P2P discovery mechanism.
                                                                                                                                                    • Messaging Style is Document, not RPC.
            Components/Containers are often used for the implementation of                                                                          • Message Paths are routed, not hard-coded.
            services!                                                                                                                               • Technology must support heterogeneity (interface is standardized, not code).
                                                                  Service
                                                                  Repository                                                                        • Data Types are technology independent.
                                                                           Enter service                                                            • Syntactic Definition using a schema. Contract defines structure (what
                                                                                                                                                      documents are exchanged) and behavior (e.g., order and rules of document
                                                                                                                                                      exchange, QoS).
                                                register
                                                                 BROKER               search                                                        • Binding is delayed, not fixed and early.
                                                                                                                                                    • Semantic Adaptation by transformation, not re-coding (e.g. use intermediaries
                                                                                                                                                      for currency calculations).
                                              SERVICE                                SERVICE                                                        • Objective: More on broad applicability than on re-use or efficiency.
                                             PROVIDER            consume           CONSUMER




           SOA: Message Passing                                                                                                                     Web Services as Middleware Solution:
                                                                                                                                                 Bemerkungen
           Paradigm                                                                                                                                   The Web is the Computer

             Under the hood each communication in a SOA
             is based upon asynchronous message                                                                                                                                      Message                              Message
             exchanges:                                                                                                                                       Client-side Proxy *    exchange   1        Broker       1   exchange *   Server-side Proxy
                                                                                                                                                               marshal                              register_server                     marshal
                                                                                                                                                               unmarshal                            find_server                         unmarshal
                         Peer 1                                                                   Peer 2                                                       receive_result                       establish_commu                     dispatch
                                                                                                                                                                                                    nication
                                                                                                                                                               service(proxy)                                                           receive_request
                                                                                                                                                                      *                                                                        *
                                                                                                                                                                            calls

             Any other communication style / semantics
                                                                                                                                                                                                                                                   calls


             can be provided using message passing, e.g.:
                                                                                                                                                                      1                                                                        1



              • Request/Response (use correlation info to associate                                                                                                 Client                                                                  Service

                messages)
                                                                                                                                                               call_service_p                                                           start_up
                                                                                                                                                               start_task                                                               main_loop
              • Multicast: Send same message to different peers                                                                                                                                                                         service(impl.)
              • ...




                                                                                                                                                 Bemerkungen
           Dynamics

                    Client               Client Proxy                       Broker                      Server Proxy                   Service        How to implement this
                             method
                             (proxy)                          find_service
                                                                                           register_service
                                                                                                                                                       paradigm
                                                           server descr.

                                                  marshal
                                                                                     receive_request
                                                              Request                                              unmarshal
                                                              Message
                                                                                                                   dispatch
                                                                                                                          method
                                                                                                                          (impl.)
                                                                                                                              result
                                                                                                                    marshal
                                                      receive_result
                                                                                                 Response
                                                  unmarshal
                                                                                                 Message
                                result
                                                                                      Between the proxies both
                                                                                      a message exchange format and
                                                                                      a transport protocol are required




Dein Name – Dein Vortragstitel                                                                                                                                                                                                                      Pra 01 - S. 17
Advanced Developers Conference
10.-11. Oktober 2004




           Step 1: Define a Transport
                                                                Marshalling
                                                             Bemerkungen                                              Flavors
           Protocol
           A protocol defines syntax,                                SOAP bodies can be formatted
           semantics and order of                                     • RPC style: method name and parameter names
           messages exchanged
           between peers.                                               are mapped to XML elements with same names
           For a Web-based transport                                  • Document Style: XSD Schema is used instead.
           protocol we need:                                            Web service can carry any document.
            • HTTP and other Internet Protocols
              as transport layer.                                    Options for parameter encoding:
            • a self-describing data
              representation format using XML.                        • Literal: Encoding using XML Schema
           Each request and each                                      • Encoded: Encoding using SOAP
           response is wrapped as a XML
           message and transfered over                               Conforming to the standard toolkits
           the wire.                                                 should use Document Style and Literal
              SOAP formerly known as Simple
              Object Access Protocol.




                                                                Step 2:
                                                             BemerkungenDefine a Service
           Why is SOAP important?
                                                                 Description Language
             SOAP defines a transport protocol based upon
             XML and HTTP (or other protocols).
             Leveraging HTTP helps clients and servers to
             circumvent firewalls.
             Using SOAP, web servers can be extended to
             full blown Broker architectures.
             SOAP can bridge disparate infrastructures and
             applications.




                                                                Step 3:
                                                             Bemerkungen Define a global
           WSDL Elements
                                                                 Service Directory
                                                                UDDI is a
                      Port                                      global registry
                                                                                                       Publisher API                   Instead of using UDDI we
                       • Concrete net address                   Registration                              UDDI                         might also use other central
                         of Web Service (incl.                  possible at any
                         URL and port)                          node                                    Inquiry API
                                                                                                                                       registries, hard coded URLs,
                      Service                                   Registrations                                                          or P2P discovery mechanisms
                       • Collection of ports                    replicated at        1. search for
                                                                                     web service
                       • Physical location of                   daily basis                                    2. return service URL
                         end point                              Common SOAP                                                                Description
                      Message                                   protocol used                                                           of Web Service
                                                                                                                                            (WSDL)
                       • Format for single
                                                                                                                   3. read service
                                                                                                                      description
                         transfer
                       • Request and Reponse
                         are separate
                         messages
                      PortType
                                                                                                                                                5. forward request
                                                                                                     4. send request using                           to service

                       • Logical grouping of
                                                                                                        SOAP over HTTP         Web Server
                                                                            Client
                         messages to
                         operations                                                                   7. send result using
                                                                                                                                                                     Web Service

                      Binding                                                                          SOAP over HTTP                       6. return result

                       • Maps PortType to
                         implementation (e.g.,
                         SOAP)
                         C       i    f     f




Dein Name – Dein Vortragstitel                                                                                                                                               Pra 01 - S. 18
Advanced Developers Conference
10.-11. Oktober 2004




           Step 4: All you need are                                              SOAP+WSDL+UDDI
                                                                              Bemerkungen                                       is not
           Generators                                                            sufficient
             Introduce tools that generate glue for
             connecting you with the Web ORB, i.e.,
             • Client Proxies for connecting the client with
               services.
             • Server Proxies for seamless service deployment.
                                                          Client
                                                          Proxy
                              WSDL
                                                          Server
                                                          Proxy



                                                                                                                                          Source: IBM




          WS Implementations and                                              Bemerkungen
                                                                                 Web Services in Java
          Complementary Technologies
             Tools:                                                                Java (J2EE 1.4) provides a Web Service API for
             • .NET: ASP.NET WebServices (will be integrated in Indigo),           Java: JAX-RPC is the
               WSE (Web Services Enhancements) includes Attachments,
               Security, ...                                                       Currently there are different solutions
             • J2EE: JAX-RPC which is implemented by many vendors such             • Some specific SOAP toolkits:
               as Apache Axis, WS is part of EJB 2.1 (Enterprise JavaBeans)           - Apache Axis
             • MS-SOAP for COM                                                        - IBM Web Services Toolkit
             • All major IDEs support WS such as IBM, Microsoft, BEA,                 - GLUE
               Borland, ...
                                                                                   • Some integrated with the major application servers
             Complementary Technologies:                                              -   Silverstream
             • P2P (Peer-to-Peer Computing): Use discovery instead of                 -   IONA
               central repository
                                                                                      -   Weblogic
             • Grid Computing: Sharing common resources on a network
                                                                                      -   ...




                                                                              Bemerkungen
                                                                                 GLUE

                                                                                   There are a lot of different solutions for
                                                                                   Java.
            Case Study: Web Services                                               One typical example is GLUE from „The
                                                                                   MIND Electric“.
            in Java using GLUE                                                     GLUE allows to implement Web services
                                                                                   in Java.
                                                                                   It provide its own little HTTP server and
                                                                                   can integrate EJB, JMS, ...




Dein Name – Dein Vortragstitel                                                                                                                   Pra 01 - S. 19
Advanced Developers Conference
10.-11. Oktober 2004




           GLUE (cont‘d)                                        GLUE Example
                                                             Bemerkungen                           (1)

             It also enables to parse WSDL files and                Provide an interface IHello.java:
             generate proxies.
             Interoperates with most vendors such               import java.*;
             as .NET or IBM WSTK.
             Offers both command line tools and
                                                                public interface IHello {
             JBuilder support.                                       public String echo(String input);
                                                                     public String hello();
                                                                }




                                                             Bemerkungen
           GLUE Example (2)                                       GLUE Example (3)

             Implement the interface in Hello.java:                 Implement main (HelloMain.java):

          import java.*;                                       import electric.registry.Registry;
                                                               import electric.server.http.HTTP;
                                                               public class HelloMain {
                                                                      public static void main( String[] args ) // throws Exception
                                                                      {
          public class Hello implements IHello {                              try {
               public String hello() {                                               // start a web server on port 8004
                                                                                     HTTP.startup( "http://localhost:8004/glue" );
                    return "Hello, here is GLUE";                                    // publish an instance of Exchange
               }                                                                     Registry.publish( "hello", new Hello() );
                                                                              }
               public String echo(String input) {                             catch(Exception e) {
                    return input;                                                    e.printStackTrace();
                                                                              }
               }                                                      }
          }                                                      }




                                                             Bemerkungen
           GLUE Example (4)                                       GLUE Example (5)

             Now start server                                     // calling it:
                                                                  IHello svc = new IHelloHelper().bind();
             Using a web service is also simple:                  String res = svc.echo(„Hello“);
             • Use wsdl2java to generate a proxy
               implementation.
             • Instantiate and invoke it from your client
               application.
             • GLUE also provides tools such as java2wsdl.




Dein Name – Dein Vortragstitel                                                                                             Pra 01 - S. 20
Advanced Developers Conference
10.-11. Oktober 2004




            Web Services in .NET                                             Datatypes
                                                                          Bemerkungen             supported

               .NET provides a very comfortable and                          String             Char               Byte

               well-integrated way to build them:                            Boolean            Int16              Int32
        namespace WebService1 {
               public class Service1 : System.Web.Services.WebService {      Int64              UInt16             UInt32
                      // lot of stuff omitted
                      [WebMethod]
                                                                             UInt64             Single             Double
                      public double DM_to_Euro(double value) {
                             return value / 1.95583;
                      }                                                      Guid               Decimal            DateTime
                      [WebMethod]
                      public double Euro_to_DM(double value) {               XMLQualifiedName   class              struct
                             return value * 1.95583;
                      }
               }                                                             XmlNode            DataSet
        }




                                                                             Commonalities and
                                                                          Bemerkungen
            Using Web Services                                               Differences
               Using it is also simple                                         Commonalities:
                • Some steps have been omitted                                  • Both .NET and Java strive for conformance to
        localhost.Service1 s1 = new localhost.Service1();                         existing standards (SOAP, WSDL, UDDI).
        double result = s1.Euro_to_DM(200);
                                                                                • „Look & Feel“ very similar: WSDL-based parsers
                                                                                  that generate proxies.
               Asynchronous „Style“:                                           Differences:
         localhost.Service1 s1 = new localhost.Service1();                      • For Java there is a whole bunch of available
         IAsyncResult ar = s1.BeginEuro_to_DM(200, null, null);                   solutions.
         While (!ar.IsCompleted) {
                // enjoy your coffee                                           Additional remark:
         }                                                                      • Standards are open to interpretation. Thus,
         double result = s1.EndEuro_to_DM(ar);
                                                                                  interoperability doesn‘t come for free.




                                                                          Bemerkungen
            More Enterprise APIs                                             Enterprise APIs

                                                                               Naming:
                                                                                • JNDI in Java (as an interface to CORBANaming,
                                                                                  LDAP, ...)
                                                                                • Active Directory in .NET (Windows-specific)
                                                                               Message-oriented Middleware:
                                                                                • JMS in Java (JAXM is on the horizon)
                                                                                • .NET can use MSMQ.




Dein Name – Dein Vortragstitel                                                                                                     Pra 01 - S. 21
Advanced Developers Conference
10.-11. Oktober 2004




           JMS – Messaging in Java                                            Example
                                                                           Bemerkungen

             JMS is an API to integrate existing MOM                                  Here is an example scenario for
             solutions (JMS Providers).
                                                                                      Queuing:
             Point to Point approaches are supported as
             well as Publish/Subscribe (Message Listeners).
             Queues (~ mailbox) and Topics (~ newsgroup).
             Different kinds of message bodies are
             provided: stream, text, serialized object, bytes,                                                                                       Session

             map.                                                                    Sender
                                                                                                Session
                                                                                                Session
                                                                                                          Connection   myQueue           Connection Session    Receiver
                                                                                                                                                     Session




                                                                           Bemerkungen
           Example (cont‘d)                                                       Example (cont‘d)

             Here is a sample peer-to-peer client:                                   ... sample continued ...
                                                                                     // Establish a session:
                                                                                     QueueSession session
             // First, we need a Connection Factory:                                  = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
             QueueConnectionFactory factory;                                         // Get a QueueSender to send messages using <queue>:
             Context msg   = new InitialContext(); // JNDI lookup                    QueueSender sender = session.createSender(queue);
             factory = (QueueConnectionFactory) msg.lookup(„QCFactory“);             // Get a QueueReceiver to receive messages using <queue>:
             // Getting a message queue:                                             QueueReceiver receiver = session.createReceiver(queue);
             myQueue = (Queue) msg.lookup(„MyQueue“);                                // Creating a Text Message:
             // Connect:                                                             StringBuffer myText;
             QueueConnection con;                                                    TextMessage message;
             con = fac.createQueueConnection(); // create JMS connection             message = session.createTextMessage();
                                                                                     message.setText(myText);




                                                                           Bemerkungen
           Example (cont‘d)                                                       MSMQ - Messaging in .NET

                                                                                      There is also a messaging API to access
             ... sample continued ...
             // Send the message:
             sender.send(message);
             // receiving response:
                                                                                      MSMQ:
             TextMessage newText;                                           using System;
             newText = (TextMessage) receiver.receive();                    using System.Messaging;


             That‘s it!
                                                                            namespace Messaging
                                                                            {
                                                                                      class Class1 {
                                                                                                static void Main(string[] args) {
                                                                                                          MessageQueue mq = null;
                                                                                                          if (!MessageQueue.Exists(@".\Private$\myQueue1")) {
                                                                                                                    mq = MessageQueue.Create(@".\Private$\myQueue1");
                                                                                                          }
                                                                                                          else
                                                                                                                    mq = new MessageQueue(@".\Private$\myQueue1");

                                                                                                               mq.Send("Hallo");
                                                                                                               Message msg = mq.Receive();
                                                                                                               Console.WriteLine(msg.Body.ToString());
                                                                                               }
                                                                                     }
                                                                            }




Dein Name – Dein Vortragstitel                                                                                                                                            Pra 01 - S. 22
Advanced Developers Conference
10.-11. Oktober 2004




             Accessing Directory Services                                          Legacy-Integration
                                                                                Bemerkungen

                There is a special API in .NET to access                             In .NET using the Microsoft Host
                LDAP-based directories such as Active                                Integration Server
                Directory.                                                           In Java using the Connector
                In Java JNDI serves as an adapter to                                 Architecture. JCA defines standard way
                existing directory services.                                         to build connectors and integrate them
                Both very similar.                                                   with EJB containers
                Java much more flexible.                                             Comparison: Java provides a much
                                                                                     simpler way. Connectors can be
                                                                                     implemented relatively straight forward.




                                                                                Bemerkungen
             Interoperability                                                      Interoperability (cont‘d)

                Java provides access to C/C++ using                                  In .NET there is a way to interoperate
                JNI (Java Native Interface). Relatively                              with COM+ and COM+ Services.
                complex call-in, call-out.                                           Java provides CORBA interoperability
                                                                                     JMS provides integration with MoMs
                .NET provides PInvoke (Platform                                      In .NET, the interoperability between
                Invoke):                                                             .NET languages is easy
         class PInvokeTest {
          [DllImport("user32.dll")]
                                                                                     • Use the same assemblies, class libraries…
          static extern int MessageBoxA(int hWnd, string m, string c, int t);        • Languages have to be adapted a little bit (e.g.
          static void Main(string[] args) {
                         MessageBoxA(0, "Hello DLL", "My Window", 0);                  Managed C++ does not provide multiple
          }                                                                            inheritance)
         }




                                                                                Bemerkungen
             Controlling Resouce Access                                            Access Control in Java

                                                                                     In Java access control is implemented
                                                                                     by the SecurityManager (delegates to
                                                                                     java.security.AccessController).
                                                                                     SecurityManager uses policy files. Use
                                                                                     policytool to create policies.
                                                                                     Permissions in policies control access to
                                                                                     resources. Customized permission types
                                                                                     possible.
                                                                                     Jar-files can be signed (keytool).




Dein Name – Dein Vortragstitel                                                                                                           Pra 01 - S. 23
Advanced Developers Conference
10.-11. Oktober 2004




           Access Control in .NET
                                                                      Access
                                                                   BemerkungenControl in .NET
                                                                      (cont‘d)
             Code Access Security                                       • Support in .NET Framework:
             • managed by CLR                                              - System.Security.Permissions
                                                                           - System.Security.Policy
             • Evidence-based security (works in tandem with
               Windows security).                                          - System.Security.Principal
             • Code Groups defined by membership condiions              • Permissions can be requested programmatically or
               such as zone, publisher, URL, site, publisher,             declaratively.
               strong name                                              • Configuration stored in XML-bsed .config files.
             • Tool caspol.exe (code access security tool) to           Role-Based Security
               administer code groups.                                  • Principal: user‘s identity can be Windows account,
             • Code Access Permissions and Permissions Sets               Passport account, ASP.NET cookie authentication
               specifies what assemblies are allowed to do.             • Roles according to technology used.
             • Policy Levels: User, Machine, Enterprise.




           Commonalities and                                       Bemerkungen
           Differences
                                                                      Mobile and Embedded

             Both approaches very similar.
             Differences in implementation of access
             control:
             • In .NET CLR collects evidence to grant or deny
               permissions.
             • In Java the SecurityManager is used by JVM to ask
               for permission.




                                                                   Bemerkungen
           Profiles and devices                                       Profiles and devices (cont‘d)

             There are the following variants of Java                   .NET Universe
                                                                        • .NET: Framework for Standard und Enterprise
             • J2SE (Java 2 Platform Standard Edition)                  • .NET Compact Framework for Windows CE (and other
             • J2EE (Java 2 Platform Enterprise Edition)                  embedded OS)
             • J2ME (Java 2 Platform Micro Edition)                        - Design Goals:
                                                                               > Resource saving
                - Configurations,                                              > Adaptability regarding device properties
                - and Profiles                                                 > Compatibility with the standard IDEs
             • JavaCard                                                        > Easy integration
                                                                               > Seamless connectivity
                                                                           - No ASP.NET, Reflection.Emit, Optimized JIT
                                                                           - Depending on machine stack
                                                                           - Simplified versioning and security, but similar
                                                                             formats




Dein Name – Dein Vortragstitel                                                                                               Pra 01 - S. 24
Advanced Developers Conference
10.-11. Oktober 2004




           Profiles and devices (cont‘d)                                       Tools
                                                                            Bemerkungen

             .NET Mobile Web Framework                                               Microsoft .NET applications are mainly
             •   Abstraction for the developer                                       developed using Microsoft‘s Visual
             •   Several markup languages (WML, HTML, ...)                           Studio .NET.
             •   Configurable and extendible                                         • Borland will also provide support (e.g., Sidewinder,
                                                                                       a C# IDE)
             •   ASP.NET can be used                                                 • Rational XDE support .NET
             •   Emulators for devices are available for testing and                 • Language implementers such as ISE, ActiveState
                 debugging purposes                                                    provide Visual Studio Plug Ins
                                                                                     Java tool support comes from many
             • Extends ASP.NET with special controls                                 different companies and organizations:
                                                                                     • Sun, Borland, BEA, Rational, IBM, Eclipse,
                                                                                       Compuware, ...




                                                                            Bemerkungen
           Open and Shared Source                                                 Selecting one of the two

             Microsoft .NET:
             • Shared Implementation (Rotor) available for BSD
               Unix and Windows.
             • Mono developed as open source to implement full
               .NRT support for Linux; still immature
             • Dot GNU will provide another open source
               approach; when will it arrive?
             Java:
             • Countless mature open source products available
                  - JBoss (EJB), OpenEJB, Eclipse, Apache (Tomcat,
                    Struts, ...), ....




                                                                            Bemerkungen
           .NET and/or Java ?                                                     .NET and/or Java ?
             .NET is a product, JVM/J2EE are specifications                          .NET language independence is not for free and
             Both adress the web (among other things)                                not completely transparent
             For „real big systems“ J2EE is better suited                    #pragma once
                                                                             using namespace System; // .NET mit C++
                                                                             namespace CPPBase {
             The rule-of-thumb „Java is platform-                             public __gc class CPPBaseClass {
                                                                               public: virtual System::String __gc* Echo(System::String __gc *s);
             independent,´.NET is language independent“                       };
                                                                             }
             must be considered carefully:                                   System::String __gc * CPPBase::CPPBaseClass::Echo(System::String __gc *s)
             • ECMA works on the standardization of C# and parts of .NET.    { return s; }
               However, only subset standardized. JCP (Java Community
               Process) works very efficiently.                                      In a real project you might want to use only
             • Other languages can be compiled to the JVM such as Jython,            one language
               ComponentPascal, Beta, ...
                                                                                     • But sometimes... ☺




Dein Name – Dein Vortragstitel                                                                                                               Pra 01 - S. 25
Advanced Developers Conference
10.-11. Oktober 2004




           .NET and/or Java ?                                       Noch Fragen?
                                                                 Bemerkungen

             Windows Applications are better done with
             .NET than Java (can Eclipse SWT change this?)
             Java should be used when platform (vendor-)
             independence is necessary
             Java is more mature, .NET is more modern
             There is also Java for .NET
             • But syntax is not the issue here!
             Both can be used for Web services - .NET is
             „nicer“, J2EE is more scalable
             Migration from COM to .NET seems to be a big
             issue.
             Analysts foresee a fifty/fifty situation for Java
             and .NET




                                                                 Bemerkungen



                                     Development for
                                     Professionals!




                                                                 Bemerkungen




Dein Name – Dein Vortragstitel                                                     Pra 01 - S. 26

						
Related docs