Supporting parametric polymorphism in CORBA IDL

Similar documents
On the correctness of template metaprograms

Why code complexity metrics fail on the C++ standard template library

Proceedings of the 8 th International Conference on Applied Informatics Eger, Hungary, January 27 30, Vol. 2. pp Virtuoso Virtuality

Distributed Objects. Object-Oriented Application Development

Agent and Object Technology Lab Dipartimento di Ingegneria dell Informazione Università degli Studi di Parma. Distributed and Agent Systems

PROFESSOR: DR.JALILI BY: MAHDI ESHAGHI

CORBA (Common Object Request Broker Architecture)

Domain-specific languages with custom operators

Using CORBA Middleware in Finite Element Software

Implementation of GDMO to IDL Translator and CORBA/CMIP Gateway for TMN/CORBA Integration

Wrapping a complex C++ library for Eiffel. FINAL REPORT July 1 st, 2005

Thesis book. Extension of strongly typed object-oriented systems using metaprograms István Zólyomi

Efficient Separate Compilation of Object-Oriented Languages

BEA WebLogic Enterprise. Technical Articles

Some Notes on Generics in C#

UNIT TESTING OF C++ TEMPLATE METAPROGRAMS

Chapter 5: Distributed objects and remote invocation

Irbid National University, Irbid, Jordan. 1. The concept of distributed corporate systems

SUBTLE METHODS IN C++

Today: Distributed Objects. Distributed Objects

Lecture 09. Ada to Software Engineering. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

Towards a Web-centric Legacy System Migration Framework

A Report on RMI and RPC Submitted by Sudharshan Reddy B

Refactoring via Database Representation

Distributed Object-Based Systems The WWW Architecture Web Services Handout 11 Part(a) EECS 591 Farnam Jahanian University of Michigan.

Efficient Separate Compilation of Object-Oriented Languages

Safe Instantiation in Generic Java

Programmiersprachen (Programming Languages)

Lecture Notes on Programming Languages

Generic Programming in C++, Delphi and Java

Java RMI Middleware Project

Static rules of variable scoping in Erlang

Advanced Lectures on knowledge Engineering

Module 1 - Distributed System Architectures & Models

Data Abstraction. Hwansoo Han

Coordination Patterns

Oracle Tuxedo. CORBA Technical Articles 11g Release 1 ( ) March 2010

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

Extended abstract. The Pivot: A brief overview

Prototype Environment for Refactoring Clean Programs

Dynamic Instantiation-Checking Components

Distributed Object-based Systems CORBA

Distributed Environments. CORBA, JavaRMI and DCOM

Lecture #2 on Object-Oriented Modeling

Beyond 2000, Beyond Object-Orientation

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

GUI framework communication via the WWW

Chapter 3:: Names, Scopes, and Bindings (cont.)

Chapter 3:: Names, Scopes, and Bindings (cont.)

Architectural Design Outline

What is Type-Safe Code Reuse?

How Much Middle-Tier Do You Need? *

Type-safe data binding on modern object-oriented platforms

Today: Distributed Middleware. Middleware

Software Paradigms (Lesson 10) Selected Topics in Software Architecture

UNIT 4 CORBA 4/2/2013 Middleware 59

A METHOD FOR INTEGRATING LEGACY SYSTEMS WITHIN DISTRIBUTED OBJECT ARCHITECTURE

Object-Oriented Genetic Improvement for Improved Energy Consumption in Google Guava

CORBA COMMON OBJECT REQUEST BROKER ARCHITECTURE OVERVIEW OF CORBA, OMG'S OBJECT TECHNOLOGY FOR DISTRIBUTED APPLICATIONS CORBA

Comparison and Analysis to Extending a Existing Programming Language to Support Generics

Clean-CORBA Interface Supporting Pipeline Skeleton

Reusability Metrics for Object-Oriented System: An Alternative Approach

Distributed Systems Principles and Paradigms. Distributed Object-Based Systems. Remote distributed objects. Remote distributed objects

Call by Declaration. Erik Ernst 1. Dept. of Computer Science, University of Aarhus, Denmark

Semantics of C++ Hauptseminar im Wintersemester 2009/10 Templates

DESIGNING A TOOL TO MAP UML CLASS DIAGRAM INTO RELATIONAL DATABASE

(12-1) OOP: Polymorphism in C++ D & D Chapter 12. Instructor - Andrew S. O Fallon CptS 122 (April 3, 2019) Washington State University

Single-pass Static Semantic Check for Efficient Translation in YAPL

ODMG 2.0: A Standard for Object Storage

RMI: Design & Implementation

Comparative analysis of refactoring and code optimization

CORBA CASE STUDY Introduction 20.2 CORBA RMI 20.3 CORBA services 20.4 Summary

