Distributed Programming - CORBA - PowerPoint PPT Presentation

About This Presentation
Title:

Distributed Programming - CORBA

Description:

... naming service, which finds objects by name, similar to a 'white page' phone book. ... This is the complete list of the basic types available in IDL: ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 44
Provided by: vesnaundma
Category:

less

Transcript and Presenter's Notes

Title: Distributed Programming - CORBA


1
Distributed Programming - CORBA
  • Marc Conrad
  • D104 (Park Square Building)
  • Marc.Conrad_at_luton.ac.uk
  • See also www.perisic.com for CORBA links.

2
The Common Object Request Broker Architecture

CORBA
3
PART I CORBA and the OMG
  • Explaining the meaning of the acronym CORBA and
    the role of the OMG for CORBA.

4
The Common Object Request Broker Architecture
  • CORBA is not a programming language but an
    architecture.
  • CORBA is an elegant and sophisticated way to
    describe and link the use of objects in a
    distributed environment.
  • The "dirty work", the implementation of the
    behavior of the objects is out of the scope of
    CORBA.

5
The Common Object Request Broker Architecture
6
The Common Object Request Broker Architecture
  • CORBA is a standard which has been devloped by
    the OMG, the Object Management Group.
  • The OMG is the world's largest computer industry
    consortium with over 800 members.
  • See http//cgi.omg.org/cgi-bin/membersearch.pl

7
A Collection Of Rather Bulky Acronyms.
  • OMG - Object Management Group
  • ORB - Object Request Broker
  • IDL - Interface Definition Language
  • IOR - Interoperable Object Reference
  • POA - Portable Object Adapter
  • IIOP - Internet Inter-ORB Protocol

8
PART II - An example CORBA implementation
  • or
  • CORBA says "Hello World"
  • (and a first glance at IDL)

9
The CORBA Development Process
  • Write some IDL that describes the interfaces to
    the object or objects that will be used or
    implemented.
  • Compile the IDL file.
  • Identify the IDL compiler generated classes and
    interfaces.
  • Write additional code.
  • Run the application.

10
IDL Example
  • module Example
  • interface Hello
  • string sayHello()

This is an example of an IDL which provides one
method, namely sayHello(). This code is saved in
a file hello.idl
11
Mapping Hello.idl to Java(Here with idlj)
  • Go to a command line prompt and type in the
    following command idlj -fall
    Hello.idl

12
Mapping Hello.idl to Java(Here with idlj)
  • The command idlj -fall Hello.idl produces 6
    files

13
Mapping Hello.idl to Java(Here with idlj)
  • The command idlj -fall Hello.idl produces 6
    files
  • _HelloImplBase.java
  • _HelloStub.java
  • Hello.java
  • HelloHelper.java
  • HelloHolder.java
  • HelloOperations.java

14
Writing the Server.
  • For the implementation of the Server we have to
    implement two classes
  • The Servant, i.e. the object which has been
    specified by the Hello.idl
  • The Server itself, i.e. the program running in
    the background which reacts on client requests.

15
Writing the Servant
  • import Example.
  • public class HelloServant extends _HelloImplBase
  • public String sayHello()
  • return "\nHello world !!\n"

16
Server
  • Initialise the ORB
  • Instantiate a HelloServant object.
  • Register this object in the ORB.
  • Publish the object to the rest of the world
  • Wait for client requests.
  • import java.io. import org.omg.CORBA. import
    Example.
  • public class HelloServer
  • public static void main(String args)
  • try
  • ORB orb ORB.init(args, null)
  • HelloServant helloRef new
    HelloServant()
  • orb.connect(helloRef)
  • String str orb.object_to_string(helloRef)
  • String filename "A//HelloIOR"
  • FileOutputStream fos new
    FileOutputStream(filename)
  • PrintStream ps new
    PrintStream(fos)
  • ps.print(str) ps.close()
  • java.lang.Object sync new
    java.lang.Object()
  • synchronized (sync)
  • sync.wait()
  • catch (Exception e)

17
A stringified reference
  • Here is an example of an stringified object
    reference, generated by the example code
  • IOR000000000000001649444c3a4578616d706c652f48656c
    6c6f3a312e3000000000000001000000000000005800010100
    0000000f3139342e38302e3231352e32323300000682000000
    000018afabcaff0000000225163ffd00000008000000000000
    00000000000100000001000000140000000000010020000000
    000001010000000000

18
Client.
  • Initialising the ORB.
  • Retreiving an object reference.
  • Narrowing the object.
  • Using the object.
  • import java.io. import org.omg.CORBA. import
    Example.
  • public class HelloClient
  • public static void main(String args)
  • try
  • ORB orb ORB.init(args, null)
  • String filename "A//HelloIOR"
  • FileInputStream fis new
    FileInputStream(filename)
  • java.io.DataInputStream dis new
    java.io.DataInputStream(fis)
  • String ior dis.readLine()
  • org.omg.CORBA.Object obj
    orb.string_to_object(ior)
  • Hello helloRef HelloHelper.narrow(ob
    j)
  • String str helloRef.sayHello()
  • System.out.println(str)
  • catch (Exception e)
  • System.out.println("ERROR " e)
  • e.printStackTrace(System.out)

19
The CORBA services
  • Instead of sending a stringified object reference
    it is also possible to use CORBA services for
    obtaining object references
  • The CORBA naming service, which finds objects by
    name, similar to a "white page" phone book.
  • The CORBA trading service, which finds references
    that match search criteria, similar to a "yellow
    page" service.

20
Summary
  • The IDL provides class definitions for objects.
  • A Compiler compiles the IDL into several files.
  • The server and the client are then implemented by
    using these files.
  • The ORB plays a crucial role in running the
    application both for the server and for the
    client.

