48
EGL Conference 2011 April 5/6 Wiesbaden, Germany EGL Open: Extensible Model Compilers Tim W Wilson – EGL Chief Architect

EGL Conference 2011 - EGL Open

Embed Size (px)

DESCRIPTION

EGL open source strategy (featuring demos of vendor developed tools and Android application generator). See www.eglcon.org for more information.

Citation preview

Page 1: EGL Conference 2011 - EGL Open

EGL Conference 2011 April 5/6 Wiesbaden, Germany

EGL Open: Extensible Model Compilers

Tim W Wilson – EGL Chief Architect

Page 2: EGL Conference 2011 - EGL Open

EGL Conference 2011

2

Evolution of Language Abstraction

Hardware

OS

Runtime Platform

Assembler

C, COBOL

Java

EGL

One

One

One

One

One

One

One

Many

Many

Many

One

Single Machine

Multiple Machine

FutureOne

Many

Evolution of Execution Environment

Evolution of Programming Languages

Range of Deployment Options

Page 3: EGL Conference 2011 - EGL Open

EGL Conference 2011

3

EGL Basic Concepts

Various component types that programmers can define Data Item – Creates a Type alias from extended data declaration

Record - aggregate of typed fields into new type

Program - Main program starts run unit – used for batch processing

Library – Static set of data and functions – local to run-unit

Service – Remotable set of functions

Interface – Abstract definition of a Service

Handler – Object-based component containing instance data and functions

ExternalType – Abstract type definition of a type implementation that exists outside of EGL

Annotations and Stereotypes Meta data applied to program elements

Drives transformations as well as tooling

Abstract Statements meant to be extended get, add, delete, replace, close, call, etc.

Page 4: EGL Conference 2011 - EGL Open

EGL Conference 2011

4

Extensible Abstractions - Metadata

Metadata allows concepts to be added without forcing specific implementations

Common semantics modeled, i.e. CRUD operations on database

Remote Invocation

UI input validation

Same semantics can apply across runtimes and frameworks

Compiler/Generator maps semantic concepts to given runtime

Metadata supplies the specifics

Page 5: EGL Conference 2011 - EGL Open

EGL Conference 2011

5

Extensible Metadata – SQLRecord Example

// A Record type definition mapped to a database table

Record Order type SQLRecord {

tableNames = [“ORDER”],

keyItems=[“orderID”] }

orderID OrderID { columnName=“ORDERID” };

dateOrderPlaced date { columname=“CREATDTE” };

totalValue money? ;

End

Have you ever wondered what these actually are and where they come from?

Page 6: EGL Conference 2011 - EGL Open

EGL Conference 2011

6

Extensible Metadata - Annotation Types

All annotations are instances of an annotation type

An Annotation Type is a stereotyped Record definition

Record ColumnName type Annotation {..}

value string;

end

DataItem SSN char(9){

columnName=“DB_SSN”, … }

end

Page 7: EGL Conference 2011 - EGL Open

EGL Conference 2011

7

Extensible Metadata - Stereotypes

Stereotypes are Annotation Types that have been annotated with the @Stereotype annotation

Record SQLRecord type Annotation {

targets = [ ElementKind.Record ]

@Stereotype{

memberAnnotations = [Column, IsReadOnly, …] }

}

tableNames string[][];

..

End

Page 8: EGL Conference 2011 - EGL Open

EGL Conference 2011

8

EGL Compiler as Model Compiler

EGL is a programming language mixed together with a modeling mechanism and extensible model compiler Has conceptual affinity with UML Action Languages

What is an Extensible Model Compiler? New concepts added to programming model

e.g. Entity, UI programming model, new Datatypes (i.e. ZonedUnicodeDecimal)

Existing compiler extended to map instances of new concepts used in the code to appropriate runtime

Very high fidelity interleaving of new extended code generation into existing code generation

Can override/extend any aspect down to low level Expressions

Page 9: EGL Conference 2011 - EGL Open

EGL Conference 2011

9

Java

EDT – Code generation process

EGL Source Code

EGL Compiler Model

Extensible Code Generation Framework

Java JavaScript C/C++ .Net …