Object-Oriented Middleware for Distributed Systems

Object Oriented Paradigm

AUTOMATIC GRAPHIC USER INTERFACE GENERATION FOR VTK

IT-2670: C/C++ PROGRAMMING LANGUAGE

DS 2009: middleware. David Evans

A Web-capable Persistent Programming Environment C. J. Harrison and O. M. Sallabi Department of Computation UMIST Manchester, M60 1QD, U.K.

GOO: a Generative Object-Oriented Language

Generic Programming. Akim D le Étienne Renault Roland Levillain

Performance Evaluation of Java And C++ Distributed Applications In A CORBA Environment

Available online at ScienceDirect. IERI Procedia 7 (2014 ) Engineering. Objects. Distributed

Adding Contracts to C#

Lecture 5: Object Interaction: RMI and RPC

Chapter 9. Subprograms

Generalized Document Data Model for Integrating Autonomous Applications

Polymorphism. Zimmer CSCI 330

Unit 7: RPC and Indirect Communication

What are the characteristics of Object Oriented programming language?

As related works, OMG's CORBA (Common Object Request Broker Architecture)[2] has been developed for long years. CORBA was intended to realize interope

Distribution Transparencies For Integrated Systems*

Exceptions in remote procedure calls using C++ template metaprogramming

Evaluation Issues in Generic Programming with Inheritance and Templates in C++

Patterns for polymorphic operations

CORBA/CMIP Gateway Service Scheme for CORBA/TMN Integration

Term Paper. Daniel Sarnow. Interface-based Programming in C++ Fakultät Technik und Informatik Studiendepartment Informatik

Object-Oriented Distributed Technology

The Object Model Overview. Contents. Section Title

Object-oriented Programming. Object-oriented Programming

Lecture 06: Distributed Object

Transcription:

Proceedings of the 7 th International Conference on Applied Informatics Eger, Hungary, January 28 31, 2007. Vol. 2. pp. 285 292. Supporting parametric polymorphism in CORBA IDL Zoltán Porkoláb a, Roland Király a, Ilir Kurti b a Department of Programming Languages and Compilers, Eötvös Loránd University, Budapest, Hungary e-mail: gsd,kiralyroland}@inf.elte.hu b Universiteti Aleksander Moisiu, Durrës, Albania e-mail: ikurti@uamd.edu.al Abstract The Common Object Request Broker Architecture (CORBA) is a widely accepted standard, that enables software components written in multiple programming languages, and running on multiple platforms to interoperate. Language independency is achieved through the concept of language mapping. CORBA uses the interface definition language (IDL), to specify the interfaces between components. Also, the IDL compiler generates stub and skeleton code that the client and servant links to. Parametric polymorphism is an emerging programming technique that focuses on abstracting types to collect commonalities in data structures and operations via type parameters. Parametric polymorphism may radically reduce code-repetition thus improves the qulity of the code. It is an unfortunate case that CORBA IDL does not support parametric polymorphism, which causes unnecessary code repetition both in declaration level in IDL and implementation level in stubs and skeletons. In this article we discuss the advantages of introducing templates a C++ style solution for parametric polymorphism into the IDL language. Keywords: CORBA, IDL, Parametric polymorphism MSC: 68M14 Distributed systems 1. Introduction The Common Object Request Broker Architecture (CORBA) is a widely accepted standard defined by the Object Management Group (OMG) [11] that enables software components written in multiple computer languages and running on Supported by Stiftung Aktion Österreich-Ungarn, Pr.N: 66öu2. 285

286 Z. Porkoláb, R. Király, I. Kurti multiple computers to work together [4]. CORBA provides a framework for the development and execution of distributed applications and components as well as some tools to facilitate the implementation of those interfaces using the developer s choice of languages. In addition, the OMG specifies a wealth of standard services, such as directory and naming services, persistent object services, and transaction services. Each of these services is defined in a CORBA-compliant manner, so they are available to all CORBA applications. Finally, CORBA provides all the plumbing that allows various components of an application to communicate with each other. Language independence is a very important feature of the CORBA architecture. Because CORBA does not dictate a particular language to use, it gives application developers the freedom to choose the language that best suits the needs of their applications. Taking this freedom one step further, developers can also choose multiple languages for various components of an application. For instance, the client components of an application might be implemented in Java as an applet, which ensures that the clients can run on virtually any plattform that supports standard HTTP browsers. The server components of that application in the same time might be implemented in C++ for high performance purposes. 2. CORBA IDL Language independency is achieved through the concept of language mapping. CORBA uses the Interface Definition Language (IDL) to specify the interfaces between components. An object interface indicates the operations the object supports, but not how they are implemented. IDL is purely declarative, that is, in IDL there is no way to declare object state and algorithms. Language mapping is done by IDL compiler, a tool which converts IDL declarations to their associated representations in the target language. IDL defines language bindings for many different programming languages in a standardized way. Currently there exist mapping to C, C++, Java, Ada, COBOL, Smalltalk, Objective C, and Lisp languages. The definition of IDL is programming language neutral, however CORBA objects exhibit many features and traits of other objectoriented systems, including interface inheritance and polymorphism. What makes CORBA even more interesting is that it provides this capability even when used with non object-oriented languages such as C and COBOL, although CORBA maps particularly well to object-oriented languages like C++ and Java. The IDL generates stub and skeleton code that the client and servant links to. Client-side stubs represent the CORBA object locally in the actual programming language. The generated code also represents in the language all of the IDL interfaces and data types used to issue requests. The client code thus depends only on the generated client-side stub code. In addition to the files generated for a client, it also generates skeleton code for the object implementation. A skeleton is the entry point into the distributed object. It unmarshals the incoming data, calls the method implementing the operation being requested, and returns the marshaled

