1.22k likes | 1.8k Views
CORBA and Java. by Alex Chaffee alex@jguru.com http://www.jguru.com/ Java online resources http://www.purpletech.com/ Java training and consulting. Abstract.
E N D
CORBA and Java • by Alex Chaffee • alex@jguru.com • http://www.jguru.com/ • Java online resources • http://www.purpletech.com/ • Java training and consulting Copyright © 1998 Purple Technology, Inc.
Abstract • 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. In this session, we examine the ways they interoperate programmatically, as we walk you step-by-step from a CORBA IDL, to a server and client both written in Java, running on top of a 100%-Java ORB. We also discuss the relationship between CORBA and RMI, and discuss some of the real-world issues involved in deploying a CORBA-based application. Recommended: some knowledge of CORBA, ability to read Java source code. Copyright © 1998 Purple Technology, Inc.
Introduction • Purple Technology • http://www.purpletech.com • Java Training and Consulting • Alex Chaffee • Creator of Gamelan • Cool Java Dude Copyright © 1998 Purple Technology, Inc.
Part I: CORBA Overview Copyright © 1998 Purple Technology, Inc.
What is CORBA? • Common Object Request Broker Architecture • Communication infrastructure for distributed objects • Allows a heterogeneous, distributed collection of objects to collaborate transparently Copyright © 1998 Purple Technology, Inc.
What is CORBA good for? • Developing distributed applications • Locating remote objects on a network • Sending messages to those objects • Common interface for transactions, security, etc. • CORBA Services (more later) Copyright © 1998 Purple Technology, Inc.
Why Distributed Applications? • Data is distributed • Administrative and ownership reasons • Heterogeneous systems • Shared by multiple applications • Scalability Copyright © 1998 Purple Technology, Inc.
Why Distributed Applications? • Computation is distributed • Scalability: multiprocessing • Take computation to data • Heterogeneous architectures • Users are distributed • Multiple users interacting and communicating via distributed applications Copyright © 1998 Purple Technology, Inc.
Distributed Object Systems • All entities are modeled as objects • Systems support location transparency • Interfaces, not implementations, define objects • Good distributed object systems are open, federated systems Copyright © 1998 Purple Technology, Inc.
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 Copyright © 1998 Purple Technology, Inc.
It’s Just A Spec • Has never been fully implemented • Probably never will be • Industry moves quickly and spec has to keep up • Interoperability vs. portability • Pass-by-value Copyright © 1998 Purple Technology, Inc.
Basic CORBA Architecture Server Client response request ORB ORB “Object Bus” Copyright © 1998 Purple Technology, Inc.
CORBA Objects • Examples • Service • Client • Component • Business object • CORBA objects approach universal accessibility • Any Language • Any Host on network • Any Platform Copyright © 1998 Purple Technology, Inc.
CORBA Elements • 1. ORB • 2. CORBA Services • 3. CORBA Facilities • 4. Application Objects Copyright © 1998 Purple Technology, Inc.
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 Copyright © 1998 Purple Technology, Inc.
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 Copyright © 1998 Purple Technology, Inc.
Network of ORBs • There’s an ORB on the server too • ORB receives request Copyright © 1998 Purple Technology, Inc.
IIOP • Internet Inter-Orb Protocol • Network or “wire” protocol • Works across TCP/IP (the Internet protocol) Copyright © 1998 Purple Technology, Inc.
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 Copyright © 1998 Purple Technology, Inc.
ORB Features • Local or remote • Same API wherever target object lives • Preserves context • Distributed security and transactions • Coexistence with legacy code • Just provide a wrapper object Copyright © 1998 Purple Technology, Inc.
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 Copyright © 1998 Purple Technology, Inc.
IDL • Interface Definition Language • Defines protocol to access objects • Like a contract • Well-specified • Language-independent Copyright © 1998 Purple Technology, Inc.
IDL Example module Calc { interface Adder { long add(in long x, in long y); } } • Defines an object called Adder with a method called add Copyright © 1998 Purple Technology, Inc.
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 Copyright © 1997 Alex Chaffee
Stubs and Skeletons (Fig.) Client Host Machine Server Host Machine Client Object Remote Object Stub Skeleton IIOP ORB ORB Copyright © 1997 Alex Chaffee
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 Copyright © 1998 Purple Technology, Inc.
Different Meanings of “Server” • Host machine • Program running on host machine • CORBA object running inside program • has IDL, stub, skeleton • Sometimes called a Servant Copyright © 1998 Purple Technology, Inc.
Stubs and Skeletons -> Platform Independence • Client code has no knowledge of the implementation of the object or which ORB is used to access the implementation. Copyright © 1998 Purple Technology, Inc.
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 Copyright © 1998 Purple Technology, Inc.
CORBA Services • 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 Copyright © 1998 Purple Technology, Inc.
CORBA Services • Security Service • Authentication, ACLs, encryption, etc. • Event Service • Uncoupled notifications Copyright © 1998 Purple Technology, Inc.
CORBA Services • Relationship • Externalization • Query • Licensing • Properties • Time • Trader • Collection • … and so on… • See what I mean about it never being implemented? Copyright © 1998 Purple Technology, Inc.
CORBA Facilities • Frameworks for specialized applications • Distributed Document Component Facility • OpenDoc • In progress: • Agents • Business Objects • Internationalization Copyright © 1998 Purple Technology, Inc.
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 Copyright © 1998 Purple Technology, Inc. (after diagram in Orfali et al.)
User Interface Tier Business Logic Tier Data Storage Tier Can use CORBA objects in each tier Three Tiers Copyright © 1998 Purple Technology, Inc.
Part II: Java IDL - Using CORBA from Java Copyright © 1998 Purple Technology, Inc.
Java CORBA Products • The Java 2 ORB • VisiBroker for Java • OrbixWeb • Netscape Communicator • Various free or shareware ORBs Copyright © 1998 Purple Technology, Inc.
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 Copyright © 1998 Purple Technology, Inc.
Transparent API • JavaIDL turns IDL into direct method calls • Easy to program • Clients have no knowledge of implementation • Highly portable Copyright © 1998 Purple Technology, Inc.
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 Copyright © 1998 Purple Technology, Inc.
Other Java ORBs • Visigenic (Inprise) VisiBroker • Netscape Communicator • Oracle Web Server 3.0 • Free download • Iona OrbixWeb Copyright © 1998 Purple Technology, Inc.
IDL to Java Mapping • Defined by OMG • Translates IDL concepts into Java language constructs • Everything is accessible by writing normal-looking Java code Copyright © 1998 Purple Technology, Inc.
IDL to Java Type Mapping IDL Type boolean char / wchar octet short / unsigned short long / unsigned long long long / unsigned long long float double string / wstring Java Type boolean char byte short int long float double String Copyright © 1998 Purple Technology, Inc.
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 Copyright © 1998 Purple Technology, Inc.
IDL Modules • Map to Java packages • Unfortunately, it has the root level name of the module • Clutters up your package hierarchy • e.g. module Calc -> • package Calc • interface Calc.Adder • not package ORG.omg.CORBA.modules.Calc Copyright © 1998 Purple Technology, Inc.
IDL Interfaces • Map to Java interfaces Copyright © 1998 Purple Technology, Inc.
IDL Operations • Map to Java methods Copyright © 1998 Purple Technology, Inc.
IDL Attributes • Map to pair of functions • IDL • string name; • Java • public void name(String val); • public String name(); • Yes, it looks stupid. Sorry. Copyright © 1998 Purple Technology, Inc.
idltojava • Development tool • Automatically generates java stubs, skeletons, helpers, holders, ... • Generates stubs for specific remote interfaces Copyright © 1998 Purple Technology, Inc.
Stubs • Java objects call stub methods • Stubs communicate with CORBA objects • and vice versa • Transparent integration Copyright © 1998 Purple Technology, Inc.