Pluggable Generators

Eclipse

JEE Dojo

Pluggable Extension Examples

Possible

Android

COBOL

CICS/IMS

Page 10: EGL Conference 2011 - EGL Open

EGL Conference 2011

10

Module Structure of EDT: org.eclipse.edt

org.eclipse.edt.ide

org.eclipse.edt.core

org.eclipse.edt.gen

Page 11: EGL Conference 2011 - EGL Open

EGL Conference 2011

11

The EDT Modeling Framework: org.eclipse.edt.mof MOF (Meta Object Framework) Model

Meta model used to create other models

Used to create the EGL Model

EGL Model Meta model used by compiler to create

EGL elements

Program, Record, Expression, etc

EGL syntax can be used to define both MOF and EGL model elements EGL Compiler can create instances of

either model

EGL can therefore be used to define arbitrary models

MOF Model

EGL Model

Page 12: EGL Conference 2011 - EGL Open

EGL Conference 2011

12

The MOF (Meta Object Framework) Model

Page 13: EGL Conference 2011 - EGL Open

EGL Conference 2011

13

EDT MOF Framework All values are instances of EObject – including EClass

All EObject values have a reference to their EClass instance

Dynamic interface for manipulating EObjects e.g. myEObject.eGet(“field1”)

Serialization to Binary or XML form Abstracted such that other serializations possible

Replaces Intermediate Representation (IR) files seen in RBD today

Java Class generator for creating specific java classes for each EClass High performance

Easier programming

Transformation framework Initial java class implementations of each EClass generated using this framework

All EGL code generators based off same framework

Page 14: EGL Conference 2011 - EGL Open

EGL Conference 2011

14

EGL Meta Model

Page 15: EGL Conference 2011 - EGL Open

EGL Conference 2011

15

Using EGL to define a Model EGL Meta Model defined by EGL itself

Special Stereotype MofClass tells compiler to create EClass instances instead of ExternalType instances

Compiler creates EClass instance

because of MofClass

Stereotype

Compiler creates normal

Externaltype instance

Page 16: EGL Conference 2011 - EGL Open

EGL Conference 2011

16

XML Serialization of EClass - StructPart

This object is an instance of EClass

Instances of org.eclipse.edt.mof.egl.Field

Page 17: EGL Conference 2011 - EGL Open

EGL Conference 2011

17

XML Serialization of ExternalType - Customer

This object is an instance of org.eclipse.edt.mof.egl.ExternalType

Instances of org.eclipse.edt.mof.egl.Field

Page 18: EGL Conference 2011 - EGL Open

EGL Conference 2011

18

Extensible Model Compilers: org.eclipse.edt.gen Core Model Transformation framework

Model to Model, i.e. EDT MOF model to EMF model

Model to Text, i.e. EGL Model model to Java

All EDT code generation based upon this framework

Simple and lightweight and highly extensible

Extensibility comes from configurable ‘Templates’ A Template is simply a java Class

Each model element has a Template associated with it

Each Template implements methods that perform some transformation on its given model element

All template method invocation follows the inheritance hierarchy of the given model

If a given template method does not exist in the specific template of the model element method lookup will go up the super type chain

Extending an existing transformation is simply a matter of adding and replacing templates with new ones that:

Add new

Replace the original

Extend the original

Page 19: EGL Conference 2011 - EGL Open

EGL Conference 2011

19

EDT Core Generators EDT will provide ‘core’ generators for Java and JavaScript

A ‘core’ generator is one that implements a transformation to a target runtime technology that adheres to the semantics of the ‘Core’ EGL Language

EGL Core will be the EGL specification containing: Syntax and semantics for declaring EGL definitions

Execution semantics for statements and expressions

Semantic descriptions for extensible IO statements

GET, ADD, etc. with no description for specifics like SQL access

EGL Core will not specify any metadata specifications except for those necessary to define other metadata Annotation and Stereotype are types themselves known to the compiler

Core generators

Page 20: EGL Conference 2011 - EGL Open

EGL Conference 2011

20

EDT Extended Generators An Extended Generator contains:

