240 likes | 359 Vues
Introduction. CORBA loves Java! CORBA provides a platform-independent, language-independent way to write applications that can invoke objects that live across the room or across the planet.
E N D
Introduction • CORBA loves Java! • CORBA provides a platform-independent, language-independent way to write applications that can invoke objects that live across the room or across the planet. • Java is an object-oriented language that's ideal for writing the clients and servers living on the Object Bus.
What is CORBA? • Common Object Request Broker Architecture • Communication infrastructure for distributed objects • Allows a heterogeneous, distributed collection of objects to collaborate transparently What is the OMG? • Designers of CORBA • Consortium of 700+ companies • Not including Microsoft • Members: • platform vendors • database vendors • software tool developers • corporate developers • software application vendors
Basic CORBA Architecture Server Client response request ORB ORB “Object Bus”
CORBA Objects • Examples • Service • Client • Component • Business object • CORBA objects approach universal accessibility • Any Language • Any Host on network • Any Platform CORBA Elements • ORB • CORBA Services • CORBA Facilities • Application Objects
ORB • Object Request Broker • “Object Bus” • Handles all communication among objects • Each host (machine) has its own ORB • ORBs know how to talk to each other • ORB also provides basic services to client ORB Responsibilities • Find the object implementation for the request • Prepare the object implementation to receive the request • Communicate the data making up the request • Retrieve results of request
IIOP • Internet Inter-Orb Protocol • Network or “wire” protocol • Works across TCP/IP (the Internet protocol) What is an ORB really? • Not a separate process • Library code that executes in-process • Listens to TCP ports for connections • One port per local object • Opens TCP sockets to other objects • N ports per remote machine
ORB Features • Method invocations • Static and Dynamic • Remote objects or CORBA services • High-level language bindings • Use your favorite language; ORB translates • Self-describing • Provides metadata for all objects and services • Local or remote • Same API wherever target object lives • Preserves context • Distributed security and transactions • Coexistence with legacy code • Just provide a wrapper object
IDL • Interface Definition Language • Defines protocol to access objects • Like a contract • Well-specified • Language-independent IDL Example module Calc { interface Adder { long add(in long x, in long y); } } • Defines an object called Adder with a method called add
Stubs and Skeletons • Stub • lives on client • pretends to be remote object • Skeleton • lives on server • receives requests from stub • talks to true remote object • delivers response to stub Client vs. Server • in CORBA, a client is a client relative to a particular object • i.e. an object with a reference to a “server” object • A client may also act as a server • If it has an IDL and stubs and skeletons • Technically, a CORBA server contains one or more CORBA objects
Stubs and Skeletons Client Host Machine Server Host Machine Client Object Remote Object Stub Skeleton ORB ORB IIOP
CORBA Services • APIs for low-level, common tasks • Life Cycle Service • creating, copying, moving, removing objects • Naming Service • Register objects with a name • Look up objects by name • Concurrency Control Service • Obtain and release exclusive locks • Transaction Service • Two-phase commit coordination • Supports nested transactions • Persistence Service • Storing objects in a variety of databases • RDBMS, OODBMS, file systems • Relationship • Externalization • Query • Licensing • Security Service • Authentication, ACLs, encryption, etc. • Event Service • Uncoupled notifications
CORBA Facilities • Frameworks for specialized applications • Distributed Document Component Facility • OpenDoc • In progress: • Agents • Business Objects • Internationalization Three Tiers • User Interface Tier • Business Logic Tier • Data Storage Tier • Can use CORBA objects in each tier
ORB ORB ORB ORB N-Tier Design with CORBA Storage “Tier” DB ORB ORB DB Data Object ORB TP Monitor ORB ORB Service “Tier” Business Object Tier Client Tier
Java CORBA Products Java IDL - Using CORBA from Java • The Java 2 ORB • VisiBroker for Java • OrbixWeb • Netscape Communicator • Various free or shareware ORBs Java IDL • Should be named “Java CORBA” • More than just IDL • Full implementation of CORBA in 100% Java • Three Parts • ORB • Naming Service • idltojava compiler • Ships with JDK 1.2
The Java ORB • 100% Java • Generic • Allows Java IDL applications to run either as stand-alone Java applications, or as applets within Java-enabled browsers • Uses IIOP Other Java ORBs • Visigenic (Inprise) VisiBroker • Netscape Communicator • Oracle Web Server 3.0 • Free download • Iona OrbixWeb
IDL to Java Type Mapping Java Type boolean char byte short int long float double String IDL Type boolean char / wchar octet short / unsigned short long / unsigned long long long / unsigned long long float double string / wstring IDL vs. Java vs. C++ concepts IDLJavaC++ module package namespace interface interface abstract class operation method member function attribute pair of pair of methods functions
IDL Modules • Map to Java packages • It has the root level name of the module • Clutters up the package hierarchy • e.g. module Calc -> • package Calc • interface Calc.Adder • not package ORG.omg.CORBA.modules.Calc IDL Attributes • Map to pair of functions • IDL • string name; • Java • public void name(String val); • public String name();
idltojava • Development tool • Automatically generates java stubs, skeletons, helpers, holders, ... • Generates stubs for specific remote interfaces Skeletons • Java objects call stub methods • Stubs communicate with CORBA objects • and vice versa • Transparent integration Stubs • ORB passes request to skeleton (like a stub) • Skeleton calls local implementation
Remote Interfaces and Stubs IDL Interface implements implements extends Client Stub Skeleton Remote Object (Server)
idltojava input • Calc.idl module Calc { interface Adder { long add(in long x, in long y); } } idltojava output • idltojava Calc.idl • Adder.java (a Java interface that maps the IDL interface) • _AdderStub.java (a client stub) • _AdderImplBase.java (a server skeleton) • AdderHelper.java (a helper class) • AdderHolder.java (a holder class) • Must compile these files and put them in the CLASSPATH
CORBA Flow Client Virtual Machine Server Virtual Machine Client Remote Object Skeleton Stub Server “Fred” Name Server Virtual Machine
CORBA Flow Client Virtual Machine Server Virtual Machine 1. Server Creates Remote Object2. Server Registers Remote Object Client Remote Object 1 Skeleton Stub Server 2 “Fred” Name Server Virtual Machine
CORBA Flow Client Virtual Machine Server Virtual Machine 3. Client requests object from Name Server 4. Name Server returns remote reference (and stub gets created) Client Remote Object Skeleton Server Stub 3 4 “Fred” Name Server Virtual Machine
RMI Flow Client Virtual Machine Server Virtual Machine 5. Client invokes stub method 6. Stub talks to skeleton 7. Skeleton invokes remote object method Client Remote Object 5 7 Skeleton 6 Stub Server “Fred” Name Server Virtual Machine