21
PART III Learning the IDL
  • or
  • We learn a language which is not a programming
    language but used to develop programs.

22
The OMG IDL Overview.
  • IDL supports the following constructs
  • Constants
  • Data type declarations
  • Attributes
  • Operations
  • Interfaces
  • Modules
  • Valuetypes

23
IDL Types and Constants
  • The following basic types are available in IDL
  • short, unsigned short, long, unsigned long, long
    long, unsigned long long, float, double, long
    double, fixed, char, wchar, boolean, string,
    wstring, octet, enum, any, native.
  • Excercise How are all this types mapped into
    Java? C?

24
The IDL language mapping
  • The OMG so far specifies mappings to the
    following languages
  • C, C, Smalltalk, COBOL, Lisp, Python, and Java.

25
PART IV - The IDL to Java mapping
  • or
  • How to translate an IDL to a language where you
    can really write programs.

26
Mapping IDL to Java
  • IDL supports the following constructs
  • Constants
  • Data type declarations
  • Attributes
  • Operations
  • Interfaces
  • Modules
  • Valuetypes
  • A constant is mapped to a Java public static
    final variable within a class of its own.

27
Mapping IDL to Java
  • IDL supports the following constructs
  • Constants
  • Data type declarations
  • Attributes
  • Operations
  • Interfaces
  • Modules
  • Valuetypes
  • IDL operations are mapped to Java methods as seen
    in the HelloWorld example.

28
Mapping IDL to Java
  • IDL supports the following constructs
  • Constants
  • Data type declarations
  • Attributes
  • Operations
  • Interfaces
  • Modules
  • Valuetypes
  • Interfaces are mapped to Java interfaces/classes
    as seen in the example.
  • Note One interface generates more then one Java
    class/interface (Helper classes, )

29
IDL to Java mapping
  • Identifiers are mapped to Java identifiers with
    some extra rules for special cases, e.g. class
    which is not an IDL keyword will be mapped to
    _class in Java.

30
IDL Types and Constants
  • This is the complete list of the basic types
    available in IDL
  • short, unsigned short, long, unsigned long, long
    long, unsigned long long, float, double, long
    double, fixed, char, wchar, boolean, string,
    wstring, octet, enum, any, native.
  • The blue ones do also exist in Java. What about
    the other?

31
IDL Java mapping- Signed integer types
  • short (16 bit)
  • Mapped to Java short.
  • long (32 bit)
  • Mapped to Java int
  • long long (64 bit)
  • Mapped to Java long
  • Caveat!
  • The CORBA type long and the Java type long are
    different!

32
IDL Java Mapping- Unsigned integer types
  • There is an obvious type mismatch here.
  • However, the mapping is defined from unsigned
    CORBA types to signed Java types.
  • unsigned short (16 bit)
  • Mapped to Java short.
  • unsigned long (32 bit)
  • Mapped to Java int
  • unsigned long long (64 bit)
  • Mapped to Java long

33
IDL Types and Constants- Floating point types
  • float
  • 16-bit IEEE floating point number
  • mapped to the Java type float
  • double
  • 32-bit IEEE floating point number
  • mapped to the Java type double
  • long double
  • 64-bit IEEE floating point number
  • so far not mapped!

34
IDL to Java mapping- Fixed point type
  • fixed
  • fixed-point deximal number of up to 31 digits,
    e.g.
  • typedef fixedlt5,2gt priceTag
  • The IDL type fixed is mapped to the Java class
    java.math.BigDecimal.
  • Range checking is performed at run time.
  • Exceptions are raised if values are outside of
    the range.

35
IDL to Java mapping- characters
  • char, wchar
  • are both mapped to the Java type char.
  • Note IDL char is 8-bit, IDL wchar is 16-bit, the
    Java char is 16-bit.
  • Also The IDL wchar can hold characters which are
    not part of Javas native Unicode set.

36
IDL Types and Constants- strings
  • string
  • Variable-length string of characters whose length
    is available at run time.
  • wstring
  • Variable-length string of wchar characters.
  • Strings may be bounded or unbounded, e.g. typedef
    octstring stringlt8gt for a bounded string of 8
    characters.
  • These are mapped to java.lang.String with
    possible exceptions raised for bounded strings.

37
IDL Types and Constants- miscancelous
  • boolean (TRUE or FALSE)
  • mapped to the Java type boolean.
  • octet (8-bit uninterpreted type)
  • mapped to the Java type byte.
  • enum (enumerated type with named integer values.)
  • mapped to a final Java class emulating the
    required properties.

38
IDL mapping of any
  • any (Can represent a value from any possible IDL
    type, basic or constructed, object or nonobject.
    any has an application interface describing how
    values are inserted, extracted, and how the type
    can be discovered.)
  • mapped to org.omg.CORBA.any

39
PART V the ORB
  • or
  • The thing which does the job.

40
The ORB
  • The ORB plays a central role in CORBA.
  • We have already met the ORB in different
    contexts, so the following slides are slides
    already seen, but we emphasise now more on the
    role of the ORB.

41
The Common Object Request Broker Architecture
  • The Object Request Broker (ORB) is itself an
    object which provides the services for accessing
    remote objects and transmitting data.
  • Note that the implementation of the ORB depends
    on the specific vendor. The CORBA standard only
    defines the interface.

42
The ORB A Pseudo Object
  • CORBA is primarily a specification for accessing
    remote objects.
  • However, we can as well use the IDL for the
    specification of local objects.
  • These objects are called pseudo objects.

43
The Common Object Request Broker Architecture
Write a Comment
User Comments (0)
About PowerShow.com