Specific set of metadata types, i.e. SQLRecord, TextProgram, etc

Extension to a core generator with new templates built for new set of metadata types

Runtime support libraries if necessary

EDT will also provide a set of extended generators to support common platforms

JEE Generator extends core Java generator Support of Web Services, JPA, etc.

Core JavaScript Generator extended to handle current RUI programming model

Extended generators

Page 21: EGL Conference 2011 - EGL Open

EGL Conference 2011

21

EGL Compilers and the IDE An EGL Compiler:

Is a set of Metadata extensions with an intended programming model

Compiles EGL source using those definitions into IR files

Is configured with a set of extended generators that generate code to intended runtime

Many EGL Compilers exist in the IDE at the same time as separate plug-ins

Each ‘family’ of generators manage their inputs/outputs independently

Each project configures the compiler of choice Each resource inside that project can

choose a particular set of generators to use

Configured Compilers: EDT, RBD, Android

Page 22: EGL Conference 2011 - EGL Open

EGL Conference 2011

22

RBD / EDT Integration Direction

RBD 8.0.1

Eclipse

EGL Tools

COBOL Generator

Open sourc

eIBM

EGL Parser and Compiler

Java Generator

JavaScript Generator

EDT

EGL Tools

EDT Java Generator

EDT JavaScript Generator

EGL Parser and Compiler

Generation Framework

RBD Future

Eclipse

Extended EGL Tools

RBD COBOL

Generator

RBDJava

Generator

RBDJavaScript Generator

EGL Tools

EDTJava

Generator

EDTJavaScript Generator

EGL Parser and Compiler

Generation Framework

Page 23: EGL Conference 2011 - EGL Open

EGL Conference 2011 April 5/6 Wiesbaden, Germany

Android Generator: an example

Page 24: EGL Conference 2011 - EGL Open

EGL Conference 2011

24

UI Programming Model Example: Define Abstract Concepts

Window

View

ViewGroup

TableLayout

1 contentView

* children

Abstract concepts derived from concepts common across UI frameworks

Window – deployable UI unit Android – Activity

Web – HTML Page

View – Super type of all UI controls Android – View

SWT – Widget

ViewGroup – contains View children Android – ViewGroup

Dojo – Container

TableLayout – kind of ViewGroup for Tables

Page 25: EGL Conference 2011 - EGL Open

EGL Conference 2011

25

UI Programming Model Example: Define Concepts in EGL

Abstract concepts defined using Externaltypewith AbstractType stereotype

Event handlers modeled as Delegates

Inheritance modeled directly

Externaltype declarations allow for full Class modeling

Page 26: EGL Conference 2011 - EGL Open

EGL Conference 2011

26

UI Programming Model Example: Define Concepts in EGL

Core UI Concepts

Stereotypes for implementation

Concrete Widgets

Page 27: EGL Conference 2011 - EGL Open

EGL Conference 2011

27

Example Usage: Mortgage Calculator

Event handler declaration

Stereotype used to implement a WindowSimilar conceptually to RUIHandler

Invocation of the Amortize Service

Declaration of Widgets and properties

Page 28: EGL Conference 2011 - EGL Open

EGL Conference 2011

28

Mapping to Target Platform: Android and Dojo Abstract concepts need concrete mapping to intended runtime platform

Native Android is a Java framework Android generator would be an extension of the core EDT Java generator

Dojo is a JavaScript framework Dojo generator would be an extension of the core EDT JavaScript generator

This example shows a simple mapping to Android platform Use of widgets and layout Calling a web service

This example is simply meant to show what it means to build an EGL compiler extension – not an intention to do native Android as a strategic direction

Page 29: EGL Conference 2011 - EGL Open

EGL Conference 2011

29

Create the AndroidGenerator class

Android generator extends core Java generator

Adds command line parameters as necessary

Define where the configuration is for adding and overriding code generation templates

Define where the configuration is for mapping abstract types to concrete classes in the runtime

Page 30: EGL Conference 2011 - EGL Open

EGL Conference 2011

30

Create Necessary Templates

Override existing method from Template from Core

Template method invocation

Page 31: EGL Conference 2011 - EGL Open

