- Forward


Common Object Request Broker Architecture (CORBA)
An Introduction with Examples in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Getting Started
Back SMYC Forward
  • Common Object Request Broker Architecture (CORBA):
    • Allows objects on one machine to communicate with objects on another machine in a language-independent way
    • Developed by the Object Management Group (OMG)
  • Interface Definition Language (IDL):
    • Allows objects to be described in a language-independent manner
  • Object Request Broker (ORB):
    • Responsible for locating objects, marshalling arguments, activating objects, and communications
Stubs and Skeletons
Back SMYC Forward
  • The IDL Compiler:
    • Used to create the necessary proxies
  • The Proxies:
    • A stub is a proxy for a remote object which is responsible for forwarding method invocations on remote objects to the host where the actual implementation resides
    • The stub communicates with a skeleton of the remote object which invokes the actual remote object implementation
Stubs and Skeletons (cont.)
Back SMYC Forward

An Overview

stubs_skeletons
IDL Data Types
Back SMYC Forward
char A single ASCII character
wchar A single "wide" character (which may or may not use Unicode)
octet Eight binary "bits"
boolean A binary type that can have a value of either TRUE or FALSE
string An ordered set of characters
wstring An ordered set of wide characters
short A short integer
long A long integer
float A short floating point number
double A long floating point number
any Any entity in CORBA
IDL Modules
Back SMYC Forward

Allow for the Grouping of Entities

module name { };

Can be Nested to Create Submodules

module name1 { module name2 { }; };
IDL Interfaces
Back SMYC Forward

A Collection of Operations

interface Prioritized { };

Can be Specialized

interface TextMessage { }; interface TextAlert : TextMessage { };
Operations
Back SMYC Forward
  • Defined:
    • A function signature
  • Details:
    • An operation consists of a name, a return type, and a list of parameters
    • Each paramater has a name, a type and a modifier that indicates whether it is "in-bound" (in), "out-bound" (out) or both (inout)
    • IDL does not support overloaded operations
  • Syntax:
    • type name ( [modifier type name]... );
Attributes
Back SMYC Forward
  • Defined:
    • A field (or class variable)
  • Details:
    • All attributes are private
  • Syntax:
    • attribute type name;
Collections of Attributes
Back SMYC Forward

An Example of a struct

struct AccidentReport { attribute int priority; attribute string message; };
Enumerated Data Types
Back SMYC Forward

An Example

enum Color { red, orange, yellow, green, blue, indigo, violet };
Arrays and Sequences
Back SMYC Forward
  • Array:
    • A collection of homogeneous entities
    • The size must be determined at "compile time"
    • Syntax: typedef type name[size];
  • Sequence:
    • A collection of homogeneous entities
    • The size must be determined at "run time"
    • Syntax: typedef sequence<type> name;
Exceptions
Back SMYC Forward

An Example

exception ConnectionException { string reason; };
Java Mappings
Back SMYC Forward
  • Names:
    • In general an IDL name/identifier is mapped to a Java name/identifier with no change
    • If a name collision could be generated in the mapped Java code, the name collision is resolved by prepending an underscore (_) to the mapped name
  • Modules:
    • An IDL module is mapped to a Java package with the same name
    • All IDL type declarations within the module are mapped to corresponding Java class or interface declarations within the generated package
Java Mappings (cont.)
Back SMYC Forward
  • Basic Types:
    • IDL Type Java Type
      boolean boolean
      char char
      wchar char
      octet byte
      string java.lang.String
      wstring java.lang.String
      short short
      long int
      long long long
      float float
      double double
      fixed java.math.BigDecimal
      any org.OMG.CORBA.Any
  • Booleans:
    • The IDL constants TRUE and FALSE are mapped to the Java values true and false
Java Mappings (cont.)
Back SMYC Forward
  • Holders:
    • out and inout parameter passing is handled with wrapper classes (called "holders" in CORBA)
  • Basic Types:
    • The holder class name is the Java type name with the first letter capitalized and the suffix "Holder"
    • For example, an out int gets mapped to an IntHolder
  • User-Defined Types:
    • The suffix "Holder" is added
Java Mappings (cont.)
Back SMYC Forward

An IDL enum is mapped to a Java class. For example, the following IDL specification:

enum EnumType {first, second, third, fourth, fifth};

results in the following Java code:

public class EnumType implements org.omg.CORBA.portable.IDLEntity { public static final int _first = 0; public static final EnumType first = new EnumType(_first); public static final int _second = 1; public static final EnumType second = new EnumType(_second); public static final int _third = 2; public static final EnumType third = new EnumType(_third); public static final int _fourth = 3; public static final EnumType fourth = new EnumType(_fourth); public static final int _fifth = 4; public static final EnumType fifth = new EnumType(_fifth); public int value() {...} public static EnumType from_int(int value) {...}; // constructor protected EnumType(int) {...} };
Java Mappings (cont.)
Back SMYC Forward
  • IDL struct:
    • Mapped to a final Java class with the same name
  • Details:
    • Provides instance variables for the fields in the struct
An Example
Back SMYC Forward

From the book:


McCarty B.
James Madison University


Cassady-Dorion L.
James Madison University

SAMS Press
Indianapolis, IN
1999 0-672-31537-8

javaexamples/corba-bookexample/musicServer.txt
 
javaexamples/corba-bookexample/Album.java
 
javaexamples/corba-bookexample/MusicCollection.java
 
javaexamples/corba-bookexample/MusicServer.java
 
There's Always More to Learn
Back -