corba-and-java_edited
Download
Report
Transcript corba-and-java_edited
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.
1
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
2
Basic CORBA Architecture
Server
Client
response
request
ORB
ORB
“Object Bus”
3
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
4
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
5
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
6
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
7
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
8
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
9
Stubs and Skeletons
Client Host Machine
Server Host Machine
Client
Object
Remote
Object
Stub
Skeleton
ORB
IIOP
ORB
10
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
• Security Service
– Authentication, ACLs, encryption, etc.
• Event Service
– Uncoupled notifications
•Relationship
•Externalization
•Query
•Licensing
11
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
12
N-Tier Design with CORBA
Storage “Tier”
ORB
DB
ORB
ORB
ORB
DB
Data Object
ORB
ORB
ORB
ORB
Client Tier
TP Monitor
ORB
Business Object
Tier
Service “Tier”
13
Java IDL - Using CORBA from Java
Java CORBA Products
•
•
•
•
•
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
14
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
15
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
IDL vs. Java vs. C++ concepts
IDL
module
Java
package
C++
namespace
interface
interface
abstract
class
operation
method
member
function
attribute
pair of
methods
pair of
functions
16
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();
17
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
18
Remote Interfaces and Stubs
IDL Interface
implements
implements
extends
Client
Stub
Skeleton
Remote Object
(Server)
19
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
20
CORBA Flow
Client Virtual Machine
Server Virtual Machine
Client
Remote
Object
Skeleton
Stub
Server
“Fred”
Name Server Virtual Machine
21
CORBA Flow
Client Virtual Machine
Server Virtual Machine
1. Server Creates Remote Object
Client2. Server Registers Remote Object
Remote
Object
1
Skeleton
Stub
Server
2
“Fred”
Name Server Virtual Machine
22
CORBA Flow
Client Virtual Machine
Server Virtual Machine
3. Client requests object from
Client Name Server
4. Name Server returns remote
reference
(and stub gets created)
Skeleton
Stub
3
Remote
Object
Server
4
“Fred”
Name Server Virtual Machine
23
RMI Flow
Client Virtual Machine
Server Virtual Machine
5. Client invokes stub method
Client 6. Stub talks to skeleton
7. Skeleton invokes remote object
method
5
Remote
Object
7
6
Stub
Skeleton
Server
“Fred”
Name Server Virtual Machine
24