Advanced Developers Conference
10.-11. Oktober 2004




                                                                Ag...
Advanced Developers Conference
10.-11. Oktober 2004




           Layers                                                 ...
Advanced Developers Conference
10.-11. Oktober 2004




              The .NET Framework Class
                           ...
Advanced Developers Conference
10.-11. Oktober 2004




           Object Model (Java)                                    ...
Advanced Developers Conference
10.-11. Oktober 2004




             .NET-Types that are not                              ...
Advanced Developers Conference
10.-11. Oktober 2004




                                                                  ...
Advanced Developers Conference
10.-11. Oktober 2004




                                                                  ...
Advanced Developers Conference
10.-11. Oktober 2004




           Server Components in Java
                             ...
Advanced Developers Conference
10.-11. Oktober 2004




           Using COM Components in
                               ...
Advanced Developers Conference
10.-11. Oktober 2004




           Ports And Channels                                     ...
Advanced Developers Conference
10.-11. Oktober 2004




           [Service]                                              ...
Advanced Developers Conference
10.-11. Oktober 2004




           Database Access in .NET                                ...
Advanced Developers Conference
10.-11. Oktober 2004




           XML and .NET (cont‘d)                                  ...
Advanced Developers Conference
10.-11. Oktober 2004




            Example (cont‘d)                                      ...
Advanced Developers Conference
10.-11. Oktober 2004




            Java Server Pages and
                                ...
Advanced Developers Conference
10.-11. Oktober 2004




             ASP.NET Example (cont‘d)                             ...
Tutorial on J2EE versus .NET for .NET Programmers
Tutorial on J2EE versus .NET for .NET Programmers
Tutorial on J2EE versus .NET for .NET Programmers
Tutorial on J2EE versus .NET for .NET Programmers
Tutorial on J2EE versus .NET for .NET Programmers
Tutorial on J2EE versus .NET for .NET Programmers
Tutorial on J2EE versus .NET for .NET Programmers
Tutorial on J2EE versus .NET for .NET Programmers
Tutorial on J2EE versus .NET for .NET Programmers
Tutorial on J2EE versus .NET for .NET Programmers
Upcoming SlideShare
Loading in …5
×

Tutorial on J2EE versus .NET for .NET Programmers

2,798 views

