Eclipse Modeling Framework

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Eclipse Modeling Framework - Presentation Transcript

    1. Eclipse Modeling Framework
      ajaykemparaj@gmail.com
      http://www.theenmusketeers.com
      EMF
    2. What is Eclipse ?
      Eclipse is a Java IDE
      Eclipse is an IDE Framework
      Eclipse + JDT = Java IDE
      First class framework for Java
      Language aware editor
      Incremental build
      Integrated debugging
      Eclipse + CDT = C/C++ IDE
      First class framework for C/C++
      Language aware editor
      Refactoring, search
      Eclipse + PHP = PHP IDE
      Eclipse + JDT + CDT + PHP = Java, C/C++, PHP IDE
      ………….
    3. Plug-in
      Plug-in
      Plug-in
      Eclipse is a Tools Framework
      Tools extend the Eclipse platform using plug-ins
      Business Intelligence and Reporting Tools (BIRT)
      Eclipse Communications Framework (ECF)
      Web Tools Project (WTP)
      Eclipse Modelling Framework (EMF)
      Graphical Editing Framework (GEF)
      Test and Performance Tooling Project (TPTP
    4. Eclipse is a Application Framework
      Remove the IDE elements, Java language support, team development support, … and you’re left with a pretty comprehensive general application framework
      Support for multiple platforms
      Linux, Windows, Mac OSX, UNIX, embedded
      Rich widget set, graphics
      Native-OS integration (drag and drop, OLE/XPCOM integration)
      A platform for rich clients
    5. Eclipse is all these things
      A Java IDE
      An IDE Framework
      A Tools Framework
      An Application Framework
      An Open Source Enabler
      A community
      An eco-system
      A foundation
    6. Model Driven Architecture (MDA)
      • A software architecture proposed by the OMG (Object Management Group)
      • Application specified in high-level, Platform Independent Model (PIM)
      • Transformation technologies used to convert PIM to
      Platform Specific Model (PSM), implementation code
      • Includes several open modeling standards:
      UML™ (Unified Modeling Language)
      MOF (Meta-Object Facility)
      XMI (XML Metadata Interchange)
      CWM (Common Warehouse Model)
    7. What is EMF ?
      EMF is a simple, pragmatic approach to modeling:
      Allows us to generate some of the code that we write over and over, paving the way for more complex systems
      Models are simple, but meant to be mixed with hand-written code
      It’s real, proven technology (since 2002)
    8. What EMF is ?
      • A Model for describing other Model (Meta Model)
      • Runtime Emulator for your model
      • generator for Java Implementation of your Model
      EMF is a framework converting various forms of model into core model description called Ecore
    9. Why EMF ?
      EMF is middle ground in the modeling vs. programming worlds
      Focus is on class diagram subset of UML modeling (object model)
      Transforms models into Java code
      Provides the infrastructure to use models effectively in your application
      Very low cost of entry
      EMF is free and open source
      Full scale graphical modeling tool not required
      Reuses your knowledge of UML, XML Schema, or Java
      It’s real, proven technology (since 2002)
    10. Some of Eclipse projects which are using EMF
      • Tools Project: UML2 and Visual Editor (VE)
      • Web Tools Platform (WTP) Project
      • Test and Performance Tools Platform (TPTP) Project
      • Business Intelligence and Reporting Tools (BIRT) Project
      • Data Tools Platform (DTP) Project
      • Modeling : Graphical Modeling Framework (GMF)
    11. What is an EMF “Model”?
      • Specification of an application’s data
      Object attributes
      Relationships (associations) between objects
      Operations available on each object
      Simple constraints (e.g. multiplicity) on objects and relationships
      • Essentially, the Class Diagram subset of UML
    12. EMF Architecture
    13. EMF Components
      • Core Runtime
      Notification framework
      Ecore meta model
      Persistence (XML/XMI), validation, change model
      • EMF.Edit
      Support for model-based editors and viewers
      Default reflective editor
      • Codegen
      Code generator for application models and editors
      Extensible model importer/exporter framework
    14. The Ecore(Meta) Model
      • EMF’s metamodel (model of a model)
    15. Model Sources
      • EMF models can be defined in (at least) three ways:
      1. Java Interfaces
      2. UML Class Diagram
      3. XML Schema
    16. Java Interfaces
      public interface Item
      {
      String getProductName();
      void setProductName(String value);
      intgetQuantity();
      void setQuantity(int value)
      float getPrice();
      void setPrice(float value);
      }
      public interface PurchaseOrder
      {
      String getShipTo();
      void setShipTo(String value);
      String getBillTo();
      void setBillTo(String value);
      List getItems(); // List of Item
      }
      • Classes can be defined completely by a subset of members, supplemented by annotations
    17. UML Class Diagram
      • Built-in support for Rational Rose®
      • UML2 support available with UML2 (from MDT)
    18. XML Schema
      <?xml version="1.0" encoding="UTF-8"?>
      <xsd:schemaxmlns:xsd="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.com/SimplePO"
      xmlns:po="http://www.example.com/SimplePO">
      <xsd:complexType name="PurchaseOrder">
      <xsd:sequence>
      <xsd:element name="shipTo" type="xsd:string"/>
      <xsd:element name="billTo" type="xsd:string"/>
      <xsd:element name="items" type=“po:Item"
      minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="Item">
      <xsd:sequence>
      <xsd:element name="productName" type="xsd:string"/>
      <xsd:element name="quantity" type="xsd:int"/>
      <xsd:element name="price" type="xsd:float"/>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:schema>
    19. Direct Ecore Modeling
      • Ecore models can be created directly
      Sample Ecore editor (in EMF)
      Ecore Tools graphical editor (from EMFT)
    20. Code Generation (Simple)
    21. Code Generation (Full)
    22. Generated Model Code
      • Interface and implementation for each modeled class
      Includes get/set accessors for attributes and references
      Interface
      public interface PurchaseOrder extends EObject
      {
      String getShipTo();
      void setShipTo(String value);
      String getBillTo();
      void setBillTo(String value);
      EList<Item> getItems();
      }
      Implementation Class
      public class PurchaseOrderImpl extends EObjectImpl
      implements PurchaseOrder
      {
      ...
      }
    23. Change Notification
      • Every EObject is also a notifier
      Sends notification whenever an attribute
      or reference is changed
      Observers can update views, dependent
      objects
      Observers are also adapters
      Adapter
      Adapter adapter = ...
      purchaseOrder.eAdapters().add(adapter);
    24. Factories and Packages
      • Factory to create instances of model classes
      • Package provides access to metadata
      POFactory factory = POFactory.eINSTANCE;
      PurchaseOrder order = factory.createPurchaseOrder();
      POPackagepoPackage = POPackage.eINSTANCE;
      EClassitemClass = POPackage.Literals.ITEM;
      //or poPackage.getItem()
      EAttributepriceAttr = POPackage.Literals.ITEM__PRICE;
      //or poPackage.getItem_Price()
      //or itemClass.getEStructuralFeature(POPackage.ITEM__PRICE)
    25. Persistence
      • Persisted data is referred to a resource
      • Objects can be spread out among a number of
      resources, within a resource set
      • Proxies represent referenced objects in other
      resources
    26. Resource Set
      • Context for multiple resources that may have references among them
      • Usually just an instance of ResourceSetImpl
      • Provides factory method for creating new resources in the set
      ResourceSetrs = new ResourceSetImpl();
      URI uri = URI.createFileURI("C:/data/po.xml");
      Resource resource = rs.createResource(uri);
      • Also provides access to the registries, URI converter
      and default load options for the set
    27. Resource
      • Container for objects that are to be persisted together
      • Convert to and from persistent form via save() and load()
      • Access contents of resource via getContents()
      URI uri = URI.createFileURI("C:/data/po.xml");
      Resource resource = rs.createResource(uri);
      resource.getContents().add(p1);
      resource.save(null);
      • EMF provides generic XMLResource implementation
      • Other, customized implementations.
      <PurchaseOrder>
      <shipTo>John Doe</shipTo>
      <next>p2.xml#p2</next>
      </PurchaseOrder>
    28. Registries
      • Resource Factory Registry
      • Returns a resource factory for a given type of resource
      • Based on URI scheme, filename extension or content type
      • Determines the format for save/load
      • If no registered resource factory found locally, delegates to
      global registry: Resource.Factory.Registry.INSTANCE
      • Package Registry
      • Returns the package identified by a given namespace URI
      • Used during loading to access factory for instantiating classes
      • If no registered package found locally, delegates to global
      registry: EPackage.Registry.INSTANCE
    29. Reflective EObject API
      • All EMF classes implement EObject interface
      • Provides an efficient API for manipulating objects
      reflectively
      Used by framework (e.g. persistence framework, copy utility,
      editing commands)
      public interface EObject
      {
      EClasseClass();
      Object eGet(EStructuralFeaturesf);
      void eSet(EStructuralFeaturesf, Object val);
      ...
      }
    30. Reflective EObject API
      • Efficient generated switch-based implementation of reflective methods
      public Object eGet(intfeatureID, ...)
      {
      switch (featureID)
      {
      case POPackage.PURCHASE_ORDER__ITEMS:
      return getItems();
      case POPackage.PURCHASE_ORDER__SHIP_TO:
      return getShipTo();
      case POPackage.PURCHASE_ORDER__BILL_TO:
      return getBillTo();
      ...
      }
      ...
      }
    31. Regeneration and Merge
      • The EMF generator is a merging generator
      /**
      * <!-- begin-user-doc -->
      * <!-- end-user-doc -->
      * @generated
      */
      public String getName()
      {
      return name;
      }
      •@generated elements are replaced/removed
      • To preserve changes mark @generated NOT
    32. Recording Changes
       EMF provides facilities for recording the changes made to
      instances of an Ecore model
       Change Model
       An EMF model for representing changes to objects
       Directly references affected objects
       Includes “apply changes” capability
       Change Recorder
       EMF adapter
       Monitors objects to produce a change description (an instance of
      the change model)
    33. Change Recorder
       Can be attached to EObjects, Resources, and ResourceSets
       Produces a description of the changes needed to return to the
      original state (a reverse delta)
      PurchaseOrder order = ...
      order.setBillTo("123 Elm St.");
      ChangeRecorder recorder = new ChangeRecorder();
      recorder.beginRecording(Collections.singleton(order));
      order.setBillTo("456 Cherry St.");
      ChangeDescription change = recorder.endRecording();
       Result: a change description with one change, setting billTo to
      “123 Elm St.”
    34. Diagnostician
      • Diagnostician walks a containment tree of objects,
      dispatching to package-specific validators
      Diagnostician.validate() is the usual entry point
      Detailed results accumulated as Diagnostics
      Diagnostician validator = Diagnostician.INSTANCE;
      Diagnostic diagnostic = validator.validate(order);
      if (diagnostic.getSeverity() == Diagnostic.ERROR)
      {
      // handle error
      }
      for (Diagnostic child : diagnostic.getChildren())
      {
      // handle child diagnostic
      }
    35. Demo
      Creation of ecore
      Code Generation
      Code Walkthrough
    36. Resources
      • EMF documentation in Eclipse Help Overviews, tutorials, API reference
      • EMF project Web site
      http://www.eclipse.org/modeling/emf/
      Downloads, documentation, FAQ,newsgroup, Bugzilla, Wiki
      • Eclipse Modeling Framework, by Frank Budinsky Ed Merks
    SlideShare Zeitgeist 2009

    + ajaykemparajajaykemparaj Nominate

    custom

    371 views, 0 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 371
      • 371 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 14
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories