Download presentation
Presentation is loading. Please wait.
1
Introduction to CORBA
2
Introduction - CORBA (Common Object Request Broker Architecture) is a standard that enables an object written in one programming language, running on one platform to interact with objects across the network that are written in other programming languages and running on other platforms. - For example, a client object written in C++ and running under Windows can communicate with an object on a remote machine written in Java running under UNIX.
3
OMG The CORBA specification was developed by the Object Management Group (OMG). The OMG is an international, not-for-profit group consisting of approximately 800 companies and organizations defining standards for distributed object computing CORBA is only one of the specifications they develop. They are also behind other key object oriented standards such as UML (Unified Modeling Language).
4
History - The OMG was established in 1988 and the initial CORBA specification came out in Over the past 10 years significant revisions have taken place. - Version 2.0, which defined a common protocol for specifying how implementations from different vendors can communicate, was released in the mid-nineties. - The current version of CORBA is 3.0, which introduced the CORBA Component Model.
5
Specification vs. Implementation
CORBA, as defined by the OMG, is a standard or specification and not a particular piece of software. CORBA 3.0 is actually a suite of 10 standards, each defining aspects of a CORBA implementation. Several implementations of the CORBA standard exist. Among the most widely used are IBM’s SOM (a.k.a. SOMobjects) and DSOM architectures. There are also free implementations available for general use.
6
CORBA Integrations - An implementation of CORBA has been integrated into Netscape browsers. - CORBA has been built into Netscape ONE (Open Network Environment) - Netscape’s application environment based on open internet standards. - The Enterprise Edition of IBM’s WebSphere (a software platform to help build and deploy high performance web sites) integrates CORBA (as well as Enterprise Java Beans) to build highly transactional, high-volume e-business applications
7
Standard Call and Return
8
CORBACORBA Architecture
9
Three-tier CORBA Architecture
10
The Primary Elements IDL Client / Server CORBA Objects ORBs
Interface Definition Language Client / Server CORBA Objects Abstract objects based upon a concrete implementation ORBs Object Request Brokers GIOP / IIOP General and Internet Inter-Object Protocols
11
Interface Definition Language
Defines public interface for any CORBA server. C++ like syntax Client and Server implemented based on compilation of the same IDL (usually) OMG has defined mappings for: C, C++, Java, COBOL, Smalltalk, ADA, Lisp, Python, and IDLscript
12
Highlighted IDL Features
Pass by reference and by value In, out, and inout parameters Inheritance Throwing of exceptions The Any Type Callbacks Enables Peer-to-Peer Object Communication. Also supports: structs, unions, enumerations, all c++ scalars, arrays, sequences, octets, strings, constants, and typedefs.
13
Steps to Write a CORBA Object in Java
14
Client / Server CORBA Objects
15
Client / Server CORBA Objects Cont.
Abstract Do not have their own implementation. The elements of a CORBA object (interface, implementation, and location) are held rendered via other elements. Implemented via a Servant A servant is a block of code (usually an instance of a class) which implements the public interface of the CORBA object. Depending on the server policies, there may or may not be multiple instances of the servant and it may or may not be multi-threaded. Configured in code or at server startup Unlike COM+ and EJB the policies for a CORBA object which control things such as Security, threading, and persistence are not console configurable
16
Object Request Brokers (Orbs)
Responsible for all communication Locating objects Implementation specific Known IOR(Inter-Object Reference) Naming and Trading Services( DSN-like) Transferring invocations and return values Notifying other ORBs of hosted Objects Must be able to communicate IDL invocations via IIOP If an ORB is OMG compliant, then it is interoperable with all other OMG compliant ORBs
17
Additional ORB Services
Interface Repository A Database of all of the IDL for compiled objects running on the ORB Implementation Repository A Database containing policy information and the implementation details for the CORBA objects running on the ORB Load Balancing Fail-over support (대체동작 지원) Security
18
Advantages Maturity: feature-rich, diverse capabilities(Tx,security)
Open Standard Wide platform support Wide language support Efficiency Scalability
19
Drawbacks Lower Level than COM+/.NET/EJB
Steeper Learning Curve than other solutions. Firewall unfriendly Regared as complicated No standard to get the initial reference for the naming services.
20
Object Management Architecture(OMA)
Center of all the activity undertaken by OMG OMA specifies a range of architectural entities surrounding the core ORB, which is CORBA proper Detailed specifications for each component and interface category is populated in OMA reference Model
21
OMA Reference Model
22
CORBA Services CORBA Services provides basic functionality, similar to the services that system library calls do in UNIX. Functions includes creating objects, controlling access to objects, keeping track of relocated objects and to consistently maintain relationship between objects.
23
Horizontal CORBA Facilities
Horizontal CORBA Facilities sit between the CORBA services and Application objects. User-interface, information management, system management, and task management. The Horizontal Common Facilities are those facilities that are used by most systems. the Printing Facilities, the Secure Time Facilities, the Internationalization Facilities, and Mobile Agent Facilities.
24
Domain(Vertical) CORBA Facilities
facilities that are specific to particular domains or industries, rather than widely applicable. Define a standard interfaces for standard objects shared by companies within a specific vertical market(e.g. healthcare, manufacturing, finance). Now nine industries have their own OMG task force.
25
Agent An agent is a computer program that acts autonomously on behalf of a person or organization. Currently, most agents are programmed in an interpreted language (for example, Tcl and Java) for portability. A stationary agent executes only on the system where it begins execution A mobile agent is not bound to the system where it begins execution. It has the unique ability to transport itself from one system in a network to another
26
Application Objects Topmost part of the OMA hierarchy.
Provide access to application objects that can invoke methods on remote objects through ORB. Application is built from a large number of basic object classes, new classes can be generated or specified provided by CORBA services. Standardization is not required.
27
Three Benefits of using OMA
Coding is quicker, so application can be deployed sooner Applications designed around discrete services have better architecture Many OMA implementations have enterprise characteristics built in: they’re robust, and they scale.
28
CORBA vs. DCOM DCOM supports an object-oriented model, but differs substantially from classical OO models. DCOM object provides services through one or more distinct interfaces. DCOM is lack of polymorphism, instead, it constructs application from binary components.
29
CORBA vs. DCOM The major difference is CORBA is an open specification. DCOM has the potential to evolve at a faster rate than CORBA because the politics will be simpler. CORBA can be deployed far more widely than DCOM and runs in most current OS environment, while DCOM is running almost exclusively in the Windows environment.
30
CORBA vs. JAVA/RMI Some overlap between these two, both provide a viable means of building distributed applications. CORBA is concerned with interfaces between objects and applications modeled as objects, Java is primarily concerned with the implementation of these objects.
31
CORBA vs. JAVA/RMI JAVA/RMI systems fall short of seamless integration because of their interoperability requirements with other languages. JAVA/RMI system assumes the homogeneous environment of the JVM, which can only take advantage of Java Object Model. Coexistence between CORBA and Java
32
The Future of CORBA Much easier for developers to build and run client/server applications written in different languages using the IDL interface Compute-domain benefits Functionality the same as if written to sockets or some other RPC device Business-domain benefits Allows rapid development of full service website
33
Companies Using CORBA Today
AT&T Late 1990’s developed 20 to 40 systems using CORBA for both internal and external access Are certain development time for future projects will be greatly reduced by building reusable frameworks with the OMG The Weather Channel Used CORBA and Linux System is reliable, low maintenance, offers data logging Cut software development time from months to weeks
34
Companies Using CORBA Today
Raytheon Company Needed to update its complex real-time distributed system Built new system using C++ and CORBA Ready to build next generation system
35
Companies with Plans to Develop Using CORBA
Chase Manhattan Bank Plans to develop wholesale banking service Will use CORBA and Java-based middleware Further plans to introduce Java-based mortgage application service as well as integration with third-party applications possibly by year’s end Nokia Telecommunications Combining use of Orbix and CORBA to continue enhancing products and manage value added services based on a common architecture.
36
NOKIA “Nokia’s decision [to use CORBA] highlights the continuing adoption of CORBA and is recognition of the fast, effective, scaleable and open approach to the development of powerful, intelligent, mission-critical network services that CORBA offers.” Colin Newman, VP Marketing at IONA (Developers of the Orbix ORB)
37
References www.oma.org www.corba.org
developer.java.sun.com/developer/ onlineTraining/corba
38
CORBA IDL language Different from C++ in several additional commonly used keywords interface module any attribute in, out, inout readonly oneway raises exception context Interface describes the methods available in CORBA objects that implement that interface Module allows interfaces and other IDL definitions to be grouped into logical units, describing a naming hierarchy to avoid namespace clashes Any is a wildcard that can represent any valid CORBA IDL type Attribute is simply a variable associated with an interface, that can be readonly In,out,inout are method arguments that are passed to (in) or from (out) a remote method, or both (inout) Raises exception means we can specify a custom exception for our methods to raise given certain circumstances
39
IDL structure Modules Interfaces Structs Typedefs
Similar to packages in Java Define the naming scope Interfaces Inheritance interface B: A{ }; Multiple inheritance allowed interface Z: B, C { }; Structs Typedefs Modules are equivalent to packages in java. We can have multiple nested modules to define naming scope Interfaces can be extended to inherit one or many other interfaces, to add new types, constants, exceptions, methods and attributes Types, constants, exceptions can be redefined, but methods cannot! Structs are equivalent to final classes in java
40
CORBA IDL struct Rectangle{ 1 struct GraphicalObject { 2 long width;
long height; long x; long y; } ; struct GraphicalObject { 2 string type; Rectangle enclosing; boolean isFilled; }; interface Shape { 3 long getVersion() ; GraphicalObject getAllState() ; // returns state of the GraphicalObject }; typedef sequence <Shape, 100> All; 4 interface ShapeList { 5 exception FullException{ }; 6 Shape newShape(in GraphicalObject g) raises (FullException); 7 All allShapes(); // returns sequence of remote object references 8 long getVersion() ; }; Structs are compound, primative objects that map to final static classes in java. When we compile our IDL they are generated for us. Interfaces encapsulate the methods we wish to make available. Here we have Shape with two methods (explain), and ShapeList with three methods, and 1 exception We have to implement these interfaces ourselves on the server side, to actually offer a useful service!
41
IDL module Whiteboard module Whiteboard { struct Rectangle{ ...} ;
struct GraphicalObject { ...}; interface Shape { typedef sequence <Shape, 100> All; interface ShapeList { }; We can put these structs and interfaces inside a module to encapsulate a particular service we wish to offer.
42
CORBA IDL struct is used to represent complex data structures
C compatible Can also be compiled to OO class No method defined in, out, inout in: it’s a input parameter transferred from client to server out: it’s an output parameter returned from server to client, the return value will be treated as an output parameter. Set to void if no output parameter inout: both, seldom used Interface is similar to Java interface Only a set of methods defined Can be compiled to Java interface as shown below Struct is equivalent to the same in c, in java it maps to an equivalent Final class IDL interface defines set of methods. When compiled, equivalent java interface is generated. public interface ShapeList extends org.omg.CORBA.Object { Shape newShape(GraphicalObject g) throws ShapeListPackage.FullException; Shape[] allShapes(); int getVersion(); }
43
Data representation in IDL
Primitives – 15 primitive types Short (16-bit), long (32-bit), unsigned short, unsigned long, float (32-bit), double (64-bit), char, boolean (TRUE/FALSE), octet (8-bit) and any (which can represent any primitive or constructed type) Complex data Array, sequence, string, record (struct), enumerated, union object – CORBA object reference Is the common supertype of all of IDL interface types such as Shape and ShapeList in previous example We can represent a wide variety of data in a CORBA idl: Primitives are all well covered, and map to an equivalent primitive in the target execution language Complicated and compound data can be represented using things like array and sequence, which I will explain in the next slide Object generally refers to any CORBA remote object reference, it is not used directly in IDL
44
IDL constructed types – 1
Examples Use sequence typedef sequence <Shape, 100> All; typedef sequence <Shape> All bounded and unbounded sequences o f Shapes Defines a type for a variable-length sequence of elements of a specified IDL type. An upper bound on the length may be specified. string String name; typedef string<8> SmallString; unbounded and bounded sequences of characters Defines a sequences of characters, terminated by the null character. An upper bound on the length may be specified. array typedef octet uniqueId[12]; typedef GraphicalObject GO[10][8] Defines a type for a multi-dimensional fixed-length sequence of elements of a specified IDL type. Sequence is a fixed or variable length sequence of elements of an IDL type that has been defined previously. Here we have a sequence of Shape (remote corba objects) String is simply a sequence of characters, that can be bounded or unbounded Array is a single or multidimensional sequence of elements of an IDL type that has been defined previously. this figure continues on the next slide
45
IDL constructed types – 2
Examples Use record struct GraphicalObject { string type; Rectangle enclosing; boolean isFilled; }; Defines a type for a record containing a group of related entities. Structs are passed by value in arguments and results. enumerated enum Rand (Exp, Number, Name); The enumerated type in IDL maps a type name onto a small set of integer values. union union Exp switch (Rand) { case Exp: string vote; case Number: long n; case Name: string s; The IDL discriminated union allows one of a given set of types to be passed as an argument. The header is parameterized by an enum , which specifies which member is in use. A record is grouping of related entities, which is represented as a struct in CORBA IDL. Enumerated represents a particular type name that is mapped onto a small set of integer values, representing the valid values this type can be set to Union is an IDL type that can represent a set of types that can be validly passed as an argument
46
IDL methods General format Tags
[oneway] <return_type> <method_name> ([parameter1, …, parameterL]) [raises (except1, …, exceptN)] [context (name1, …, nameM)] Tags Oneway: non-blocked In, out, inout Raise-exception: throws user defined exceptions Exception can be empty, or have variables exception FullException{ GraphicalObject g;} Context: supply properties mappings (from string names to string values) The expressions in square brackets are optional One-way specifies that the client is non-blocking when making the remote call In,out, inout represents the characteristics of the method arguments Raise-exception specifies that a user-defined exception will be raised, and they themselves can contain a variable Context is rarely used
47
Parameter passing in CORBA
Pass By Reference Any parameter whose type is specified by the IDL interface, is a reference to a CORBA object and the value of a remote object reference is passed Pass By Value Arguments of primitive and constructed types are copied and sent to the recipient On arrival, a new value is created in the recipient’s process (new memory allocation). When we access a CORBA method we can obtain a remote reference to another CORBA object, e.g. Shape getShape()… it is passed by reference If a method returns a primitive or constructed type it is passed by value to us, so we operate on a local “copy” of that type (e.g. struct, sequence)
48
Example CORBA Application: Hello World
Implementations (Java IDL) Server program Write HelloWorld.idl Generate classes from HelloWorld.idl Implement the Servant class Implement a Server class Client program Write a simple Client with main to lookup HelloWorld Service and invoke the methods The steps of implementing the client and server are similar to RMI Create the HelloWorld.idl (instead of creating the Remote Interface in java) 2. Compile HelloWorld.idl to generate stub/skel in our target language - Java in this case! 3. Implement a servant class that implements all the methods defined in the IDL file 4. Implement a server class that instantiates our remote server, and registers it with the CORBA naming service
49
Write IDL definition HelloWorld.idl module cs652{ module corba{
module server { interface HelloWorldService{ string sayHello(in string who); }; Here we have an IDL file with nested modules to represent our intended namespace. Our interface HelloWorldService has a single method: The method is “sayHello” it takes one parameter “in”, which is a string It returns a string type
50
Generate Java classes Command Line tool
idlj -fall HelloWorld.idl Use idlj on CORBA IDL interface and generates the following items The equivalent Java interface: HelloWorldService.java The Portable Object Adapter (POA) abstract class HelloWorldServicePOA.java (since J2SE 1.4) for Servant class to extend The proxy class for client stub, _HelloWorldServiceStub.java Classes called helpers and holders, one for each of the types defined in the IDL interface Helper contains the narrow method, which is used to cast down from a given object reference to the class to which it belongs Holder deals with out and inout arguments, which cannot be mapped directly in Java Java classes corresponding to each of the structs defined within the IDL interface (not available for HelloWorld example) The -fall parameter to the idl compile is telling it to generate ALL bindings, for client and server. HelloWorldService.java: A mapping of the idl to a java interface HelloWorldServicePOA.java: POA class for Servant (Impl) class to extend, handles interaction with Object Adaptor _HelloWorldServiceStub.java: Stub that needs to be distributed to Java clients Helper: Converts / casts the CORBA object reference down to the class to it’s original form so we can interact with it Any structs are generated as Final java classes
51
Implement the Servant HelloWorldServiceImpl.java public class HelloWorldServiceImpl extends HelloWorldServicePOA { public HelloWorldServiceImpl() { super(); } public String sayHello(String who) { return "Hello "+who+" from your friend CORBA server :-)"; } }
52
Implement CORBA Server
public class HelloWorldServer { public static void main(String[] args) { try{ // create and initialize the ORB ORB orb = ORB.init(args, null); // get reference to rootpoa & activate the POAManager POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); rootpoa.the_POAManager().activate(); // create servant and get the CORBA reference of it HelloWorldServiceImpl helloWorldImpl = new HelloWorldServiceImpl(); org.omg.CORBA.Object ref = rootpoa.servant_to_reference(helloWorldImpl); HelloWorldService helloWorldService = HelloWorldServiceHelper.narrow(ref); // get the root naming context and narrow it to the NamingContextExt object org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); // bind the Object Reference in Naming NameComponent path[] = ncRef.to_name("HelloWorldService"); ncRef.rebind(path, helloWorldService); // wait for invocations from clients orb.run(); } catch (Exception e) {} } Explain key points in next slide
53
Commands explanation activate: make the object enabled in CORBA
servant_to_reference: get the object reference from the servant class resolve_initial_references: first lookup of POA narrow: cast CORBA object reference to the preferred class to_name: convert between string value and name component path rebind: bind and rebind the object reference to the naming service
54
Example CORBA client program
package cs652.corba.client; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; public class HelloWorldClient { public static void main(String[] args) { try{ // create and initialize the ORB ORB orb = ORB.init(args, null); // get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); // Use NamingContextExt instead of NamingContext, part of the Interoperable naming Service. NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); // resolve the Object Reference in Naming HelloWorldService helloWorld = HelloWorldServiceHelper.narrow(ncRef.resolve_str("HelloWorldService")); System.out.println(helloWorld.sayHello("Raj")); }catch(Exception e){} }
55
Run it orbd -ORBInitialPort 10000 &
Run the Object Request Broker Daemon (usedby clients for look up and object invocation on servers) orbd -ORBInitialPort & Run the server java cs652.corba.server.HelloWorldServer -ORBInitialPort & Run the client java cs652.corba.client.HelloWorldClient -ORBInitialHost localhost -ORBInitialPort 10000 RUN DEMO CODE FROM LAPTOP
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.