Supporting parametric polymorphism in CORBA IDL 287 results. Thus, the object developer can focus on providing the implementation of the IDL interface. The CORBA IDL was designed to express common language features without regards to any particular programming languages. IDL is able to describe modules as a collection of object interfaces; attributes and parameterized operations, and exceptions raized by certain operations. The IDL data types are basic data types, (like string, long, short... ), constructed data types (like struct, union, enum, sequence... ), a dynamically typed value (any), and object references. The following figure demonstrates the structure of IDL definitions: module <id> <type_decl>; <const_decl>; <exception_decl>; interface <id> [:<base>] <type_decl>; <const_decl>; <exception_decl>; <attrib>; [<mode>] <id> (<params>) [raises <exception>] [context]; // other interfaces... 3. Parametric polymorphism in IDL Parametric polymorphism abstracting commonalities on data types and operations is a widely accepted programming paradigm today [3]. Appeared first in earlier dynamic programming languages, the idea won greater attention in the languages ADA [1], and Eiffel [5] where generics were important elements for abstraction. In the C++ programming language template is a fundamental language construction [8]. Recently most object-oriented languages has some language elements implementing parametric polymorphism. In Java, erlier attempts from Pizza [7] to Generic Java [2] has lead to Java Generics in language verison 5. [9]. In C#, generics also part of the current specification [10]. However, there is two completely different way to implement parametric polymorphism. ADA, Eiffel and C++ use instantiation: every time a client refers a

288 Z. Porkoláb, R. Király, I. Kurti template with a new type parameter a new instance is created. This automatic code generation is called instantiation. In that method all the type parameter occurances are served by different concrete classes generated from the template. On the other hand, Java and C# use type erasure technique. Here no separate instances are created, all type parameter occurances are served by the same single code typically working on the root class of class hierarchy. In Java, this class is Object. CORBA and generic programming have already met at the implementational level. Most modern implementations of CORBA IDL mappings are heavily based on parametric polymorphism programming techniques. The IDL C++ mapping generates template classes for reducing code repetition. However, at the interface definition level the programmer is still unable the define generic constructions. Introduction template machanism into IDL language will highly reduce code duplication, therefore would improve the quality of the code. 3.1. IDL templates To introduce parametric polymorphism to CORBA IDL the most straitforward way is to follow the C++ template mechanism, both in syntax and in semantics. In this model we require only minor changes in the IDL languager. The main concept here is the immediate instantiation of templated IDL definitions: changing the placeholder identifier to the concrete type used in the place the template is referred creates concrete instantiations. Such a mapping between templated and ordinary IDL definitions can be done by a macro-like precompiler. The result is a non templated IDL file. Language bindings and IDL compilers to create the stub and skeleton codes are not affected. A general definition of the templates of IDL language can be the following: template <typename identifier> interface function other_elements; The following is an example for a templated IDL code. template <typename T> interface stack void push (in T v2); T pop(); short size(); The code is parsed and syntactically checked by the templated IDL precompiler IDL<T>. However, similarly to C++ template instantiation, no other action is taken place until some other part of the IDL does not explicitelly refer. Such a code snippet could be the following:

Supporting parametric polymorphism in CORBA IDL 289 typedef stack<long> long_stack; interface calculator stack<short> expresson; interface non_templated void evaluate(in stack<float> expr); In the first case, typedef is used to name a new type long_stack as a stack instantiated with type parameter long. This is similar to the regular usage of typedef regarding with expressions like sequence<long>. In the second case a new interface calculator declared with a stack as an attribute. Here we instantiate an unnamed instance of stack interface with parameter type short. This is a different interface from the previous instance stack<long>. Instantiation may happen when the new interface is referred in a rather implicite way. In the third example stack<float> is mentioned as an argument of a method. This also causes instantiation. The result is equivalent to the following: interface T1 void push (in long v2); long pop(); short size(); interface T2 void push (in long v2); long pop(); short size(); interface T3 void push (in long v2); long pop(); short size(); typedef T1 long_stack;

