5. CORBA vs. WebService
5
One important observation concerning CORBA and Web services
is that whatever can be accomplished by CORBA can be
accomplished using Web service technologies and vice versa,
although the amount of effort required would be noticeably
different. In particular, one can implement CORBA on top of
SOAP, or SOAP on top of CORBA.
6. 6
Aspect CORBA Web services
Data model Object model SOAP message exchange
model
Client-Server coupling Tight Loose
Location transparency Object references URL
Type system IDL XML schemas
static + runtime checks runtime checks only
Error handling IDL exception SOAP fault messages
Serialization built into the ORB can be chosen by the user
Parameter passing by reference by value (no notion of
objects)
by value (valuetype)
Transfer syntax CDR used on the wire XML used on the wire
binary format Unicode
State stateful stateless
Request semantics at-most-once defined by SOAP
Runtime composition DII UDDI/WSDL
Registry Interface Repository UDDI/WSDL
Implementation repository
Service discovery CORBA naming/trading
service
UDDI
RMI registry
Language support any language with an IDL
binding
any language
Security CORBA security service HTTP/SSL, XML signature
Firewall Traversal work in progress uses HTTP port 80
Events CORBA event service N/A
7. CORBA vs. RMI
CORBA interfaces are defined in IDL, RMI interfaces are defined
in Java
CORBA is language-independent, RMI is not
CORBA objects are not garbage collected, RMI objects are
garbage collected automatically.
RMI does not support “out” and “inout” operations since local
objects are copied, and remote objects passed by reference to
stub
RMI-IIOP(RMI and CORBA): less resources and more robust
7
8. 8
CORBA vs. EJB
These have many common objectives
– definition, packaging and deployment of components
CORBA has always been component oriented
– EJB ideas are being extended and incorporated into CORBA 3
– EJB is like CORBA without language independence
A Java-based CORBA will then be the best EJB
– a EJB flavor on the richness of CORBA
EJB mandates CORBA interoperability
– and many EJB services are very close derivatives of their
CORBA forerunners.
Why is this so important?
– Because more component frameworks will emerge over time!
9. 9
CORBA Introduction
A standard controlled by the Object
Management Group (OMG)
A spec for creating distributed objects
Its architecture is based on the object model
Promotes design of applications as a set of
cooperating objects
based on client/server concepts
10. CORBA Objects
It is important to note that CORBA objects differ
from typical programming objects in three
ways:
– CORBA objects can run on any platform.
– CORBA objects can be located anywhere on the
network.
– CORBA objects can be written in any language that
has IDL mapping.
10
13. First key - ORB
13
Client
Client
Client
Server
Server
Server
ORB
14. First key - ORB
Provides a communications hub for all objects
– analogous to a hardware bus
Uses a broker to handle messages requests
between clients and servers
– broker can choose server that best fits needs of
client
– allows separation of interface and implementation
– allows building block approach to development and
evolution
14
15. 15
First key - ORB
Object bus that provides object location
transparency
Responsible for mechanisms to:
– Find the object implementation of the request
– Prepare object implementation to receive the
request
– Communicate the data making up the request
16. Object adapter
An object adapter is the primary means for an object
implementation to access ORB services such as object
reference generation.
an object adapter bridges the gap between
– CORBA objects with IDL interfaces and
– the programming language interfaces of the corresponding servant
(classes)
16
17. Object adapter
An object adapter has the following tasks:
– it creates remote object references for CORBA objects;
– it dispatches each RMI via a skeleton to the appropriate servant;
– it activates objects.
An object adapter gives each CORBA object a unique object
name.
– the same name is used each time an object is activated.
it is specified by the application program or generated by the object
adapter.
– Each active CORBA object is registered with its object adapter,
which keeps a remote object table to maps names of CORBA objects to
servants.
Each object adapter has its own name - specified by the
application program or generated automatically.
OA helps the ORB to operate with different type of objects.
17
19. 19
Second key - IDL
Java
C++
C
VB
Ada
Implementation is
Hidden behind
interface
Service or Contract-
oriented View
20. Why IDL?
IDL provides facilities for defining modules, interfaces,
types, attributes and method signatures.
IDL has the same lexical rules as C++ but has
additional keywords to support distribution,
– e.g. interface, any, attribute, in, out, inout, readonly, raises.
It allows standard C++ pre-processing facilities.
– e.g. typedef for All.
The grammar of IDL is a subset of ANSI C++ with
additional constructs to support method signatures.
20
23. 23
CORBA Software Bus
C++ COBOL Smalltalk
Interface
Definition
Language
Protocol for
communication:
IIOP
Java VB
24. 24
Third key - IIOP
The General Inter-ORB protocol(GIOP) defines
– an external data representation, called CDR
– specifies formats for the messages in a request-
reply protocol.
• including messages for enquiring about the location of an
object, for cancelling requests and for reporting errors.
The Internet Inter-ORB protocol (IIOP) defines
a standard form for remote object references.
– IIOP is a specialized form of GIOP for TCP/IP
networks.
25. 25
Third key - IIOP
Don't be put off by GIOP and IIOP, they are just
names for familiar things
– GIOP is just about external data representation and
a Request-reply protocol allowing for objects to be
activated
– IIOP is just about remote object references
26. 26
Corba Services
Naming Service
Event Service and Notification Service:
– in ES suppliers and consumers communicate via an event channel
– NS extends this to allow filtering and typed events
Security service:
– authentication of principals and access control of CORBA objects with
policies
– auditing by servers, facilities for non-repudiation
Trading service:
– allows CORBA objects to be located by attribute
Transaction service and concurrency control service
– TS provides flat or nested transactions
– CCS provides locking of CORBA objects
Persistent object service:
– for storing the state of CORBA objects in a passive form and
retrieving it
27. Steps of a CORBA-based App
The steps involved:
– Define an interface(IDL file)
– Map IDL to Java (idlj compiler)
– Implement the interface
– Write a Server
– Write a Client
– Run the application
Example: a step-by-step Hello example
27
29. Step 2: map Hello.idl to Java
29
Use the idlj compiler
idlj -fall Hello.idl (Inheritance model)
idlj -fallTie -oldImplBase Hello.idl (Tie model)
This will generate:
_HelloImplBase.java (server skeleton)
HelloStub.java (client stub, or proxy)
Hello_Tie.java (only Tie model)
Hello.java
HelloHelper.java
HelloHolder.java
HelloOperations.java
30. Step 3: implement the interface
30
Implement the servant
public class HelloImpl extends _HelloImplBase {
public String sayHello() {
return "nHello world !!n";
}
}
31. Step 4: implement the server
31
Creates and initializes an ORB instance
– ORB orb = ORB.init(args, null);
Creates a servant instance (the implementation of one CORBA
Hello object)
– HelloImpl helloImpl = new HelloImpl();
Obtain a reference for the desired object and register it with ORB
– By creating a tie with the servant being the delegate(Tie model)
– By a naming context (Inheritance model)
"Stringify" the reference
– String ior = orb.object_to_string(hello);
Waits for invocations of the new object from the client
– orb.run();
– Thread.currentThread().join();
32. Step 4: implement the server
Note: to use a CORBA object, you must posses a valid reference
to it. An object reference may be obtained in one of three ways:
– CORBA::ORB::resolve_initial_references( <class-name> )
returns a reference to the specified class if the ORB can find it
– Invoking a "factory" method on an object whose reference you
already have (a "factory" creates other objects)
– Converting a "stringified" reference to a real reference
the preferred way to obtain an object reference is the latter
32
33. Step 5: write a client
33
Creates and initializes an ORB instance
– ORB orb = ORB.init(args, null);
Obtain a reference for the desired object from IOR.
– read stringified object from IOR
– resolve the Object Reference(by HelloHelper.narrow() method)
"Invokes the object's sayHello() operations and prints the result
34. Step 6: run the application
Compile the .java files, including the stubs and skeletons
– javac *.java HelloApp/*.java
Start orbd
– orbd -ORBInitialPort 1050 -ORBInitialHost localhost&
Start the Hello server
– java HelloServer -ORBInitialPort 1050 -ORBInitialHost localhost&
Run the client application
– java HelloClient -ORBInitialPort 1050 -ORBInitialHost localhost
34
35. 35
Advantages of CORBA
Object Location Transparency
Server Transparency
Language Transparency
Implementation Transparency
Architecture Transparency
Operating System Transparency
Protocol Transparency
36. References
Java IDL: The "Hello World" Example With The ImplBase Server-Side
Model (old version)
Java IDL: The "Hello World" Example
Java IDL: The "Hello World" Example With The ImplBase Server-Side
Model
CORBA Tutorial
Locating CORBA objects using Java IDL
36