CORBA IDL 1 Introduction to CORBA IDL Overview OMG IDL is purely a descriptive language OMG IDL...

21
CORBA IDL 1 Introduction to CORBA IDL Overview OMG IDL is purely a descriptive language OMG IDL obeys the same lexical rules as C++ OMG IDL grammar is a subset of ANSI C++ standard with additional constructs to support operation invocation mechanism Uses C/C++ #includes and #pragma preprocessor commands
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    251
  • download

    3

Transcript of CORBA IDL 1 Introduction to CORBA IDL Overview OMG IDL is purely a descriptive language OMG IDL...

CORBA IDL 1

Introduction to CORBA IDL

Overview OMG IDL is purely a descriptive language OMG IDL obeys the same lexical rules as C++ OMG IDL grammar is a subset of ANSI C++ standard with additional

constructs to support operation invocation mechanism Uses C/C++ #includes and #pragma preprocessor commands

CORBA IDL 2

Introduction to CORBA IDL

Basics Comments

/* standard C/C++ comments */ // standard C++ comments

Identifiers Arbitrarily long sequence of alphabetic, digits, and underscore("_") characters First character must be alphabetic All characters are significant Case sensitive, but does not allow same identifiers with different cases, i.e.,

myName, MyName, or Myname, etc, can not co-exist in the same idl file. All files containing IDL must end in '.idl' or '.IDL‘ CORBA_USES_THE_UNDERSCORE_TO separate words in a name

CORBA IDL 3

Introduction to CORBA IDLKeywords

any, attributebooleancase, char, const, contextdefault, doubleenum, exceptionFALSE, fixed, floatin, inout, interfacelongmoduleObject, octet, oneway, outraises, readonlysequence, short, string, struct, switchTRUE, typedefunsigned, unionvoidwchar, wstring

CORBA IDL 4

Introduction to CORBA IDL

Module Module defines a naming scope and can be nested Modules can span several files Modules can be reopened The scoping operator is ::

CORBA IDL 5

Introduction to CORBA IDL

File Bank.idl module Bank {

interface Account {

readonly attribute float balance;

}; }; // pay attention to these these ';'

module Security {

interface Algorithms {

string MD5(in float data);

Bank::Account idToAccount( in string id); }; };

module Bank {

interface Teller {

Account getAccount( in string customerID ); }; };

CORBA IDL 6

Introduction to CORBA IDL

Nesting of Modulesmodule IIT {

module CS {

module CS447 {

interface ReportCard {

readonly attribute short grade;

};

};

};

};

CORBA IDL 7

Introduction to CORBA IDL

Using Scoping rules ::module outer {

module inner {

interface inside {};

};

interface outside {

inner::inside get_inside();

};

};

CORBA IDL 8

Introduction to CORBA IDLOne Pass Compiler – Forward Declarations

Module Bank {// Forward declare Customer, CustomerAddressinterface Customer;struct CustomerAddress;interface Account {

Customer getOwner ();};interface Custmoer {

Acount getAccount();CustomerAddress getAddress();

};struct CustomerAddress {

string street;string city;string state;int zipcode;

};};

CORBA IDL 9

Introduction to CORBA IDL

Interface Map to a Java interface Support multiple inheritance Contain:

Type declarations Constants declarations Exception declarations Attributes declarations Operations declarations

CORBA IDL 10

Introduction to CORBA IDL

Inheritancemodule inheritanceExample{

interface Right {

string getRightInfo(in string ID);

};

interface Left {

string getLeftInfo(in string ID);

};

interface Center: Left, Right {

readonly attribute int x-position;

}

CORBA IDL 11

Introduction to CORBA IDL

Inheritance Multiple inheritance is allowed The order of listing is not important Names of operations must be unique and must not be redeclared in derived

interfaces

CORBA IDL 12

Introduction to CORBA IDL

Basic Data Types – Java Mappings

IDL type Java type

short short

unsigned short short

long int

unsigned long Int

long long Long

unsigned long long Long

float fload

IDL type Java type

double Dduble

long double No mapping

char char

wchar char

boolean boolean

octet byte

Any org.omg.CORBA.Any

string java.lang.String

wstring java.lang.String

CORBA IDL 13

Introduction to CORBA IDL

Parameter Passing in out in-out

Rules for different type of parameters: An implementation should not attempt to modify an in parameter If an exception is raised in an operation, the values of out, inout parameters are

not defined. When an unbounded string or sequence passed as an inout parameter, the

returned value cannot be longer than the input value

CORBA IDL 14

Introduction to CORBA IDL

valuetypes: Mixture of interfaces and structures and are declared using the key workd

valuetype. Providing call-by-value semantics for object references Provide sharing semantics for IDL values like structs, sequences.

Example:Interface Observer{

void notify();

};

valuetype ShoppingCart supports Observer{

readonly attribute long value;

private long numIterms;

factory init(in long i);

};

CORBA IDL 15

Introduction to CORBA IDLJava Mapping to Parameters

Java uses a Holder class to implement out and inout parameters

The IDLinterface In_Out_Examples {

void just_out( out short a); void in_out( inout string b); void just_in( in char c); };

The Java generated interface public interface In_Out_Examples

extends org.omg.CORBA.Object { public void just_out(org.omg.CORBA.ShortHolder a) ; public void in_out(org.omg.CORBA.StringHolder b) ; public void just_in(char c) ; public java.lang.Object _deref() ;

}

CORBA IDL 16

Introduction to CORBA IDL

Oneway operation Oneway method does not block on a response from the server object The method is not guaranteed to be delivered The invocation semantics are “best-effort”, which implies the method will

invoked at most once Return must be void Must not have ‘raises’ clause Must not have inout or out parameters

Example

interface No_Blocking_Here {oneway void no_reply (in string message);

};

CORBA IDL 17

Introduction to CORBA IDLAttributes

Attributes are logically equivalent to a pair of accessor functions A readonly attribute means just produce the get accessor methods

Exampleinterface Student {

readonly attribute string studentId;atribute string name;…;};

Java Mappingspublic interface Student extends org.omg.CORBA.Object {

public String studentId();public String name();public void name(String value);…; }

CORBA IDL 18

Introduction to CORBA IDLExceptions

User defined exceptions are checked

Examplemodule University {

exception InvalidDepart{string name;};interface OnLineHelper {

string findChair (in string dept, in string id, out string chair) raises(InvalidDepart, InvalidStudentId);

};Java Mappings

public interface OnLineHelperOperations {public String findChair (

Java.lang.String dept,java.lang.String id,org.omg.CORBA.StringHolder id)throws InvalidDepar;

}

CORBA IDL 19

Introduction to CORBA IDL

Template types --- String OMG IDL strings are mapped to java.lang.String Since java strings do not have bounds, IDL strings passed to/from operations

are checked for size If the actual size is larger than the OML IDL string allows, a run time

exception is thrown

interface Bank {

// unbonded string readonly

attribute string address;

// bounded size string

attribute string first_name<10>;

attribute string last_name<5>; };

CORBA IDL 20

Introduction to CORBA IDL

Template types --- sequence One-dimensional array with a maximum size and length Using typedef to declare Must be defined before it can be used

CORBA IDL 21

Introduction to CORBA IDLmodule Bank_One {

interface Account {readonly attribute string name; };

struct Accounts { // bounded sequence<Account, 10> acountList; // unbounded sequence<short> ID;

}; typedef sequence<long> accountNmbers; interface Bank {

void accountList( out accountNmbers list); };

};