290 Z. Porkoláb, R. Király, I. Kurti interface calculator T2 expresson; interface non_templated void evaluate(in T3 expr); Using and compiling templates in IDL is easier than in other languages, because IDL does not contain the function bodies, just the method header definitions, so the expressions and their evaluations require a bit more relaxed examination. However, this is still must not taken as a simple macro replacement. Strict syntax checking, name lookup, and controlling previous instantiations must be taken place. The main advantage of this solution is that we can translate the templated IDL into the ordinary IDL declarations without the neccessity to bother the IDL bindings for different languages. Existing IDL compilers can be used to generate stub and skeleton codes. 3.2. Generating generic stub and skeleton When we extracting templated IDL code the result is a non-templated IDL definition ready to processing with ordinary IDL compilers. However, in this model we lose the opportunity to further exploit the commonality of the templated definitions. All the further processing of the generated interfaces happens independently. In programming languages directly supporting parametric polymorphism we can generate the stub and skeleton code directly from the original templated IDL definitions. Hence the size of the generated source and in some cases the executable can be radically reduced. For languages like ADA and C++ generation of the templated proxy types, holder and helpers are straitforward [6]. In C# and Java we have to fix the problems arising from the nature of type erasure. In the case of languages where no support for parametric polymorphism exists, we can use the method described in the previous subsection. 4. Conclusion The introduction of parametric polymorphism to CORBA Interface Definition Language offers the opportunity to create abstractions over type parameterized data structures, operations and other language elements. Thus the designer of distributed systems creates clearer interfaces and improves the quality of the code. There are different levels of implementing parametric polymorphism in IDL mapping. The most natural and portable way is the template instantiation method

Supporting parametric polymorphism in CORBA IDL 291 at IDL level. In this case templated IDL definitions are unfolded to non-templated standard IDL definitions. Hence, maximal portability is achieved but we lose the opportunity to further exploit the commonality in these definitions. An advanced solution is possible for languages supporting parametric polymorphism. In this case stub and skeleton generation could utilize the commonality in IDL declarations, therefore more advanced templated code helps the implementor References [1] Barnes, J., Programming in Ada 95, 2nd Ed. Addison-Wesley, ISBN-10: 0201342936, (June 1998). [2] Bracha, G., Odersky, M., Stoutamire, D., Wadler, P., Making the Future Safe for the Past: Adding Genericity to the Java Programming Language, OOP- SLA 98, ACM Symposium on Object Oriented Programming: Systems, Languages, and Applications (OOPSLA), Vancouver, BC, (1998), 183 200. [3] Cardelli, L., Wegner, P., On Understanding Types, Data Abstraction, and Polymorphism, Computing Surveys, Vol. 17, No. 4, (December 1985), 471 522. [4] Harkey, D., Orfali, R., Client/Server Programming with Java and CORBA, 2nd Ed, John Wiley and Sons, ISBN-10: 047124578X, (March 1998). [5] Meyer, B., Eiffel: The Language, Prentice Hall PTR, ISBN-10: 0132479257, (October 1991). [6] Henning, M., Vinoski, S., Advanced CORBA Programming with C++, Addison- Wesley Professional, ISBN-10: 0201379279, (February 1999). [7] Odersky, M., Wadler, P., Pizza into Java: Translating Theory into Practice, POPL 97, Proceedings of the 24th ACM Symposium on Principles of Programming Languages, Paris, France, (1997), 146 159. [8] Stroustrup, B., The C++ Programming Language (Special 3rd Edition), Addison- Wesley Professional, ISBN-10: 0201700735, (February 2000). [9] Torgersen, M., Ernst, E., Hansen, C. P., Ahé, P., Bracha, G., Gafter, N. M., Adding Wildcards to the Java Programming Language, Journal of Object Technology 3(11), (2004), 97 116. [10] Standard ECMA-334 C# Language Specification, 4th Ed. June 2006, ISO/IEC 23270:2006. [11] IDL Syntax and Semantics, Chapter 3 of The Common Object Request Broker: Architecture and Specification, http://www.omg.org

292 Z. Porkoláb, R. Király, I. Kurti Zoltán Porkoláb, Roland Király Pázmány Péter sétány 1/C H-1117 Budapest, Hungary Ilir Kurti Lagja 1, Rr. Currilave Durrës, Albania