EGL Conference 2011

31

Map Model to Android Templates

Mapping of model classes to their templates

Page 32: EGL Conference 2011 - EGL Open

EGL Conference 2011

32

Running Mortgage Calculator on Android Emulator

Page 33: EGL Conference 2011 - EGL Open

EGL Conference 2011 April 5/6 Wiesbaden, Germany

Demo

Page 34: EGL Conference 2011 - EGL Open

EGL Conference 2011 April 5/6 Wiesbaden, Germany

EGL open Tools – Xtool and XrefLars Kaare Andersen

Xact Consulting A/SCTO and Partner

Page 35: EGL Conference 2011 - EGL Open

EGL Conference 2011

3535

Agenda for this presentation Background for the tools and support to the EGL open

The main purpose of Xtool and Xref Xtool main functions

Xref main functions

Future directions Implement/integrate with new version of the EGL open

Requests from customers

Integration with RTC

Integration with RAA

Page 36: EGL Conference 2011 - EGL Open

EGL Conference 2011

3636

Background for the tools and support to the EGL open Xact have supported the EGL open project from the start.

Added a large number of requirements and API’s needed by customer or Xact.

Provided test cases for IBM development team.

Executed test based on the early versions of the EGL open software.

Goals

To support the general goal to turn EGL into a open platform.

To be able to create tool to support EGL development, management and change.

– Customer or Business Partners like Xact.

A large number of tool to support EGL will make EGL better choice for new and existing customers.

Page 37: EGL Conference 2011 - EGL Open

EGL Conference 2011

3737

Background for the tools Xact have daily contact with large EGL customers.

Customers that have developed EGL code over the last 10-20 years.

Migrated/converted EGL from other languages.

Common situation is that the customers have a large number EGL code lines.

The reuse of EGL part are on a very high level. (very positive).

– Common Data dictionary

– Common records/data areas for program, functions, services ….

– Common logging

– Common error handling

– ……

– Thousands of common packages and programs

Page 38: EGL Conference 2011 - EGL Open

EGL Conference 2011

3838

EGL code relations – direct and indirect use of parts

Program2

Program1

Record2

Program3

Program4

Function1

Function2

Function3

Function4 Record4

Record3

Record1

Page 39: EGL Conference 2011 - EGL Open

EGL Conference 2011

3939

EGL program relations and usages

Program1

Program4

Program2

Program3

Program5

Program6

Program7

Program10

Program8

Program9

Program11

Program12

Program13

Program16

Program14

Program15

Program17

Program18

Test case 1

Test case 2

Test case 3

Sub System xx

Page 40: EGL Conference 2011 - EGL Open

EGL Conference 2011

4040

Xtool and Xref Xtool

Version management – repository adaptors.

Build management.

Creation of dynamic package groups.

Release and Change management.

Xref Register, store and find cross references in all the EGL code – direct and indirect

RBD + Xtool and Xref plugins

Xtool Build server

Xtool Database server

Page 41: EGL Conference 2011 - EGL Open

EGL Conference 2011

4141

Version Control related to States (Test, Systemtest, Production)

Limited to:

Latest or State

Version in State

Page 42: EGL Conference 2011 - EGL Open

EGL Conference 2011

4242

Xtool Build ServerXtool Build server

• Load package versions from State

• Build EGL code

• Update State information

• Update Xref information

• Manage Build Progress

• Manage Change control

Page 43: EGL Conference 2011 - EGL Open

EGL Conference 2011

4343

Xref – Search for parts

Page 44: EGL Conference 2011 - EGL Open

EGL Conference 2011

4444

Xref Information - Call Stack

Page 45: EGL Conference 2011 - EGL Open

EGL Conference 2011

4545

Xref – Search for References

Page 46: EGL Conference 2011 - EGL Open

EGL Conference 2011

4646

Xtool - Synchronize

Page 47: EGL Conference 2011 - EGL Open

EGL Conference 2011

4747

Xtool – Main package View

Page 48: EGL Conference 2011 - EGL Open

EGL Conference 2011 April 5/6 Wiesbaden, Germany

Thank You