300 likes | 641 Views
MOF Meta-Models and UML Profiles. Jacques Robin. Outline. MDA’s modeling level hierarchy Purposes of meta-models in MDA Meta-Object Facility (MOF): a standard language for meta-modeling Modeling with software abstractions beyond UML UML Profiles KobrA-2 Multi-Agent Simulation.
E N D
MOF Meta-Models and UML Profiles Jacques Robin
Outline • MDA’s modeling level hierarchy • Purposes of meta-models in MDA • Meta-Object Facility (MOF): a standard language for meta-modeling • Modeling with software abstractions beyond UML • UML Profiles • KobrA-2 • Multi-Agent Simulation
Meta-Meta-Model Meta-Model Model MDA’s Modeling Level Hierarchy MOF + OCL Level M3 MOF + OCL Level M2 UML + OCL AND -OR UML Profile AND -OR Special Purpose Modeling Language Level M1 Running Application Implementation Running on Platform Level M0
system +name actor +name useCase +title Example Meta-Model inherits 1 .. * extends CMOF Meta-Model of Use-Cases (simplified) 0 ..* participates case 0 ..1 includes e-Store OrderItem UML Model: Use-Case Diagram ValidateCart
association +name class +name operation +name parameter +direction associationEnd +name +multi attribute +name +multi system +name actor +name useCase +title package +name Example Meta-Meta-Model CMOF Meta-Model of CMOF Meta-Model (Simplified) inherits 1 .. * extends CMOF Meta-Model of UML Use-Cases (Simplified) participates 0 ..* case 0 ..1 includes
Purposes of Meta-Models in MDA • Define modeling languages • Their abstract syntax • Their formal semantics • Define source and target anchors for model transformations • What about APIs and Libraries? • They are all written in a given language • They are thus best viewed as built-in model elements to reuse than as part of a modeling language • Thus they should be part of platform models, not of language meta-models
What is Meta-Modeling? • Meta-Modeling vs. Modeling • Similar formalisms but different purposes • One models applications and meta-models languages and formalisms • Meta-Modeling vs. Ontology Engineering • An ontology is a domain knowledge model, not a meta-model • But a domain is an intermediate level of abstraction and generality between application and language • Meta-Modeling Methodologies • Uncharted territory • Should integrate and reuse principles and techniques from: • Application modeling (formalism similarities) • Language design (purpose similarities) • Ontology engineering (process similarities)
OMG’s Meta-Object Facility (MOF) • Key idea: • Instead of defining entirely new languages for the M2 and M3 levels • Reuse structural core of mature, well-known, well-tooled M1 level language (UML Infra-Structure) • Advantages of MOF over traditional formalisms such as grammars to define languages: • Abstract instead of concrete syntax (more synthetic) • Visual notation instead of textual notation (clarity) • Graph-based instead of tree-based (abstracts from any reader order) • Entities (classes) have internal structure and behavior (strings do not) • Relations include generalization and undirected associations instead of only order • Specification reuse through inheritance • Additional advantages with OCL: • Allows expressing arbitrary complex constraints among language elements (more expressive) • Allows defining formal semantics without mathematical syntax
UML2 Infra-Structure MOF2 MOFMeta-Model Package Structure
Essential MOF (EMOF) Meta-Model • Minimum bootstrap elements for modeling, meta-modeling and MDA tools • Includes only classes, attributes, operations, packages and primitive types from UML2 Infra-Structure • Does not includes associations, which are replaces by references (properties whose values are classes instead of primitive types) • Any CMOF meta-model can be transformed into an EMOF meta-model • EMOF extends UML2 Infra-Structure with elements to represent: • Instances and their reflective relations with classes • Language extension mechanisms
EMOF Meta-Model: Elements Absent from UML2 Infra • Reflection package: • Views any model element as an instance of a meta-model meta-class • Provide operations that cut across MDA layers to manipulate model and meta-model elements as meta-objects of their meta-classes • Provides meta-meta-model of a generic reflective API to programmatically manipulate models
Identifiers package OID: class property with feature isID true Extent: OID value range useContainment: when true, all contained elements are added to containing element’s extents Elements(): returns extent members URIextent: extent where OIDs are URIs instead of properties Extention package Any element can be tagged to extend modeling language vocabulary EMOF Meta-Model: Elements Absent from UML2 Infra
UseCase +title: String +extends: UseCase +includes: UseCase System +name: String +case: UseCase Actor +name: String +inherits: Actor +participates: UseCase Example of EMOF Meta-Model EMOF Meta-Model of EMOF (simplified) Class Attribute Reference EMOF Meta-Model of Use-Cases (simplified) e-Store OrderItem UML Model: Use-Case Diagram ValidateCart
Tailored Modeling with Software Abstractions Beyond UML • Software abstractions beyond UML can be classified as: • Specializing UML abstractions (i.e., UML2 meta-model elements) • Generalizing UML abstractions • Being unrelated to UML abstractions • Approaches: • No MOF, no UML (the Microsoft way) • Create and use domain-specific or even application-specific meta-modeling, modeling and model transformation languages • Pure MOF, no UML: • Create domain-specific or application-specific modeling language that does not reuse any UML meta-model element but is specified as a MOF meta-model • MOF meta-model reuse operators applied to UML packages: • Define MOF meta-model of new modeling language that reuses UML meta-model elements and add new ones • UML Profile approach (the IBM way) • Define specializations of UML abstractions by stereotyping UML meta-model elements • Can be carried out as follows: • Define MOF meta-model of new modeling language • Associate every top-level element in this meta-model to a stereotype of some generalizing UML meta-model elements
D1, D2 Meta-Models in D2 Model in Language D1 Tailored Modeling: Domain-Specific Meta-Modeling and Modeling Approach • Advantage: • Perhaps easier to integrate with Visual Studio? • Drawbacks: • For each new domain or application • Need to redefine entire MDA language infra-structure alternative to OMG´s • Need to implement CASE tools for non-standard languages GUI Editor for D2 Diagrams GUI Editor for D1 Diagrams D1 Model Repository
D Meta-Model in MOF Model in Dedicated Language D Tailored Modeling: Pure MOF Approach • Pure MOF approach • Does not use UML • Advantages: • No need to artificially relate new abstractions to UML abstractions • Drawbacks: • Need to define entirely new meta-model that does not reuse any elements consolidated by OMG’s long meta-modeling experience • Need to develop entirely new graphical notation and editors • Need to develop all model manipulation services (code generation, test generation, reverse engineering) that UML CASE tools already provide UML Editor GUI Editor for D Diagrams EMF generates Menu Editor for D Diagrams
UML2 Meta-Model in MOF D Meta-Model in MOF Model in Dedicated Language D Tailored Modeling:Meta-Model and MOF Reuse Operators • Advantages: • Reuses consolidated elements from UML2 meta-model • Drawbacks: • Need to extend UML’s graphical editors to draw elements in D – UML2 • Need to extend model manipulation services (code generation, test generation, reverse engineering) of UML CASE to modeling elements in D – UML2 • Current MOF operators do not cover UML2 concept generalizing reuse, only reuse “as is” or as specialization << reuse >> UML Editor GUI Editor for D Diagrams EMF generates Menu Editor for D Diagrams
P UML2 Profile Model in Dedicated UML2 Profile P UML2 Meta-Model in MOF Tailored Modeling: UML Profile Approach • UML2 meta-classes sub-categorized by stereotypes • Sub-meta-class x stereotype: • The instances of a sub-meta-class S of meta-class G are direct instances of S, not of G • The instances of a meta-class G stereotyped by S are direct instances of G, for a stereotype has no proper instances • Advantages: • Maximum reuse the entire OMG language infra-structure • Maximum reuse of UML CASE tools (no need to develop any new tool) • Drawbacks: • Risk to “artificially” recast modeling abstraction as specializations of UML ones • Little to reuse for non-object oriented modeling languages EMF meta-class Package Class * * * Profile Stereotype ExtensionEnd Extension UML Editor * icon * Image Property Association ProfileApplication
Example Profile: KobrA-2 Component • Restricts UML2 meta-model to the subset of elements used as artifacts following the KobrA-2 methodology • Goals of upgrading KobrA-1 into KobrA-2: • Leverage latest MDA standards: UML2 (especially UML2 components), OCL2, MOF2, SPEM • Extend process to PSM modeling and implementation • Turn process more model-driven by: • Clearly distinguishing between CIM and PIM • Substitute all tabular natural language artifacts by OCL constraints and expressions • Formalize process in SPEM • Extend process with sub-steps dedicated to GUI development
K2CIMStructure K2StructureModel K2CIM K2CIMBehavior K2PIMStructureSpecification K2PIMSpecification K2PIMBehaviorSpecification K2PIM K2PIMStructureRealization K2PIMRealization K2PIMBehaviorRealization nestedArtifact K2JPMSStructureSpecification Artifact KobrA2Component K2JPSMpecification K2JPSMBehaviorSpecification K2JavaPSM K2JPSMStructurelRealization K2JPSMRealization K2JPSMBehaviorRealization K2JavaCode K2BehaviorSpecificationModel KobrA-2 UML2 Profile K2BehaviorRealizationModel
1..* K2StructureModel K2ClassDiagram 1..* * 1..* * 1..* Dependency Component Class Association Interface 1..* Port Artifact Manifestation InstanceSpecification 1..* K2ObjectDiagram 0..* Connector ComponentInstance Object Link 1..* * * 1..* KobrA-2 UML2 Profile 1..* K2ContractConstraint K2BehaviorSpecificationModel Artifact Manifestation 0..* ProtocolStateMachine K2StateChart * K2BehaviorRealizationModel K2ActivityDiagram Activity 1..* * * Constraint Artifact Manifestation valueSpecification * K2SequenceDiagram Interaction OpaqueExpression * OpaqueBehavior ExpressionInOCL
MAS ReflexAgent 2..* ReasoningComponent Agent MAS Environment Agent ReasoningComponent 1..* 1..* Sensor 1..* 1..* 1..* 1..* ReflexAgent ReflexComponent Actuator Percept Sensor Actuator AgentAction 1..* AutomataAgent GoalBasedAgent AutomataAgent Agent GoalBasedAgent AutomataAgent 1..* 3..* 4..* Goal ReasoningComponent ReasoningComponent Sensor EnvironmentStateModel PercpetInterpretationComponent EnvironmentStateModel GoalInitializationComponent ModelInitializationComponent GoalUpdateComponent RamificationComponent GoalBasedBehaviorStrategyComponent ModelBasedBehaviorStrategyComponent ModelBasedBehaviorStrategyComponent Actuator MOF Meta-Model of a Simple Multi-Agent Simulations Modeling Language (MASML)
ReflexKBAgent ReflexAgent ReflexComponent ReflexKBAgent ReflexKBComponent ReflexKB PersistentKB KBAgent KBComponent context ReflexKBComponent inv Volat ileKB.isEmpty() GoalBasedKBAgent GoalBasedAgent AutomataKBAgent AutomataAgent 6..* GoalBasedKBAgent KBComponent 3 ..* 4 ..* 4..* AutomataKBAgent KBComponent 4 ..* KBAgent GoalKB EnvironmentStateModelKB KBAgent EnvironmentStateModelKB EnvironmentStateModel VolatileKB Goal VolatileKB EnvironmentStateModel MOF Meta-Model of a Simple Multi-Agent Simulations Modeling Language (MASML) KBAgent 1..* Agent ReasoningComponent KnowledgeBase KBSentence 1..* PersistentKB KBAgent KBComponent VolatileKB 1..* 0..*
MASML Meta-Model UML2 Meta-Model Component isActive = true Component Port Signal Model UML2 Profile for MAS MAS Environment Agent ReasoningComponent Sensor Actuator Percept AgentAction EnvironmentStateModel KnowledgeBase KBSentence
Available UML Profiles • By OMG: • Enterprise Application Integration (application interoperability through standard metadata) • Enterprise Distributed Object Computing (EDOC) • QoS and Fault Tolerance • Schedulability, Performance and Time • Testing • Third parties: • Enterprise Java Beans (by Java Community Process) • Software Services (by IBM, supported by Rational Software Architect UML CASE tool) • Knowledge-Based Systems (University of York) • Data Modeling (by agiledata.org) • Framework Architectures (UML-F) • Requirement Engineering with KAOS • Formal Methods in B (UML-B) • Embedded System Design