Professional Documents
Culture Documents
by
online resources
http://www.purpletech.com/
Java
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 stepby-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.
Introduction
Purple
Java
Technology
Training and Consulting
http://www.purpletech.com
Alex
Chaffee
Creator
What is CORBA?
Common
Object Request Broker Architecture Communication infrastructure for distributed objects Allows a heterogeneous, distributed collection of objects to collaborate transparently
distributed applications Locating remote objects on a network Sending messages to those objects Common interface for transactions, security, etc.
CORBA
is distributed
Administrative
is distributed
are distributed
Multiple
entities are modeled as objects Systems support location transparency Interfaces, not implementations, define objects Good distributed object systems are open, federated systems
including Microsoft
vendors
Members:
platform database software
vendors
developers
tool developers
corporate software
application vendors
never been fully implemented Probably never will be Industry moves quickly and spec has to keep up
Interoperability Pass-by-value
vs. portability
request
CORBA Objects
Examples
Service Client Component Business
object
CORBA
Any
CORBA Elements
1.
ORB
Object
Request Broker
Bus
Object
Handles
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
Network of ORBs
Theres
IIOP
Internet
Inter-Orb Protocol Network or wire protocol Works across TCP/IP (the Internet protocol)
ORB Features
Method
Static
invocations
language bindings
your favorite language; ORB translates metadata for all objects and
Self-describing
Provides
services
ORB Features
Local
or remote
API wherever target object lives
Same
Preserves
context
security and transactions
Distributed
Coexistence
Just
a separate process Library code that executes in-process Listens to TCP ports for connections
One
Opens
N
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
on server receives requests from stub talks to true remote object delivers response to stub
Copyright 1997 Alex Chaffee
Stub
Skeleton
ORB
IIOP
ORB
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
Technically,
machine Program running on host machine CORBA object running inside program
has
code has no knowledge of the implementation of the object or which ORB is used to access the implementation.
CORBA Services
APIs
objects
Naming
Service
Register
CORBA Services
Concurrency
Obtain
Control Service
Transaction
Two-phase
Service
Service
CORBA Services
Security
Event
Service
ACLs, encryption, etc.
Authentication,
Service
notifications
Uncoupled
CORBA Services
Relationship
Externalization
and so on
See
what I mean about it never being Copyright 1998 Purple Technology, Inc implemented?
CORBA Facilities
Frameworks
In
progress:
Agents Business
Objects Internationalization
DB
ORB ORB ORB
DB
ORB
Data Object
ORB
TP Monitor
ORB ORB
ORB
Client Tier
Service Tier
Three Tiers
User
Interface Tier Business Logic Tier Data Storage Tier Can use CORBA objects in each tier
Java 2 ORB VisiBroker for Java OrbixWeb Netscape Communicator Various free or shareware ORBs
Java IDL
Should
More
Parts
Transparent API
JavaIDL
Java Generic Allows Java IDL applications to run either as stand-alone Java applications, or as applets within Java-enabled browsers Uses IIOP
(Inprise) VisiBroker
Netscape
OrbixWeb
by OMG Translates IDL concepts into Java language constructs Everything is accessible by writing normal-looking Java code
Java package
C++ namespace
interface abstract class method pair of methods member function pair of functions
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 1998 Purple Technology, Inc Copyright
IDL Interfaces
Map
to Java interfaces
IDL Operations
Map
to Java methods
IDL Attributes
Map
IDL
string
to pair of functions
name;
Java
public
idltojava
Development
tool Automatically generates java stubs, skeletons, helpers, holders, ... Generates stubs for specific remote interfaces
Stubs
Java
vice versa
Transparent
integration
Skeletons
ORB
implements
implements
extends
Client
Stub
Skeleton
here it comes...
idltojava input
Calc.idl
idltojava output
idltojava
Calc.idl
Must
compile these files and put them in your CLASSPATH Copyright 1998 Purple Technology, Inc
Adder.java
Created
for you by idltojava package Calc; public interface Adder extends org.omg.CORBA.Object { int add(int x, int y); }
Implementing a server
Extend
base class
all methods declared in IDL
Implement
Provide
Create
a main method
an ORB instance Create a server instance Inform the ORB about the instance Acquire a Naming Context Register the instance in that Naming Context under some name Copyright 1998 Purple Technology, Inc
AdderServer.java
class AdderServer extends _AdderImplBase { public int add( int x, int y ) { System.out.println(x + " + " + y + " = " + (x+y)); return x + y; }
AdderServer.java (cont.)
public static void main(String args[]) { // create and initialize the ORB ORB orb = ORB.init(args, null); // create server and register it with the ORB AdderServer adderRef = new AdderServer(); orb.connect(adderRef);
AdderServer.java (cont.)
// get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameSer vice"); NamingContext ncRef = NamingContextHelper.narrow(objRef); // bind the Object Reference in Naming NameComponent nc = new NameComponent("Adder", ""); NameComponent path[] = {nc}; ncRef.rebind(path, adderRef);
Implementing a client
Create
an ORB Get a reference to the Naming Context Look up the correct name in that Naming Context Receive an object reference to that object
Actually,
to its Stub
Invoke
AdderClient.java
Object Reference
Two
1.
Meanings
An abstract concept referring to a specific object living on a specific host, attached to a specific ORB 2. A local Java reference to an object that relays messages to that object
Obtained
new
from
Naming Service
tnameserv
t
is for transient
Maps
name to object reference An implementation of the CORBA Object Service (COS) name service to run the Naming Service
UNIX:
Win32:
Fire it up
start
CORBA Flow
Client Virtual Machine Client Server Virtual Machine Remote Object
Stub
Skeleton Server
CORBA Flow
1. Server Creates Remote Object Client Virtual Machine 2. Server Registers Remote Object Client Server Virtual Machine Remote Object
1
Stub
Skeleton Server
2
CORBA Flow
Client Virtual Machine Client Server Virtual Machine 3. Client requests object from Name Server Remote 4. Name Server returns remote reference Object (and stub gets created) Stub
3 4
Skeleton Server
RMI Flow
Client Virtual Machine Client
5 6 7
Stub
Skeleton Server
5. Client invokes stub method 6. Stub talks to skeleton 7. Skeleton invokes remote object Fred method Name Server Virtual Machine
Copyright 1997 Alex Chaffee
Pseudo-objects
The
ORB is a pseudo-object It works just like a remote object, only its local
Implementation Repository Generate and interpret object references Activate and deactivate implementation objects Invoke methods via skeletons
Object database
different procedure for initializing objects Hides name service from you
Ask
the BOA to register the object Ask the Helper object to bind the object
Once
call methods using normal Java syntax Copyright 1998 Purple Technology, Inc
server
Multiple
server
processing
Persistent
Shared
server
ORB
= new MyObject();
Server
boa.create(interface_name,
boa.obj_is_ready(obj)
ready
boa.impl_is_ready()
Objects Server
shut down
boa.deactivate_obj(this)
shuts down
boa.deactivate_impl()
Threads in JavaIDL
Remote
invocations happen on a separate thread Must make sure your remote objects are thread-safe
Callbacks
Pass
in a reference to some CORBA object The server object can invoke methods on that reference ORB automatically generates a stub on the server side The server has become the client, and vice versa
the ORB
orb.resolve_initial_references(NameServic
e)
From
a Naming Context From a Stringified reference From another object From a parameter to your remote method
Helper Objects
How
CORBA does casting narrow method changes the type of an object reference
// get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameSer vice"); NamingContext ncRef = NamingContextHelper.narrow(objRef);
Naming Contexts
Directory
structure for CORBA Naming Component = file Naming Context = directory Can add a Context as a Component
like
subdirectories
Can
symbolic links
Stringification
Stringified
Visigenic: Caffeine
Java
to IDL compiler
Distributed
Follow
debugging
call chain, examine variables, et al. Across many VMs, many hosts, many OSs
Publish-Subscribe System
Channel:
an avenue for real-time data exchange Consumers can subscribe to arbitrary data channels Producers can publish data on channels
Invokes
Object Model
PSServer
Channel
creates
getChannel(String channelName)
channel if it doesnt already exist
Channel
void
dataArrived(Object data)
Flow: Subscriber-side
Client
acquires PSServer reference Client acquires channel from PSServer Client creates subscriber locally, passing reference to channel Subscriber registers self with channel
channel.subscribe(this)
Client
Flow: Publisher-side
Client
acquires PSServer reference Client acquires channel from PSServer Client creates publisher locally, passing reference to channel Publisher acquires data
From
calls channel.publish(data)
Design issues
Name
TIBCO
Caching
prior messages
Subscribe
Design issues
Maintain
Dont
want to go back across the network every time you draw a graph Create local version of class
Exceptions
CORBA
subclasses of RuntimeException, so the compiler wont complain if you forget to catch them Minor codes
Completion
Status
Exceptions (cont.)
User
Exceptions
Generated
elsewhere
Interface Repositories
JavaIDL
clients do not typically need or use an Interface Repository All of the needed type information is available in the stubs or is resolved by an object's server JavaIDL supports access to Interface Repository information made available by other CORBA object implementations. Copyright 1998 Purple Technology, Inc
Implementation Repository
contains
information that allows the ORB to locate and activate implementations of objects also store additional information associated with implementations of ORB objects.
Debugging
Value Objects
CORBA
Blobs Avoids
3.0
Development Uses IIOP as transport protocol Uses Value Objects to pass Java serialized objects
using middleware server RMI from client to middleware IIOP from middleware to other servers Can use Servlet as middleware
CORBA
Not
Some
All
means that any client can make a distributed transaction that includes both CORBA and EJB Objects
Not
an either-or decision
You
can have both EJB and CORBA working together in a single system
Java Transactions
Java
A
packages
Java
High-level package
Transactions
multiple multiple
multiple
multiple multiple
servers
databases vendors products
OTS Features
Distributed
Flat
transactions commit
Two-phase Vendor
Object
participate in a transaction
Recoverable
Actually
Object
performs commit or rollback on its own data system or server that can commit or rollback data stored inside it
Resource
A
E.g.
a database server
Control
/ Coordinator / Terminator
objects distributed commit/rollback
Registers Performs
Synchronization
An
object that gets informed of the progress of the ongoing transaction callback methods
Implements
Problem: Specific
Medical
records, patient histories, clinical schedules, lab results, and medical images all stored in disparate databases
patients per doctor, many doctors per patient immediate access to all information
Many Need
Problem: General
getting
from
data
data
a single system
distributing
to
data
Solution: Java/CORBA
Not
only did Java/CORBA solve all these problems, but Java/CORBA development is cheap, fast, scalable and works over the Internet.
WebChart Architecture
Conclusion
& Harkey, Client/Server Programming with Java and CORBA (Wiley) Orfali, Harkey & Edwards, Instant CORBA (Wiley)
Presentation
1.2 CORBA documentation
http://www.purpletech.com/ http://java.sun.com/products/jdk/1.2/docs/guide/idl/
JDK
Glerum,