An Approach for Supporting Aspect-Oriented Domain Modeling GPCE 2003 – Erfurt, Germany September 24, 2003 Jeff Gray, Ted Bapty, Sandeep Neema, Doug Schmidt,

Slides:



Advertisements
Similar presentations
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Advertisements

Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
ASTA Aspect Software Testing Assistant Juha Gustafsson, Juha Taina, Jukka Viljamaa University of Helsinki.
Presented by: Thabet Kacem Spring Outline Contributions Introduction Proposed Approach Related Work Reconception of ADLs XTEAM Tool Chain Discussion.
From Natural Language Requirements to Executable Models of Software Components.
(c) Copyright Palo Alto Research Center Incorporated. All Rights Reserved.1 Aspect-Oriented Programming with AspectJ™ AspectJ.org PARC Erik Hilsdale,
Automated Analysis and Code Generation for Domain-Specific Models George Edwards Center for Systems and Software Engineering University of Southern California.
Aspect-Oriented Programming with AspectJ™ AspectJ.org Xerox PARC Erik Hilsdale Gregor Kiczales.
UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI CHESS Review May 10, 2004 Berkeley, CA Model-Based Design Edited by Janos Sztipanovits,
UML CASE Tool. ABSTRACT Domain analysis enables identifying families of applications and capturing their terminology in order to assist and guide system.
Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI NSF Model-Based Design DSML.
Using Aspect Oriented Programming to Support Disciplined Software Construction Amiram Yehudai School of Computer Science Tel-Aviv University Research agenda.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program.
Sumant Tambe, et. al LEESA DSPD 2008 An Embedded Declarative Language for Hierarchical Object Structure Traversal Sumant Tambe* Aniruddha Gokhale Vanderbilt.
Levels of Independence in Aspect-Oriented Modeling Workshop on Model-driven Approaches to Middleware Applications Development June 17, 2003 Jeff Gray,
NSF/ITR: Foundations of Hybrid and Embedded Software Systems Model-Integrated Computing: Foundations DSML Composition Model Synthesis and Model Transformation.
Model-Driven Program Transformation of a Large Avionics Application Jeff Gray, Jing Zhang, Yuehua Lin, Suman Roychoudhury, Hui Wu, Rajesh Sudarsan, Aniruddha.
Institute for Software Integrated Systems Vanderbilt University Constraint-Based Embedded Program Composition PI: Ted Bapty Sandeep Neema, Andy Gokhale,
Programação Orientada a Aspectos e a linguagem AspectJ Profa. Dra. Rosana Teresinha Vaccare Braga 4 de maio de 2005 (material elaborado por Valter Camargo.
An Examination of DSLs for Concisely Representing Model Traversals and Transformations Jeff Gray University of Alabama at Birmingham Gábor Karsai Vanderbilt.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
Aspect-Oriented Programming with AspectJ™ AspectJ.org Xerox PARC Erik Hilsdale Gregor Kiczales with Bill Griswold, Jim Hugunin, Wes Isberg, Mik Kersten.
Building Tools by Model Transformations in Eclipse Oskars Vilitis, Audris Kalnins, Edgars Celms, Elina Kalnina, Agris Sostaks, Janis Barzdins Institute.
Generating a Generator Jeff Gray University of Alabama at Birmingham Department of Computer and Information Sciences gray (at) cis.uab.edu
Institute for Software Integrated Systems Vanderbilt University Constraint-Based Embedded Program Composition Institute for Software Integrated Systems.
Institute for Software Integrated Systems Vanderbilt University Cyber Physical Systems: New Challenges for Model-based Design Janos Sztipanovits ISIS,
Validated Model Transformation Tihamér Levendovszky Budapest University of Technology and Economics Department of Automation and Applied Informatics Applied.
1162 JDK 5.0 Features Christian Kemper Principal Architect Borland.
Replicators: Transformations to Address Model Scalability Jeff Gray, Yuehua Lin, Jing Zhang, Steve Nordstrom, Aniruddha Gokhale, Sandeep Neema, and Swapna.
Constraint-Based Embedded Program Composition IMPACT Rapid Construction of Efficient Embedded Systems. Multiple System Variants for Little Cost. Rapid,
Aspect-Oriented Programming with AspectJ™ Julie Waterhouse and Mik Kersten eclipse.org/aspectj IBM UBC.
Introdução à Programação Orientada a Aspectos Introdução à Programação Orientada por Aspectos Introdução à Programação Orientada aosAspectos Introdução.
Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake
Dr. Douglas C. Schmidt, Dr. Aniruddha S. Gokhale, Bala Natarajan, Jeff Parsons, Tao Lu, Boris Kolpackov, Krishnakumar Balasubramanian, Arvind Krishna,
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
1 Xiaoqing Wu, Barrett R. Bryant, Jeff Gray and Suman Roychoudhury University of Alabama at Birmingham Separation of Concerns in Compiler Development Using.
Security UML -1 Aspect-Oriented Software Design  Motivating the Problem  What does OO Offer?  When and How does OO Fail?  Looking at the Problem Large.
CoSMIC: Tool-suite for Weaving Deployment & Configuration Crosscutting Concerns of CCM-based DRE Systems Dr. Aniruddha Gokhale (PI) Institute for Software.
MILAN: Technical Overview October 2, 2002 Akos Ledeczi MILAN Workshop Institute for Software Integrated.
© Siemens AG, CT SE 2 C O R P O R A T E T E C H N O L O G Y 1 Model-Driven Development for Pluggable Collaborations Iris Groher, Stephan Bleicher, Christa.
Weaving a Debugging Aspect into Domain-Specific Language Grammars SAC ’05 PSC Track Santa Fe, New Mexico USA March 17, 2005 Hui Wu, Jeff Gray, Marjan Mernik,
1 Model-based Aspect Weaver Construction Suman Roychoudhury Frédéric Jouault Jeff Gray {roychous, jouault, cis.uab.edu This project is supported.
Aniruddha Gokhale and Jeff Gray Institute for Software Integrated Systems (ISIS) Vanderbilt University Software Composition and Modeling Laboratory University.
12/9/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
©SoftMooreSlide 1 Session Tracking with Servlets.
Generating Aspect Code from Models OOPSLA 2002 Workshop on Generative Techniques in the Context of the MDA November 5 th, 2002 Seattle, WA This work is.
aspectj tools new and noteworthy Mik Kersten University of British Columbia Adrian Colyer IBM Hursley OOPSLA, October
A Model Transformation Approach to Automated Model Construction and Evolution Yuehua Lin Jeff Gray Department of.
Institute for Software Integrated Systems Vanderbilt University Constraint-Based Embedded Program Composition PI: Ted Bapty Sandeep Neema, Jeff Gray Institute.
Aspect Oriented Software Development Viviane Jonckers et al Many of the slides in this presentation are adapted from the AOSD-Europe white paper.
Aspect Oriented Programming and other topics Amiram Yehudai Introduction to the Seminar.
Model-Driven Synthesis of Embedded Robotic Navigation Systems Rachael Dennison Bina Shah
Cross-cutting of concerns ordinary program structure-shy functionality structure synchronization better program Chapter 1 Chapter 2 Chapter 3 Woven meaning.
PLDI (c) Copyright Palo Alto Research Center Incorporated. All Rights Reserved.1 Aspect-Oriented Programming with AspectJ™ Erik Hilsdale,
Aspect-Oriented Programming with AspectJ™ AspectJ.org Xerox PARC Erik Hilsdale Gregor Kiczales.
Customizable Operating Systems with Aspect-Oriented Programming
Problems of Object-Oriented Design and Implementation
Pre-assessment Questions
Sessions.
Applying Domain-Specific Modeling Languages to Develop DRE Systems
TRUST:Team for Research in Ubiquitous Secure Technologies
יום עיון לזכרו של ד"ר ברק שהם ז"ל
Automated Analysis and Code Generation for Domain-Specific Models
TRUST:Team for Research in Ubiquitous Secure Technologies
Zilong Ye, Ph.D. Cyber physical system Zilong Ye, Ph.D.
Presentation transcript:

An Approach for Supporting Aspect-Oriented Domain Modeling GPCE 2003 – Erfurt, Germany September 24, 2003 Jeff Gray, Ted Bapty, Sandeep Neema, Doug Schmidt, Andy Gokhale and Bala Natarajan gray (at) cis.uab.edu This research is funded by DARPA/IXO, under the PCES program. University of Alabama at Birmingham Vanderbilt University

Multiple Levels of Hierarchy Replicated Structures Context Sensitive Motivating Problem – Crossccuting Constraints in Real-Time/Embedded Models Base models become constrained to capture a particular design A B cde B cde F B cde Changeability??? Crosscutting Constraints Constraints that are related to some global property are dispersed across the model

Importance of Changeability in Modeling  Modeling’s key advantage: Ability to rapidly explore “what-if” design alternatives  Changeability a metric for modularity: “The way to evaluate a modular decomposition…is to ask what changes it accommodates.” David Weiss, chapter preface in Software Fundamentals  Ensure benefit of model-driven approach: “Small changes in requirements entail large changes in the structure and configuration” Gerald Jay Sussman, “Robust Design through Diversity,” DARPA Amorphous Computing Workshop, 1999.

Motivation Summary  Key Problems: Difficult to specify and manage cross-cutting concerns (e.g., constraints) in model-based systems Lack of tool support for automatically weaving concerns into models  Our Solution: A meta framework that assists in the construction of model weavers, capable of rapidly dispersing global concerns across a design space; not just notational Constraint-Specification Aspect Weaver

Modeling Context: MIC/GME META-MODEL Meta-Model of Stateflow using UML/OCL as meta-modeling language. DOMAIN-MODEL Model instance of Stateflow C++ Model interpreter 2 FPGA Model interpreter 3 Key focus of this paper:  Weaving of high-level concerns into domain model  Framework for creating new weavers for each meta-model Matlab Model interpreter 1

Process of Using a Model Weaver GME Domain-Specific Weaver bit1 bit1 Structural ProcessingCompound GatesPerBit 37,153 NomBits 205,76 MaxBits 128,76 Enhanced FOO.XML bit1 bit1 Structural ProcessingCompound GatesPerBit 37,153 NomBits 205,76 MaxBits 128,76 FOO.XML constraint FOOB2 { // apply a specific constraint to “B2” only in Structural models("ProcessingCompound")-> select(p | p.name() == "B2")->PowerStrategy(1, 100); } constraint FOOBStar { // apply a specific constraint to all nodes beginning with “B” - use wildcard in Structural models("ProcessingCompound")-> select(p | p.name() == "B*")->PowerStrategy(1, 100); } Modeling Pointcuts

Comp1 package org.apache.tomcat.session; import org.apache.tomcat.core.*; import org.apache.tomcat.util.StringManager; import java.io.*; import java.net.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; /** * Core implementation of a server session * James Duncan Davidson James Todd */ public class ServerSession { private StringManager sm = StringManager.getManager("org.apache.tomcat.session"); private Hashtable values = new Hashtable(); private Hashtable appSessions = new Hashtable(); private String id; private long creationTime = System.currentTimeMillis();; private long thisAccessTime = creationTime; private long lastAccessed = creationTime; private int inactiveInterval = -1; ServerSession(String id) { this.id = id; } public String getId() { return id; } public long getCreationTime() { return creationTime; } public long getLastAccessedTime() { return lastAccessed; } public ApplicationSession getApplicationSession(Context context, boolean create) { ApplicationSession appSession = (ApplicationSession)appSessions.get(context); if (appSession == null && create) { // XXX // sync to ensure valid? appSession = new ApplicationSession(id, this, context); appSessions.put(context, appSession); } // XXX // make sure that we haven't gone over the end of our // inactive interval -- if so, invalidate and create // a new appSession return appSession; } void removeApplicationSession(Context context) { appSessions.remove(context); } /** * Called by context when request comes in so that accesses and * inactivities can be dealt with accordingly. */ void accessed() { // set last accessed to thisAccessTime as it will be left over // from the previous access lastAccessed = thisAccessTime; thisAccessTime = System.currentTimeMillis(); } void validate() void validate() { // if we have an inactive interval, check to see if // we've exceeded it if (inactiveInterval != -1) { int thisInterval = (int)(System.currentTimeMillis() - lastAccessed) / 1000; if (thisInterval > inactiveInterval) { invalidate(); ServerSessionManager ssm = ServerSessionManager.getManager(); ssm.removeSession(this); } synchronized void invalidate() { Enumeration enum = appSessions.keys(); while (enum.hasMoreElements()) { Object key = enum.nextElement(); ApplicationSession appSession = (ApplicationSession)appSessions.get(key); appSession.invalidate(); } public void putValue(String name, Object value) { if (name == null) { String msg = sm.getString("serverSession.value.iae"); throw new IllegalArgumentException(msg); } removeValue(name); // remove any existing binding values.put(name, value); } public Object getValue(String name) { if (name == null) { String msg = sm.getString("serverSession.value.iae"); throw new IllegalArgumentException(msg); } return values.get(name); } public Enumeration getValueNames() { return values.keys(); } public void removeValue(String name) { values.remove(name); } public void setMaxInactiveInterval(int interval) { inactiveInterval = interval; } public int getMaxInactiveInterval() { return inactiveInterval; } // XXX // sync'd for safty -- no other thread should be getting something // from this while we are reaping. This isn't the most optimal // solution for this, but we'll determine something else later. synchronized void reap() { Enumeration enum = appSessions.keys(); while (enum.hasMoreElements()) { Object key = enum.nextElement(); ApplicationSession appSession = (ApplicationSession)appSessions.get(key); appSession.validate(); } Quantification Over Base Code pointcut pubIntf(Object o): call(public * com.borland.*.*(..)) && target(o); after(Object o) throwing (Error e): pubIntf(o) { log.write(o, e); … } after(Object o) throwing (Error e): pubIntf(o) { log.write(o, e); … } Comp2 package org.apache.tomcat.session; import org.apache.tomcat.util.*; import org.apache.tomcat.core.*; import java.io.*; import java.net.*; import java.util.*; import javax.servlet.http.*; /** * James Duncan Davidson Jason Hunter James Todd */ public class ServerSessionManager implements SessionManager { private StringManager sm = StringManager.getManager("org.apache.tomcat.session"); private static ServerSessionManager manager; // = new ServerSessionManager(); protected int inactiveInterval = -1; static { manager = new ServerSessionManager(); } public static ServerSessionManager getManager() { return manager; } private Hashtable sessions = new Hashtable(); private Reaper reaper; private ServerSessionManager() { reaper = Reaper.getReaper(); reaper.setServerSessionManager(this); reaper.start(); } public void accessed( Context ctx, Request req, String id ) { ApplicationSession apS=(ApplicationSession)findSession( ctx, id); if( apS==null) return; ServerSession servS=apS.getServerSession(); servS.accessed(); apS.accessed(); // cache it - no need to compute it again req.setSession( apS ); } public HttpSession createSession(Context ctx) { String sessionId = SessionIdGenerator.generateId(); ServerSession session = new ServerSession(sessionId); sessions.put(sessionId, session); if(-1 != inactiveInterval) { session.setMaxInactiveInterval(inactiveInterval); } return session.getApplicationSession( ctx, true ); } public HttpSession findSession(Context ctx, String id) { ServerSession sSession=(ServerSession)sessions.get(id); if(sSession==null) return null; return sSession.getApplicationSession(ctx, false); } // XXX // sync'd for safty -- no other thread should be getting something // from this while we are reaping. This isn't the most optimal // solution for this, but we'll determine something else later. synchronized void reap() { Enumeration enum = sessions.keys(); while (enum.hasMoreElements()) { Object key = enum.nextElement(); ServerSession session = (ServerSession)sessions.get(key); session.reap(); session.validate(); } synchronized void removeSession(ServerSession session) { String id = session.getId(); session.invalidate(); sessions.remove(id); } public void removeSessions(Context context) { Enumeration enum = sessions.keys(); while (enum.hasMoreElements()) { Object key = enum.nextElement(); ServerSession session = (ServerSession)sessions.get(key); ApplicationSession appSession = session.getApplicationSession(context, false); if (appSession != null) { appSession.invalidate(); } /** * Used by context to configure the session manager's inactivity timeout. * * The SessionManager may have some default session time out, the * Context on the other hand has it's timeout set by the deployment * descriptor (web.xml). This method lets the Context conforgure the * session manager according to this value. * minutes The session inactivity timeout in minutes. */ public void setSessionTimeOut(int minutes) { if(-1 != minutes) { // The manager works with seconds... inactiveInterval = (minutes * 60); } Comp1 package org.apache.tomcat.session; import org.apache.tomcat.core.*; import org.apache.tomcat.util.StringManager; import java.io.*; import java.net.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; /** * Core implementation of a server session * James Duncan Davidson James Todd */ public class ServerSession { private StringManager sm = StringManager.getManager("org.apache.tomcat.session"); private Hashtable values = new Hashtable(); private Hashtable appSessions = new Hashtable(); private String id; private long creationTime = System.currentTimeMillis();; private long thisAccessTime = creationTime; private long lastAccessed = creationTime; private int inactiveInterval = -1; ServerSession(String id) { this.id = id; } public String getId() { return id; } public long getCreationTime() { return creationTime; } public long getLastAccessedTime() { return lastAccessed; } public ApplicationSession getApplicationSession(Context context, boolean create) { ApplicationSession appSession = (ApplicationSession)appSessions.get(context); if (appSession == null && create) { // XXX // sync to ensure valid? appSession = new ApplicationSession(id, this, context); appSessions.put(context, appSession); } // XXX // make sure that we haven't gone over the end of our // inactive interval -- if so, invalidate and create // a new appSession return appSession; } void removeApplicationSession(Context context) { appSessions.remove(context); } /** * Called by context when request comes in so that accesses and * inactivities can be dealt with accordingly. */ void accessed() { // set last accessed to thisAccessTime as it will be left over // from the previous access lastAccessed = thisAccessTime; thisAccessTime = System.currentTimeMillis(); } void validate() void validate() { // if we have an inactive interval, check to see if // we've exceeded it if (inactiveInterval != -1) { int thisInterval = (int)(System.currentTimeMillis() - lastAccessed) / 1000; if (thisInterval > inactiveInterval) { invalidate(); ServerSessionManager ssm = ServerSessionManager.getManager(); ssm.removeSession(this); } synchronized void invalidate() { Enumeration enum = appSessions.keys(); while (enum.hasMoreElements()) { Object key = enum.nextElement(); ApplicationSession appSession = (ApplicationSession)appSessions.get(key); appSession.invalidate(); } public void putValue(String name, Object value) { if (name == null) { String msg = sm.getString("serverSession.value.iae"); throw new IllegalArgumentException(msg); } removeValue(name); // remove any existing binding values.put(name, value); } public Object getValue(String name) { if (name == null) { String msg = sm.getString("serverSession.value.iae"); throw new IllegalArgumentException(msg); } return values.get(name); } public Enumeration getValueNames() { return values.keys(); } public void removeValue(String name) { values.remove(name); } public void setMaxInactiveInterval(int interval) { inactiveInterval = interval; } public int getMaxInactiveInterval() { return inactiveInterval; } // XXX // sync'd for safty -- no other thread should be getting something // from this while we are reaping. This isn't the most optimal // solution for this, but we'll determine something else later. synchronized void reap() { Enumeration enum = appSessions.keys(); while (enum.hasMoreElements()) { Object key = enum.nextElement(); ApplicationSession appSession = (ApplicationSession)appSessions.get(key); appSession.validate(); } Comp2 package org.apache.tomcat.session; import org.apache.tomcat.util.*; import org.apache.tomcat.core.*; import java.io.*; import java.net.*; import java.util.*; import javax.servlet.http.*; /** * James Duncan Davidson Jason Hunter James Todd */ public class ServerSessionManager implements SessionManager { private StringManager sm = StringManager.getManager("org.apache.tomcat.session"); private static ServerSessionManager manager; // = new ServerSessionManager(); protected int inactiveInterval = -1; static { manager = new ServerSessionManager(); } public static ServerSessionManager getManager() { return manager; } private Hashtable sessions = new Hashtable(); private Reaper reaper; private ServerSessionManager() { reaper = Reaper.getReaper(); reaper.setServerSessionManager(this); reaper.start(); } public void accessed( Context ctx, Request req, String id ) { ApplicationSession apS=(ApplicationSession)findSession( ctx, id); if( apS==null) return; ServerSession servS=apS.getServerSession(); servS.accessed(); apS.accessed(); // cache it - no need to compute it again req.setSession( apS ); } public HttpSession createSession(Context ctx) { String sessionId = SessionIdGenerator.generateId(); ServerSession session = new ServerSession(sessionId); sessions.put(sessionId, session); if(-1 != inactiveInterval) { session.setMaxInactiveInterval(inactiveInterval); } return session.getApplicationSession( ctx, true ); } public HttpSession findSession(Context ctx, String id) { ServerSession sSession=(ServerSession)sessions.get(id); if(sSession==null) return null; return sSession.getApplicationSession(ctx, false); } // XXX // sync'd for safty -- no other thread should be getting something // from this while we are reaping. This isn't the most optimal // solution for this, but we'll determine something else later. synchronized void reap() { Enumeration enum = sessions.keys(); while (enum.hasMoreElements()) { Object key = enum.nextElement(); ServerSession session = (ServerSession)sessions.get(key); session.reap(); session.validate(); } synchronized void removeSession(ServerSession session) { String id = session.getId(); session.invalidate(); sessions.remove(id); } public void removeSessions(Context context) { Enumeration enum = sessions.keys(); while (enum.hasMoreElements()) { Object key = enum.nextElement(); ServerSession session = (ServerSession)sessions.get(key); ApplicationSession appSession = session.getApplicationSession(context, false); if (appSession != null) { appSession.invalidate(); } /** * Used by context to configure the session manager's inactivity timeout. * * The SessionManager may have some default session time out, the * Context on the other hand has it's timeout set by the deployment * descriptor (web.xml). This method lets the Context conforgure the * session manager according to this value. * minutes The session inactivity timeout in minutes. */ public void setSessionTimeOut(int minutes) { if(-1 != minutes) { // The manager works with seconds... inactiveInterval = (minutes * 60); } An AspectJ example Advice Pointcut

Quantification Over a Domain Model Apply AO Weaving concepts to Model-based systems  Weavers ‘Decorate’ Models with attributes & constraints  Weavers compose new model constructs … select(p | p.name() == “Model*” && p.kind() == “StateFlow”)->Strategy3(); … Strategy1 Strategy2 Strategy3 StrategyN Modeling Pointcut Domain-specific Strategies Model

Constructing Model Weavers

Domain-Specific Weavers + General Motors Factory GM specific weaverDuPont specific weaver DuPont Chemical Factory Boeing Bold Stroke Bold Stroke specific weaver + + Example: Evidence of “meta” in the corresponding XML of each of the above models

The Metaweaver Framework Strategy Code Generator Strategies (C++) Strategies Modeling Pointcuts strategy ApplyConstraint(constraintName : string, expression : string) { addAtom("OCLConstraint", "Constraint", constraintName).addAttribute("Expression", expression); } strategy RemoveConstraint(constraintName : string) { findAtom(constraintName).removeChild(); } strategy ReplaceConstraint(constraintName : string, expression : string) { RemoveConstraint(constraintName); ApplyConstraint(constraintName, expression); } XML ( Model Hierarchy )

Embedded Constraint Language Arithmetic Operators +, -, *, /, =,, =, <> Logical Operators and, or, xor, not, implies, if/then/else Collection Operator -> Property Operator. Standard OCL Collection Operators collection->size() : integer collection->forAll( x | f(x) ) : Boolean collection->select( x | f(x) ) : collection collection->exists( x | f(x) ) : Boolean Included OCL Operators

Embedded Constraint Language Traditional OCL has been strictly a declarative query language New uses require an imperative procedural style Addition of side effects into model  Examples: addAtom(…), findAtom(…) addAttribute(…), findAttribute(…) removeNode(…) Support for recursion Chaining of strategies (procedure calls)  Inlined C++ code

List of ECL Operators Aggregates folders, models, atoms, attributes, connections Connections connpoint, target, refs, resolveRefeeredID, resolveIDReferred Transformation addAttribute, addAtom, addModel, addConnection, removeNode Selection findFolder, findModel, findAtom, findAttributeNode General id, parent, getID, getInt, getStr

Example: Processor Assignment Weapons deployment WCET=150ms Latency < 20ms Sensor Update Map MapDB Σ (x,y,z) Display (x,y,z) 100 Hz WCET=1ms Latency < 5ms WCET=2ms WCET=4ms Weapon Release Latency < 10msLatency < 2ms

Processor Assignment: Component Interaction Model

Processor Assignment: Component Internals

Processor Assignment: Modeling Pointcut aspect ProcessorAssignment { models("")->select(m | m.kind() == “Comp*")->Assign(10); }

Processor Assignment: Strategy strategy Assign(limit : integer){ declare static accumulateWCET, processNum : integer; declare currentWCET : integer; self.compute.WCET.getInt(currentWCET); accumulateWCET := accumulateWCET + currentWCET; if (limit < accumulateWCET) then accumulateWCET := currentWCET; processNum := processNum + 1; endif; <<CComBSTR aConstraint = "self.assignTo()=processor" + XMLParser::itos(processNum); >> AddConstraint("ProcessConstraint", aConstraint); }

Processor Assignment: Weaved Constraint self.assignTo() = processor0 strategy Assign(limit : integer){ declare static accumulateWCET, processNum : integer; declare currentWCET : integer; self.compute.WCET.getInt(currentWCET); accumulateWCET := accumulateWCET + currentWCET; if (limit < accumulateWCET) then accumulateWCET := currentWCET; processNum := processNum + 1; endif; <<CComBSTR aConstraint = "self.assignTo()=processor" + XMLParser::itos(processNum); >> AddConstraint("ProcessConstraint", aConstraint); }

Code Generation Example Consider the following, which appears in an EagerLazy strategy: … components.models()->select(c | c.id() == refID)->eagerLazy(…); …

Code Generation Example CComPtr models0 = XMLParser::models(components, ""); nodeTypeVector selectVec1 = XMLParser::ConvertDomList(models0); nodeTypeVector selectVecTrue1 = new std::vector ; vector ::iterator itrSelect1; for(itrSelect1 = selectVec1->begin(); itrSelect1 != selectVec1->end(); itrSelect1++) { nodeType selectNode1 = (*itrSelect1); nodeType c; c = selectNode1; CComBSTR id0 = XMLParser::id(c); ClData varforward1(id0); ClData varforward2(referredID); bool varforward3 = varforward1 == varforward2; if(varforward3) selectVecTrue1->push_back(*itrSelect1); } vector ::iterator itrCollCall1; for(itrCollCall1 = selectVecTrue1->begin(); itrCollCall1 != selectVecTrue1->end(); itrCollCall1++) eagerLazy::apply(…);

Sample XMLParser Methods nodeType XMLParser::addAtom(nodeType self, CComBSTR kind, CComBSTR role, CComBSTR name) { return addNode(self, "atom", kind, role, name); } nodeType XMLParser::findModel(nodeType aNode, CComBSTR name) { CComBSTR bstrFind(L"./model[name=\""); bstrFind.Append(name); bstrFind.Append("\"]"); return submitXPath(aNode, bstrFind); } CComBSTR XMLParser::id(nodeType aNode) { CComBSTR res; CComPtr attr = XMLParser::findAttribute (aNode, "id"); XMLParser::getStr(attr, res); return res; }

Summary Strategies (C++) Meta-weaver Framework Domain-Specific Strategies strategy ApplyConstraint(constraintName : string, expression : string) { addAtom("OCLConstraint", "Constraint", constraintName).addAttribute("Expression", expression); } strategy RemoveConstraint(constraintName : string) ApplyConstraint(constraintName, expression); } Domain-specific strategies (encoded in a DSL) are used to instantiate a new model weaver Modeling Pointcuts Domain-specific Models B c d e constraint FOOB2 { // apply a specific constraint to “B2” only in Structural models("ProcessingCompound")-> // apply a specific constraint to all nodes beginning with “B” - use wildcard in Structural models("ProcessingCompound")-> select(p | p.name() == "B*")->PowerStrategy(1, 100); } Specification aspects and base model are sent through the weaver Constrained Models B c d e The weaver distributes constraints across the base model New Two-level aspect weaving (see upcoming AOSD book)

Summary Benefits of this Approach The modeler can now perform various “what-if” scenarios using modeling constraints  Impossible in previous approach  Constraints can be plugged/unplugged in model Because much of the redundancy of constraint application is removed, the effect of each constraint on the global system can be better understood. This localization of constraints improves modular reasoning. Allows for the rapid construction of new domain- specific weavers  Strategies are specified using a DSL  Generated code is at a much lower level

For more information Please give us another week to upgrade site:  gray (at) cis.uab.edu  GME (freely available):  OMG MIC PSIG: 

A Concluding Quote “Even for this let us divided live…That by this separation I may give that due to thee which thou deservest alone.” William Shakespeare, Sonnet XXXIX

Extra slides

Tool Independence Requires an exposed API for accessing internal model data structures Tool-specific adapters written for each new supported tool Cadena GME MetaEdit Rose

Adaptive Core Weaving Engine

Not unlike AspectJ AJDT JBuilder Eclipse emacs Netbeans/FORTE AJDT