CORBAIDL
-
Upload
chabucaloca -
Category
Documents
-
view
218 -
download
0
Transcript of CORBAIDL
-
7/31/2019 CORBAIDL
1/26
NJIT
Creando Archivos CORBA IDL
Preethi Balasubramanian
-
7/31/2019 CORBAIDL
2/26
Contents
The CORBA Interface Definition Language
(IDL)
Declaring data members, methods, andparameters
The interface compiler
Separating client and server on differentmachines
-
7/31/2019 CORBAIDL
3/26
CORBA IDL
La CORBA Idioma de Definicin Interfaces (IDL)
Declarando miembros de datos, mtodos, y
parmetros
El compilador de la interfaz
Separando al cliente y el servidor en mquinas
diferentes
-
7/31/2019 CORBAIDL
4/26
The Interface Definition
The interface is the syntax part of thecontract that the server object offers to theclients that invoke it.
Clients access objects only through theiradvertised interface, invoking only thoseoperations that the object exposes through its
IDL interface, with only those parameters(input and output) that are included in theinvocation.
-
7/31/2019 CORBAIDL
5/26
The Interface Definition
The IDL interface definition is independent
of programming language.
It is mapped to programming languagesusing the interface compiler.
-
7/31/2019 CORBAIDL
6/26
Example - Calc.idl
module Calc{
interface Calculator {
float calculate(in float val1, in
float val2, in char operator);
}
}
This is an interface for a Calculator with one
methodcalculate. A module can have many
interfaces.
-
7/31/2019 CORBAIDL
7/26
Mapping IDL to Java, C++
IDL Java C++
module package namespace
interface interface abstract class
operation method member function
attribute pair of methods pair of functionsexception exception exception
-
7/31/2019 CORBAIDL
8/26
Declaring Data Members
Data members are declared using theattributekeyword. The declaration must include a name and a
type. Attributes are readable and writable by default. To
make a readonly attribute, use thereadonlykeyword.IDL compiler generates public read and write methods
for the data member as required.
For example,attribute long assignable ;
generates,int assignable();void assignable (int i);
-
7/31/2019 CORBAIDL
9/26
Declaring Data Members
CORBA const values declared in an IDL map to
public static finalfields in the correspondingJava interface. Constants not declared inside theinterface are mapped topublic interface with
the same name containing a field value.const float sample = 2.3;
It is also possible to define your own types usingthe typedef keyword.
typedef string name;
-
7/31/2019 CORBAIDL
10/26
-
7/31/2019 CORBAIDL
11/26
-
7/31/2019 CORBAIDL
12/26
Declaring Methods (contd.)
module Calc{interface Calculator{
//User-defined exception
exception MyException{};
//synchronous methodfloat calculate(in float val1, in float
val2, in char operator) raises (MyException);
//asynchronous method
oneway void set_value(in long val);};
};
-
7/31/2019 CORBAIDL
13/26
More on Exceptions
System Exceptionsare thrown when
something goes wrong with the system.User Exceptionsare generated if somethinggoes wrong inside the execution of the remote
method. They are declared inside the IDL
definition for the object, and are automaticallygenerated by the IDL compiler. Implementation
of these exceptions depends on the language
mapping.
There are two types of CORBA exceptions:
-
7/31/2019 CORBAIDL
14/26
Declaring Parameters
Parameters can be of following types: Basic (char,
long,short,float,bool, etc.), Constructed (struct,
union,array,sequence), Typed objects, orany.
Parameters can be declared asin,out, orinout.
inparameters are copied from client to server
outparameters are copied from server to clientinoutparameters are used both for incoming and
outgoing information and are copied both ways.
-
7/31/2019 CORBAIDL
15/26
Declaring Parameters(contd.)
CORBA 2.0 supports only pass-by-value for
non-object data types. Objects are passed by
reference.
CORBA 3.0 supports pass-by-value for
objects by using the valuetypekeyword.
-
7/31/2019 CORBAIDL
16/26
Interface Compilers
IDL Compilers implement languagemappings in software.
They compile the interface definition(defined using IDL) to produce output thatcan be compiled and linked with an objectimplementation and its clients.
Every ORB comes with one or more IDLcompilers, one for each language that itsupports.
-
7/31/2019 CORBAIDL
17/26
Interface Compilers (contd.)
Many vendors supply their IDL compilers.Because the compilers implement mappingstandards, every vendor's IDL compilerproduces language code with the samemappings, making the code vendorindependent.
Suns JDK provides the idlj compiler.VisiBroker provides idl2cpp and idl2javacompilers.
-
7/31/2019 CORBAIDL
18/26
Need for Interface Compiler
The interface compiler converts the languageindependent IDL to language specific code thatC++, Java or other language clients and servers
can understand.For example, theidljcompiler compiles the IDLto Java code.
IDL allows an object implementer to choose the
appropriate programming language for the object.Client and server can be developed in parallel.
Clients depend only on the interface and not theimplementation of the server code.
-
7/31/2019 CORBAIDL
19/26
Need for Interface Compiler
By using IDL and interface compiler, thefollowing can be defined independent of theprogramming language :
Modularized object interfaces
Operations and attributes that an objectsupports
Exceptions raised by an operation Data types of an operation return value, its
parameters, and an object's attributes
-
7/31/2019 CORBAIDL
20/26
The idlj compiler
To compile the IDL to java usingidlj,
idlj -fall
Thefalloption creates both server and
client files.
-fclient generates client files only (default).
fservergenerates server files only.
-
7/31/2019 CORBAIDL
21/26
-
7/31/2019 CORBAIDL
22/26
Files created by idlj(contd.)
Calc.CalculatorOperations The interfacethat defines the exposed remote methods.
Calc._CalculatorStub- The client stub.Implements a local object representing theremote CORBA object. This object forwardsall requests to the remote object. The client
does not use this class directly. Calc._CalculatorImplBase- An abstract
class that implements the Calculatorinterface. It is the server skeleton.
-
7/31/2019 CORBAIDL
23/26
Separating client and server
_CalculatorStub
Calculator
CalculatorHelper
CalculatorHolder CalculatorOperations
_CalculatorImplBase
Calculator
CalculatorOperations
Client Server
-
7/31/2019 CORBAIDL
24/26
-
7/31/2019 CORBAIDL
25/26
Running the ApplicationDefine Interface
Compile Interface (idlj)
javac
Holder
Helper Implement Interface
Client stub
Operations
Server Skeleton
Operations
Start ORBjavac
Start Client Start Server
Implement Client
Client Server
-
7/31/2019 CORBAIDL
26/26
References
Client/Server Programming with Java and
CORBA Robert Orfali and Dan Harkey
http://developer.java.sun.com http://www.omg.org
http://www.infosys.tuwien.ac.at/Research/
Corba
http://www.objs.com