Generative Programming Using Two-Level Grammar by ywr18717

VIEWS: 8 PAGES: 18

									Generative Programming Using Two-Level Grammar

Barrett R. Bryant, Fei Cao, Wei Zhao, Carol C. Burt


Rajeev R. Raje, Andrew M. Olson


Mikhail Auguston
Objective

   “To create a unified framework
   (UniFrame) that will allow a seamless
   integration of heterogeneous and
   distributed software components”



                                           2
UniFrame Approach
  Unified Meta-component Model
    • Components, Quality of Service, Infrastructure
  Generative Domain Model
    • Domain model, Composition/Decomposition
      Rules, Generative Programming
  Two-Level Grammar
    • Formalism based on Two-Level Grammar
  Process
    • Methodology and tools for GDM design
                                                       4
  Generative Domain Model
•GDM consists of Domain Expertise, Query
processing, QoS processing and Generation
rules

•Generation rules are expressed in Two-Level
Grammar and the output will provide the
desired target code (e.g., glue/wrappers +
infrastructure)


                                               5
Automation of Code Generation
   Two-Level Grammar (TLG) is used to
   formally specify feature modeling and
   generation rules.
   TLG interpreter will execute generation
   rules to create source code in a
   programming language program.


                                             6
Case Study - Bank Account Management System
  Components
    CorbaAccountServer (CORBA) - Availability  85%,
    Response Delay < 30 ms
    JavaAccountServer (RMI) - Availability  90%,
    Response Delay < 10 ms
    JavaAccountClient (RMI) - Availability  90%,
    Response Delay < 50 ms

  Query - Create a bank account management system that has
  availability  50% and response delay < 100 ms.


                                                             7
Two Level Grammar
  Level 1: Domain
    Modeling domain specific knowledge
  Level 2: Operations on Domain
    Specifying Components:
     • Syntactic Contract
     • Static Quality of Service
     • Domain lexicon
    Directing glue/wrapper code generation
    leveraging it’s semantic expressiveness
                                              8
TLG Specification
   For Specific Components (User level)
     To be specified by component provider
     May be converted from GUI input


   For Glue/Wrapper Code generation (System
   level)
     Built-in specification
     Directing how wrapper and glue code is generated


                                                    9
            TLG component specification (user level)

                                    Well-            TLG Parser
                                    formed
                Internal form of specification
                                    register




                                                                Component Assembly
              Component specification library
Component     (with system level wrapper and     Generate
matching      glue code generation function in   glue/wrapper
Request       TLG)                               code




                                                                                     10
Feature Model in TLG
class BankAccount.
  AccountNumber, PIN :: String.
  Balance :: Float.
  check balance : Float.
  deposit Float.
  withdraw Float.
end class.



                                  11
  Glue/Wrapper Generation
                            Bridge driver


             RMI Client         Corba
                                Server
Proxy
                                                   Proxy client
server
   TLG specification for     TLG specification for Corba
   RMI Client                Server




                                                  Knowledge
                      GDM                         base

                                                           12
       TLG Rules for System Generation

ClientUMM, ServerUMM :: UMM.
ClientOperations, ServerOperations :: {Interface}*.

generate system from ClientUMM and ServerUMM :
  ClientOperations := ClientUMM get operations,
  ServerOperations := ServerUMM get operations,
  OperationMapping :=
      map ClientOperations into ServerOperations,
  ComponentModel :=
     ServerUMM get component model,
   generate java code for OperationMapping
      using ComponentModel.
                                                      13
            TLG Generation Rules for CORBA Wrapper
generate java code OperationMapping using corba :
  CorbaPackageName := OperationMapping get corba package name,
  CorbaObjectClass := OperationMapping get corba object type,
  ClassName := OperationMapping get class name,
  JavaClassName := Java || ClassName,
  CorbaObjectName := object || ClassName,
  SetUpCode := ComponentModel generate java code,
  Operations := generate java code for OperationMapping,
  return
    import CorbaPackageName . * ;
   public class JavaClassName {
      private CorbaObjectClass CorbaObjectName ;
      public void init () { // initialize CORBA client module
            SetUpCode
        }
        Operations
   }.
                                                                 14
         TLG Generation Rules for CORBA Methods

generate java code for OperationName1 ArgumentList1 ReturnType
      maps to OperationName2 ArgumentList2 ReturnType :
  JavaReturnType := java type of ReturnType,
 JavaArgumentList :=
     list all Argument from ArgumentList1 mapped
          by function java argument of Argument is JavaArgument,
   JavaArgumentListDefinition := separate JavaArgumentList by , ,
  OperationCall :=
     generate java code for OperationName2 ArgumentList1 ReturnType,
  return
    public JavaReturnType OperationName1 ( JavaArgumentListDefinition ) {
      EventTrace . setBeginTime ();
       OperationCall
       EventTrace . setEndTime ();
       EventTrace . calculateResponseTime ();
  }.
                                                                     15
    Example of Generation
Input
void depositMoney (float ip) --> corbaDeposit (float ip)
void withdrawMoney (float ip) --> corbaWithdraw (float ip)
float checkBalance ()         --> corbaBalance ()


Output
import corbaAccountServer . * ;
public class JavacorbaAccountServer {
  private corbaAccountServer objectcorbaAccountServer;
  public void init () { // initialize CORBA client module
     …
  }
  public void depositMoney (float ip) {
    return objectcorbaAccountServer . corbaDeposit (ip);
  }
   …
}                                                      16
         Acknowledgements

This research was supported by U. S. Office of Naval
Research Grant N000014-01-01-0746 and U. S. Army
Research Laboratory and U. S. Army Research Office
Grant DAAD190-00-1-0350.

                                                  18
   Webpage


http://www.cs.iupui.edu/uniFrame.html



                                        19

								
To top