Download presentation
Presentation is loading. Please wait.
1
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
2
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
3
CORBA IDL 3 Introduction to CORBA IDL Keywords any, attribute boolean case, char, const, context default, double enum, exception FALSE, fixed, float in, inout, interface long module Object, octet, oneway, out raises, readonly sequence, short, string, struct, switch TRUE, typedef unsigned, union void wchar, wstring
4
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 ::
5
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 ); }; };
6
CORBA IDL 6 Introduction to CORBA IDL Nesting of Modules module IIT { module CS { module CS447 { interface ReportCard { readonly attribute short grade; };
7
CORBA IDL 7 Introduction to CORBA IDL Using Scoping rules :: module outer { module inner { interface inside {}; }; interface outside { inner::inside get_inside(); };
8
CORBA IDL 8 Introduction to CORBA IDL One Pass Compiler – Forward Declarations Module Bank { // Forward declare Customer, CustomerAddress interface Customer; struct CustomerAddress; interface Account { Customer getOwner (); }; interface Custmoer { Acount getAccount(); CustomerAddress getAddress(); }; struct CustomerAddress { string street; string city; string state; int zipcode; };
9
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
10
CORBA IDL 10 Introduction to CORBA IDL Inheritance module inheritanceExample{ interface Right { string getRightInfo(in string ID); }; interface Left { string getLeftInfo(in string ID); }; interface Center: Left, Right { readonly attribute int x-position; }
11
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
12
CORBA IDL 12 Introduction to CORBA IDL Basic Data Types – Java Mappings IDL typeJava type short unsigned shortshort longint unsigned longInt long Long unsigned long longLong floatfload IDL typeJava type doubleDduble long doubleNo mapping char wcharchar boolean octetbyte Anyorg.omg.CORBA.Any stringjava.lang.String wstringjava.lang.String
13
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
14
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); };
15
CORBA IDL 15 Introduction to CORBA IDL Java Mapping to Parameters Java uses a Holder class to implement out and inout parameters The IDL interface 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() ; }
16
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); };
17
CORBA IDL 17 Introduction to CORBA IDL Attributes Attributes are logically equivalent to a pair of accessor functions A readonly attribute means just produce the get accessor methods Example interface Student { readonly attribute string studentId; atribute string name; …;}; Java Mappings public interface Student extends org.omg.CORBA.Object { public String studentId(); public String name(); public void name(String value); …; }
18
CORBA IDL 18 Introduction to CORBA IDL Exceptions User defined exceptions are checked Example module 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; }
19
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 ; attribute string last_name ; };
20
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
21
CORBA IDL 21 Introduction to CORBA IDL module Bank_One { interface Account { readonly attribute string name; }; struct Accounts { // bounded sequence acountList; // unbounded sequence ID; }; typedef sequence accountNmbers; interface Bank { void accountList( out accountNmbers list); };
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.