Published on

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,798
On SlideShare
0
From Embeds
0
Number of Embeds
30
Actions
Shares
0
Downloads
238
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Tutorial on J2EE versus .NET for .NET Programmers

  1. 1. 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)? In this talk we will try to cover most Interoperability issues 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
  2. 2. Advanced Developers Conference 10.-11. Oktober 2004 Layers Bemerkungen is What 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 platform - Component model - Database access J2EE Blueprints Describes how to construct J2EE applications (including JAVA Pet Store) - XML - Server Pages Compatibility Testsuite Validates J2EE platform compatibility to guarantee code portability and eliminate - Remoting 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) Multi-tier Architecture Bemerkungen J2EE „standard“ Services 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
  3. 3. Advanced Developers Conference 10.-11. Oktober 2004 The .NET Framework Class The Runtime System Bemerkungen Library In .NET we distinguish between .NET Framework and .NET CF CLR System.Web System.Windows.Forms Services UI Design ComponentModel Description HtmlControls Base Class Library Support Discovery WebControls Protocols System.Drawing Thread Support COM Marshaler Caching Security Drawing2D Printing Type Checker Exception Manager Configuration SessionState Imaging Text System.Data System.Xml Security Engine Debug Engine ADO SQL XSLT Serialization Design SQLTypes XPath IL to Native Code Garbage Compilers Manager Collector System Collections IO Security Runtime InteropServices Configuration Net ServiceProcess Class Loader Remoting Diagnostics Reflection Text Serialization Globalization Resources Threading Bemerkungen Java Virtual Machine .NET Runtime It is called the Common Language Runtime (CLR) The JVM targets Java and interprets Java Byte Code. It supports all languages compiled for the MSIL Other languages can also be compiled to Java bytecode (e.g. Provides integration for several languages Ada) Provides support for non-OO languages (e.g. tail Just-in-Time compilers exist for different environments and recursion) OSs C# Compiler Compiler VB.NET CLASS- Java Classloader/ MSIL + JIT Loader/ Files Verifier JIT Metadata Verifier C++‘ Garbage Garbage Native Interpreter Managed Collection, Collection, Execution Code Perl Security Manager Security, Code Call-in+Call-out, Multithreading, Multithreading, Hotspot ... ... Differences and Bemerkungen The Object Model Commonalities 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
  4. 4. 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(); public final void notifyAll(); Arrays Interfaces public String toString(); public final void wait() throws InterruptedException; Classes 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 Self-describing Types Types 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) .NET distinguishes between values types The „mother of all .NET classes“ and reference types: public class Object { • value types reside on the stack public virtual int GetHashCode(); • reference types reside on the heap public virtual bool Equals(); public virtual String ToString(); There is no difference between primitive public static bool Equals(object a, object b); types and classes public static bool ReferenceEquals(object a, • Automatic boxing/unboxing provides transparency object b); public Type GetType(); Special strongly-typed function protected object MemberWiseClone(); references protected virtual Finalize()´; • called delegates } • and events Dein Name – Dein Vortragstitel Pra 01 - S. 4
  5. 5. 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 ) { Jagged (arrays of arrays) and unjagged // do something useful } Arrays: public Sub(Pub thePub) { thePub.OnLightTurnedOn += new Pub.LightTurnedOn(somebodyTurnedOnTheLight); int [2][] a; a[0] = new int[]{1}; a[1] = new int[]{1,2}; } // ... int [,] a = new int[2,2]; } Structs (value types): class Pub { public delegate void LightTurnedOn(int ID); • Structs are implicitly sealed: public event LightTurnedOn OnLightTurnedOn; public struct not support inheritance • they do String First; Name { public void SomeoneTurnsOntheLight() { public OnLightTurnedOn(myID); public String Last; } // ... } } Commonalities and Bemerkungen Metainformation Differences Commonalities: Java and .NET provide a reflection API • Interfaces are „completely abstract classes“ • to load, execute, and instantiate classes • Both support single inheritance for classes (implementation inheritance) and multiple interface inheritance • and inspect classes (introspection). • Default-Initialization of variables • Namespace-Concept (Java-Package and .NET-Namespace) • Similar visibility attributes (public, private, ...) In addition, .NET allows to annotate • Generic types in .NET and Java (Generics) but .NET Generics much more flexible and available as runtime entities many aspects of a system (classes, • Class constructors (static initializers in Java) 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 { ... } • There are several predefined attributes import java.lang.reflect.*; (WebService, WebMethod, ...) try { Class c = Class.forName(„MyPrintComponent“); Object o = c.newInstance(); Defining an Attribute Method m = c.getMethod(„print“, new Class[]{ String.class }); m.invoke(o, new Object[]{„Hallo, Java!“}); [AttributeUsage(AttributeTargets.All] } public class AuthorIsAttribute : Attribute { catch (Exception e) { private string m_Name; // handle it here } public AuthorIsAttribute(string name) { m_Name = name;} } Dein Name – Dein Vortragstitel Pra 01 - S. 5
  6. 6. Advanced Developers Conference 10.-11. Oktober 2004 Commonalities and .NET Example (cont‘d) Bemerkungen Differences Accessing and using Type information Commonalities: • Very similar APIs using System; using System.Reflection; Differences: namespace ComponentClient { • .NET allows additional, user-defined meta class Client { information with attributes. This will also be static void Main(string[] args) { possible in Java using a similar approach. Assembly a = Assembly.LoadFrom(quot;Component.dllquot;); Type [] allTypes = a.GetTypes(); • Java Reflection is sometimes a bit more clumsy Type t = allTypes[0]; (because of primitive types and classes) object o = Activator.CreateInstance(t); MethodInfo mi = t.GetMethod(quot;algorithmquot;); • .NET allows to actually create new artifacts at double d = (double) mi.Invoke(o, new object[]{21.0}); 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 Exceptions in .NET for (ElementType: ContainerType) in 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
  7. 7. 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 the language. Different design philosophies class GlobalData { • Java provides better synchronization and thread int m_Value; communication (wait, notify, ...). public int Value { set { lock(this) { m_Value = value; } } } } • In .NET it is much easier to create a thread from class Worker { any method. Only precondition: method with no GlobalData m_Global; public Worker(GlobalData global) {m_Global = global; } result and no arguments. public void loop() { m_global.Value = 42; Thread.Sleep(100); } } // somewhere else: GlobalData g = new GlobalData(); Thread t = new Thread(new ThreadStart(new Worker().loop)); t.Start(); t.Join(); 1 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 Enterprise JavaBeans (EJBs) always Client Components and Server reside in a container that hides technical Components aspects (sep. of concerns) JavaBeans are Client Components JNDI Naming • normal Java classes following some conventions Deployment Service Descriptor 1) lookup home • optionally providing metainformation (BeanInfo EJB class) EJB Context EJB Home 2) create bean Jar 2”) find bean Remote Bean Home Interface public class MyJavaBean { new 4 Client private int color; EnterpriseBean public void setColor(int v) { color = v; } ejbCreate Bean EJB ejb... Instance 4) remove Object public int getColor() { return color; } bean-methods 3) Use bean Remote Bean // a lot of more ... Interface } EJB Run-time Application Server (Container) // BeanInfo class not shown here! Dein Name – Dein Vortragstitel Pra 01 - S. 7
  8. 8. Advanced Developers Conference 10.-11. Oktober 2004 Server Components in Java OSGi Bemerkungen cont‘d 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 bundles. • Message-Driven Beans (asynch. Service 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 Files Types Manifest component is Referenced version Hash Security Assemblies Custom Product Attributes Information very different Type 1 Metadata from that used IL-Code Type 2 with EJB or Module 1 IL-Code Type 3 COM+ IL-Code Resources Bemerkungen Server-Side Components Component Model in .NET Now Component is used like in EJB Private Assemblies are typically only 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
  9. 9. Advanced Developers Conference 10.-11. Oktober 2004 Using COM Components in COM Callable Wrapper Bemerkungen .NET 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 CCW .NET COM .NET Client Wrapper Component .NET RCW COM .NET COM Client Wrapper Component Future of Distributed .NET: Bemerkungen Indigo Architecture Indigo Messaging Services Service Model Indigo (part of Longhorn) provides common Queuing framework for connected systems (SOA) Declarative Transacted Instance Context Service Type Integration Behaviors Methods Manager Manager Methods • Integrates Web services, .NET Remoting, MSMQ Routing • Extensible Architecture Communication Eventing • Vertical functionality such as security integrated in Indigo Policy Channels 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 Transaction Communications Manager (Port) anding/pillars/Indigo/default.aspx Federation Hosting Environments ASP.NET .container .exe NT Service DllHost … Ports, Channels, Services, Bemerkungen Indigo Connectors 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
  10. 10. Advanced Developers Conference 10.-11. Oktober 2004 Ports And Channels Port/Channel Architecture Bemerkungen 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 Service Mgmt APIs MMC Plugins Service Tools (adsutil, etc) Model Send() Receive() Model Extensions Extensions Proxy Session Process Management W3SVC Metabase Components Port B Port A http.sys TcpListener Mail Listener IPC Listener Listeners Transport Channels Channels Extensions Extensions Dein Name – Dein Vortragstitel Pra 01 - S. 10
  11. 11. Advanced Developers Conference 10.-11. Oktober 2004 [Service] [RemoteObject] Bemerkungen Service-Oriented Object-Oriented [Service] [RemoteObject] public class Hello public class RemObj : MarshalByRefObject Programming Model Programming Model { { [ServiceMethod] public RemObj() { Opt-In Contract Contract based on private string Greeting(string name) Console.WriteLine( public visibility Schema-based { quot;Object {0} has been created.quot;, return String.Format(quot;Hello, {0}!quot;, name); this.GetHashCode().ToString()); integration DLL-based integration } } Broad interop No Interop public string Salutation (string name) public string Hello(string name) { { return Like .NET Remoting, return String.Format(“Howdy, {0}!”, name); String.Format(quot;Hello, {0}!”, name); CLR-focused } } } ~RemObj() { Console.WriteLine( quot;Object {0} is being torn down.quot;, this.GetHashCode().ToString()); } } Commonalities and Bemerkungen Database Access in Java Differences 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: Prepared • EJB are a more mature and proven model 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 ODBC Driver execution) • 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 There are several other APIs: import java.sql.*; // without error handling: • Embedded SQL with SQLJ (uses JDBC internally) Class.forName(„sun.jdbc.odbc.JdbcOdbcDriver“); • Proprietary ODBMS APIs Connection con=DriverManager.getConnection(„jdbc:odbc:stocks,““,““); • Standardized JDO API to provide (more or less Statement stmt = con.CreateStatement(); transparent) persistence for Java Objects ResultSet rs = stmt.executeQuery(„SELECT * from stocks“); • XML is handled differently! while (rs.next()) { System.out.println(rs.getString(„COMPANYNAME“)); • Java Connector API provides access to other } „connection oriented“ legacy systems (such as SAP rs.close(); R3) stmt.close(); con.close(); Dein Name – Dein Vortragstitel Pra 01 - S. 11
  12. 12. 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) • DataSet dnymically builds an XML schema inside to store the • “connectionless” Client data • Relational data and XML data can be handled in a similar way!! DataSet ADO.NET works offline once the data is fetched • Updating is partly automatic using DataSets Command DataSetCommand DataReader Currently there are three Managed Providers: • SQL Server • ADO Connection Managed Provider • Oracle Data Source Commonalities and Bemerkungen XML Differences 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 .NET is very XML-centric • DOM, SAX • Web Services (SOAP) • Xerces/Xalan, JDOM • JAX{M,B,R,RPC} • Configuration Files • Castor • Result sets of a database access (ADO.NET) However, Java‘s libraries have not beed designed • XML processing itself with XML as a basis (Java‘s too old ☺) JAXP (Java API for XML Parsing) supports DOM and SAX). Note that formally, many .NET features Currently under development are based on the XML infoset („XML • JAXM (Java API for XML Messaging) semantics“) and do not necessarily • JAXB (Java API for XML Data Binding) • JAXR (Java API for XML Registries) require megabytes of text data!! • JAX/RPC (Java API for XML based RPC) Dein Name – Dein Vortragstitel Pra 01 - S. 12
  13. 13. 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 manually or automatically. • RMI can use JRMP or IIOP as a transport protocol On demand activation possible. • Not easily pluggable – changes in the code are 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. Other protocols by imlementing proprietary Remote Reference Manager Socket factories. Transport Layer Bemerkungen Example Example (cont‘d) Exeptions and interface definitions Implementation of remote object: import java.rmi.*; // file: BoundaryException.java 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
  14. 14. Advanced Developers Conference 10.-11. Oktober 2004 Example (cont‘d) Example (cont‘d) Bemerkungen 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(quot;gridquot;); public static void main(String args[]) throws g.setValue(4,4, new Integer(42)); Exception { Integer i = (Integer) g.getValue(4,4); System.out.println(i); GridImpl svr = new GridImpl(); g.setValue(33,33, new Integer(88)); Naming.rebind(quot;gridquot;, svr); } System.out.println(quot;readyquot;); catch (BoundaryException b) { System.out.println(quot;Boundary violationquot;); } } } catch (Exception e) { System.out.println(e); } } } Bemerkungen Remoting in .NET Remoting in .NET (cont‘d) .NET Remoting provides pluggable transports and formatters Application Domain A Application Domain B • currently TCP and HTTP transport and • binary and SOAP formatters Client Servant Contexts are automatically propagated (very neat feature!!) Only very simple lifecycle management Transparent Proxy Object Context Sinks options for servants (compared to EJB or Real Proxy Server Context Sinks Envoy Sinks CORBA) Channels Channels Network • Singleton (one object for all calls) Formatters Formatters • SingleCall (new instance for each call) • Client-Activated based on leases Commonalities and Bemerkungen Web Differences 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
  15. 15. Advanced Developers Conference 10.-11. Oktober 2004 Java Server Pages and Java Example Bemerkungen Servlets Java allows for server-side scripting • JSPs are based on Servlets Other (1) get a.jsp (2) process Components Web JSP 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 JSPs (Java Server Pages) are scripted Web package MyPackage; pages transformed to servlets. import java.lang.*; Taglibs allow to integrate additional html/xml- public class MyPerson { ike tags. public String getFirstName() { return quot;Michaelquot;; } public String getLastName() { return quot;Stalquot;; } Java ServerFaces use taglibs to provide Web } components. // Datei MyTest.jsp: <HTML> <BODY> Apache Struts provides a framework for <jsp:useBean id=quot;personquot; scope=quot;sessionquot; implementing MVC applications. class=quot;MyPackage.MyPersonquot;/> Your name is: <br> <jsp:getProperty name=quot;personquot; property=quot;firstNamequot;/> <br> <jsp:getProperty name=quot;personquot; property=quot;lastNamequot;/> </BODY> </HTML> ASP.NET Bemerkungen ASP.NET Example (Server-Side Scripting) ASP.NET Architecture: A simple login screen: Other IIS 5 (1) get a.apx (2) process .NET Assemblies Web Client Assembly Server (4) HTTP file .NET Engine (3) result Database Dein Name – Dein Vortragstitel Pra 01 - S. 15
  16. 16. Advanced Developers Conference 10.-11. Oktober 2004 ASP.NET Example (cont‘d) ASP.NET Example (cont‘d) Bemerkungen <%@ Page language=quot;c#quot; Codebehind=quot;WebForm1.aspx.csquot; // lot of details omitted AutoEventWireup=quot;falsequot; Inherits=quot;LoginPage.WebForm1quot; %> namespace LoginPage { <!DOCTYPE HTML PUBLIC quot;-//W3C//DTD HTML 4.0 Transitional//ENquot; > public class WebForm1 : System.Web.UI.Page { <HTML> protected TextBox PasswordText, LoginText; <body> protected Button EnterButton; <form id=quot;Form1quot; method=quot;postquot; runat=quot;serverquot;> protected Label MessageLabel; <asp:Label id=quot;TitleLabelquot; runat=quot;serverquot;>Please specify your name and private void InitializeComponent() { password</asp:Label> <br> this.EnterButton.Click += <asp:Label id=quot;LoginLabelquot; runat=quot;serverquot;>Login</asp:Label> <br> new System.EventHandler(this.EnterButton_Click); <asp:TextBox id=quot;LoginTextquot; runat=quot;serverquot;></asp:TextBox> this.Load += new System.EventHandler(this.Page_Load); <asp:RequiredFieldValidator id=quot;RequiredFieldValidatorquot; runat=quot;serverquot; } ErrorMessage=quot;You need to specify your namequot; private void EnterButton_Click(object sender, System.EventArgs e) { ControlToValidate=quot;LoginTextquot;></asp:RequiredFieldValidator> <br> if (!(LoginText.Text.Equals(quot;aladdinquot;) && <asp:Label id=quot;PasswordLabelquot; runat=quot;serverquot;>Password</asp:Label> <br> PasswordText.Text.Equals(quot;sesamquot;))) { <asp:TextBox id=quot;PasswordTextquot; runat=quot;serverquot; MessageLabel.Text = quot; Wrong name or password!quot;; TextMode=quot;Passwordquot;></asp:TextBox> <br> } <asp:Button id=quot;EnterButtonquot; runat=quot;serverquot; Text=quot;Open the entrancequot; else { ToolTip=quot;Press this after you have specified login and Session[quot;userquot;] = quot;aladdinquot;; passwordquot;></asp:Button> <br> Response.Redirect(quot;UserArea.aspxquot;); <asp:Label id=quot;MessageTextquot; runat=quot;serverquot;></asp:Label> } </form> } </body> } </HTML> } Commonalities and Bemerkungen XML Web Services Differences 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 Services Architectures and Web 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

×