EMF: Eclipse Modeling Framework

EMF: Eclipse Modeling Framework

EMF: Eclipse Modeling Framework

EMF: Eclipse Modeling Framework

eBook

$37.99  $50.59 Save 25% Current price is $37.99, Original price is $50.59. You Save 25%.

Available on Compatible NOOK Devices and the free NOOK Apps.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

EMF: Eclipse Modeling Framework

 

Dave Steinberg

Frank Budinsky

Marcelo Paternostro

Ed Merks

 

Series Editors: Erich Gamma • Lee Nackman • John Wiegand

 

The Authoritative Guide to EMF Modeling and Code Generation

The Eclipse Modeling Framework enables developers to rapidly construct robust applications based on surprisingly simple models. Now, in this thoroughly revised Second Edition, the project’s developers offer expert guidance, insight, and examples for solving real-world problems with EMF, accelerating development processes, and improving software quality.

 

This edition contains more than 40% new material, plus updates throughout to make it even more useful and practical. The authors illuminate the key concepts and techniques of EMF modeling, analyze EMF’s most important framework classes and generator patterns, guide you through choosing optimal designs, and introduce powerful framework customizations and programming techniques. Coverage includes

 

            •           Defining models with Java, UML, XML Schema, and Ecore

            •           NEW: Using extended Ecore modeling to fully unify XML with UML and Java

            •           Generating high-quality code to implement models and editors

            •           Understanding and customizing generated code

            •           Complete documentation of @model Javadoc tags, generator model properties, and resource save and load options

            •           NEW: Leveraging the latest EMF features, including extended metadata, feature maps, EStore, cross-reference adapters, copiers, and content types

            •           NEW: Chapters on change recording, validation, and utilizing EMF in stand-alone and Eclipse RCP applications

            •           NEW: Modeling generics with Ecore and generating Java 5 code

 

About the Authors

 

Dave Steinberg is a software developer in IBM Software Group. He has worked with Eclipse and modeling technologies since joining the company, and has been a committer on the EMF project since its debut in 2002.

 

Frank Budinsky, a senior architect in IBM Software Group, is an original coinventor of EMF and a founding member of the EMF project at Eclipse. He is currently cochair of the Service Data Objects (SDO) specification technical committee at OASIS and lead SDO architect for IBM.

 

Marcelo Paternostro is a software architect and engineer in IBM Software Group. He is an EMF committer and has been an active contributor to several other Eclipse projects. Before joining IBM, Marcelo managed, designed, and implemented numerous projects using Rational's tools and processes.

 

Ed Merks is the project lead of EMF and a colead of the top-level Modeling project at Eclipse. He holds a Ph.D. in Computing Science and has many years of in-depth experience in the design and implementation of languages, frameworks, and application development environments. Ed works as a software consultant in partnership with itemis AG.

 

 

 


Product Details

ISBN-13: 9780132702218
Publisher: Pearson Education
Publication date: 12/16/2008
Series: Eclipse Series
Sold by: Barnes & Noble
Format: eBook
Pages: 744
File size: 29 MB
Note: This product may take a few minutes to download.

About the Author

Dave Steinberg is a software developer in IBM Software Group. He has worked with Eclipse and modeling technologies since joining the company, and has been a committer on the EMF project since its debut in 2002.

 

Frank Budinsky, a senior architect in IBM Software Group, is an original coinventor of EMF and a founding member of the EMF project at Eclipse. He is currently cochair of the Service Data Objects (SDO) specification technical committee at OASIS and lead SDO architect for IBM.

 

Marcelo Paternostro is a software architect and engineer in IBM Software Group. He is an EMF committer and has been an active contributor to several other Eclipse projects. Before joining IBM, Marcelo managed, designed, and implemented numerous projects using Rational's tools and processes.

 

Ed Merks is the project lead of EMF and a colead of the top-level Modeling project at Eclipse. He holds a Ph.D. in Computing Science and has many years of in-depth experience in the design and implementation of languages, frameworks, and application development environments. Ed works as a software consultant in partnership with itemis AG.

 

Table of Contents

Foreword by Richard C. Gronback    xix

Foreword by Mike Milinkovich    xxi

Preface    xxiii

Acknowledgments    xxvii

References    xxix

Part I    EMF Overview    1

Chapter 1    Eclipse    3

1.1    The Projects    4

1.1.1    The Eclipse Project    4

1.1.2    The Modeling Project    5

1.1.3    The Tools Project    5

1.1.4    The Technology Project    5

1.1.5    Other Projects    5

1.2    The Eclipse Platform    6

1.2.1    Plug-In Architecture    6

1.2.2    Workspace Resources    7

1.2.3    Platform UI    7

1.2.4    Rich Client Platform    9

1.3    More Information    9

Chapter 2    Introducing EMF    11

2.1    Unifying Java, XML, and UML    12

2.2    Modeling vs. Programming    15

2.3    Defining the Model    16

2.3.1    The Ecore (Meta) Model    17

2.3.2    Creating and Editing the Model    19

2.3.3    XMI Serialization    20

2.3.4    Java Annotations    21

2.3.5    The Ecore “Big Picture”    23

2.4    Generating Code    23

2.4.1    Generated Model Classes    24

2.4.2    Other Generated “Stuff”    26

2.4.3    Regeneration and Merge    27

2.4.4    The Generator Model    28

2.5    The Runtime Framework    29

2.5.1    Notification and Adapters    29

2.5.2    Object Persistence    31

2.5.3    The Reflective EObject API    35

2.5.4    Dynamic EMF    36

2.5.5    Foundation for Data Integration    38

2.6    EMF and Modeling Standards    39

2.6.1    Unified Modeling Language    39

2.6.2    Meta-Object Facility    39

2.6.3    XML Metadata Interchange    40

2.6.4    Model Driven Architecture    40

Chapter 3    Model Editing with EMF.Edit    41

3.1    Displaying and Editing EMF Models    42

3.1.1    Eclipse UI Basics    43

3.1.2    EMF.Edit Support    45

3.2    Item Providers    46

3.2.1    Content and Label Item Providers    47

3.2.2    Item Property Source    49

3.2.3    Command Factory    50

3.2.4    Change Notification    51

3.2.5    Item Provider Implementation Classes    53

3.3    Command Framework    54

3.3.1    Common Command Framework    55

3.3.2    EMF.Edit Commands    59

3.3.3    EditingDomain    61

3.4    Generating EMF.Edit Code    65

3.4.1    Edit Generation    66

3.4.2    Editor Generation    67

3.4.3    Regenerating EMF.Edit Plug-Ins    68

Chapter 4    Using EMF–A Simple Overview    69

4.1    Example Model: The Primer Purchase Order    70

4.2    Creating EMF Models and Projects    71

4.2.1    Creating an EMF Model from Annotated Java    72

4.2.2    Creating an EMF Project from a Rational Rose Class Model    80

4.2.3    Creating an EMF Project from an XML Schema    86

4.2.4    Creating a Generator Model for an Ecore Model    89

4.2.5    Other Formats    92

4.3    Generating Code    93

4.4    Running the Application    95

4.5    Continuing Development    98

Part II    Defining EMF Models    101

Chapter 5    Ecore Modeling Concepts    103

5.1    Ecore Model Uses    104

5.2    The Ecore Kernel    105

5.3    Structural Features    106

5.3.1    Attributes    110

5.3.2    References    111

5.4    Behavioral Features    112

5.5    Classifiers    113

5.5.1    Classes    114

5.5.2    Data Types    116

5.6    Packages and Factories    118

5.7    Annotations    119

5.7.1    Annotations in EMF    121

5.8    Modeled Data Types    123

5.9    Ecore and User Models    125

Chapter 6    UML    127

6.1    UML Packages    128

6.2    UML Specification for Classifiers    128

6.2.1    Classes    129

6.2.2    Enumerated Types    130

6.2.3    Data Types    131

6.3    UML Specification for Attributes    132

6.3.1    Single-Valued Attributes    132

6.3.2    Multi-Valued Attributes    133

6.3.3    Attributes with a Default Value    133

6.4    UML Specification for References    134

6.4.1    Bidirectional, Non-Containment References    135

6.4.2    Containment References    136

6.4.3    Map References    136

6.5    UML Specification for Operations    138

6.6    Documentation    140

6.7    Ecore Properties in Rational Rose    140

6.7.1    Package Properties    141

6.7.2    Classifier Properties    142

6.7.3    Structural Feature Properties    142

6.7.4    Operation Properties    143

6.7.5    Model Element Properties    144

Chapter 7    Java Source Code    145

7.1    Java Specification for Classes    146

7.1.1    Attributes    147

7.1.2    References    150

7.1.3    Compact Notation for Attributes and References    152

7.1.4    Operations    153

7.2    Java Specification for Enumerated Types    158

7.2.1    Enumeration Literals    158

7.3    Java Specification for Packages    159

7.3.1    Data Types    160

7.4    Java Specification for Maps    161

7.4.1    Explicit Definition of Map Entry Classes in a Package    161

7.4.2    Definition of Map-Typed References, Operations, and Parameters    163

7.5    Java Specification for Annotations    164

Chapter 8    Extended Ecore Modeling    167

8.1    Feature Maps    168

8.1.1    Multiple Features and Cross-Feature Order    168

8.1.2    The FeatureMap Interface    171

8.2    Modeling with Feature Maps    173

8.2.1    UML    173

8.2.2    Annotated Java    175

8.2.3    XML Schema    176

Chapter 9    XML Schema    179

9.1    Schema    180

9.1.1    Schema without Target Namespace    180

9.1.2    Schema with Target Namespace    181

9.1.3    Global Element or Attribute Declaration    182

9.1.4    Element or Attribute Form Default    183

9.1.5    EMF Extensions    183

9.2    Simple Type Definitions    184

9.2.1    Restriction    184

9.2.2    Restriction with Enumeration Facets    186

9.2.3    List Type    188

9.2.4    Union Type    188

9.2.5    Anonymous Type    189

9.2.6    EMF Extensions    190

9.3    Complex Type Definitions    191

9.3.1    Extension and Restriction    192

9.3.2    Simple Content    193

9.3.3    Anonymous Type    194

9.3.4    Abstract Type    194

9.3.5    Mixed Type    195

9.3.6    EMF Extensions    197

9.3.7    Operations    198

9.4    Attribute Declarations    201

9.4.1    ID Attribute    202

9.4.2    ID Reference or URI Attribute    202

9.4.3    Required Attribute    203

9.4.4    Default Value    204

9.4.5    Qualified Attribute    205

9.4.6    Global Attribute    205

9.4.7    Attribute Reference    205

9.4.8    EMF Extensions    206

9.5    Element Declarations    209

9.5.1    AnyType Element    210

9.5.2    ID Element    211

9.5.3    ID Reference or URI Element    211

9.5.4    Nillable Element    213

9.5.5    Default Value    214

9.5.6    Qualified Element    215

9.5.7    Global Element    215

9.5.8    Element Reference    216

9.5.9    Substitution Group    216

9.5.10 EMF Extensions    219

9.6    Model Groups    222

9.6.1    Repeating Model Group    222

9.6.2    Repeating Model Group Reference    224

9.7    Wildcards    225

9.7.1    Element Wildcard    225

9.7.2    Attribute Wildcard    226

9.7.3    EMF Extensions    227

9.8    Annotations    228

9.8.1    Documentation    228

9.8.2    Appinfo    229

9.8.3    Ignored Annotation    229

9.8.4    Non-schema Attribute    230

9.9    Predefined Schema Simple Types    230

9.10 EMF Extensions    232

Part III    Using the EMF Generator    237

Chapter 10    EMF Generator Patterns    239

10.1    Modeled Classes    240

10.1.1    Interfaces and Implementation Classes    240

10.1.2    Accessor Methods    241

10.1.3    Abstract Classes    243

10.1.4    Interfaces    243

10.2    Attributes    243

10.2.1    Simple Attributes    244

10.2.2    Data Type Attributes    245

10.2.3    Enumerated Type Attributes    248

10.2.4    Multi-Valued Attributes    250

10.2.5    Default Values    252

10.2.6    Volatile Attributes    253

10.2.7    Non-Changeable Attributes    254

10.2.8    Unsettable Attributes    255

10.3    References    257

10.3.1    One-Way References    257

10.3.2    Bidirectional References    259

10.3.3    Multiplicity-Many References    261

10.3.4    Non—Proxy-Resolving References    263

10.3.5    Containment References    264

10.3.6    Volatile References    266

10.3.7    Non-Changeable References    267

10.3.8    Unsettable References    268

10.3.9    Map References    269

10.4    Feature Maps    272

10.5    Operations    273

10.6    Class Inheritance    275

10.6.1    Single Inheritance    275

10.6.2    Multiple Inheritance    276

10.6.3    Interface Inheritance and Implementation    277

10.7    Reflective Methods    278

10.7.1    Feature IDs    278

10.7.2    Reflective Accessors    279

10.7.3    Inverse Handshaking Methods    283

10.7.4    Feature ID Conversion Methods    285

10.8    Factories and Packages    287

10.9    Switch Classes and Adapter Factories    291

10.10 Alternative Generator Patterns    295

10.10.1    Performance Optimization    295

10.10.2    Suppression of EMFisms    302

10.11    Customizing Generated Code    305

Chapter 11    EMF.Edit Generator Patterns    309

11.1    Item Providers    310

11.1.1    Content and Label Provider    311

11.1.2    Item Property Source    315

11.1.3    Command Factory    318

11.1.4    Change Notification    319

11.1.5    Object Creation    321

11.2    Item Provider Adapter Factories    327

11.3    Editor    331

11.4    Action Bar Contributor    334

11.5    Wizard    336

11.6    Plug-Ins    337

Chapter 12    Running the Generators    341

12.1    EMF Code Generation    341

12.2    The Generator UI    346

12.3    Generator Model Properties    350

12.3.1    Model Object Properties    350

12.3.2    Package Properties    359

12.3.3    Class Properties    362

12.3.4    Feature Properties    363

12.4    The Command-Line Generator Tools    364

12.4.1    Headless Invocation    365

12.4.2    Rose2GenModel    366

12.4.3    XSD2GenModel    369

12.4.4    Ecore2GenModel    369

12.4.5    Generator    370

12.5    The Generator Ant Tasks    371

12.5.1    emf.Rose2Java    373

12.5.2    emf.XSD2Java    374

12.5.3    emf.Ecore2Java    375

12.6    The Template Format    375

12.6.1    An Example Template    376

12.6.2    Template Extensibility    379

Chapter 13    Example–Implementing a Model and Editor    381

13.1    Getting Started    381

13.2    Generating the Model    384

13.3    Implementing Volatile Features    384

13.4    Implementing Data Types    387

13.5    Running the ExtendedPO2    Editor    392

13.6    Restricting Reference Targets    393

13.7    Splitting the Model into Multiple Packages    396

13.7.1    Resolving Package Dependencies    398

13.7.2    Restricting Reference Targets Revisited    401

13.8    Editing Multiple Resources Concurrently    404

13.8.1    Cross-Document Non-Containment References    404

13.8.2    Cross-Document Containment References    411

Part IV    Programming with EMF    417

Chapter 14    Exploiting Metadata    419

14.1    Packages    419

14.1.1    Accessing Package Metadata Generically    420

14.1.2    Locating Packages    422

14.2    Reflection    426

14.2.1    Creating Objects    426

14.2.2    Interrogating and Modifying Objects    427

14.3    Dynamic EMF    432

14.4    Extended Metadata    437

Chapter 15    Persistence    443

15.1    Overview of the Persistence Framework    443

15.2    The EMF Persistence API    447

15.2.1    URI    447

15.2.2    URIConverter    449

15.2.3    Resource    450

15.2.4    Resource.Factory and Resource.Factory.Registry    456

15.2.5    ResourceSet    459

15.3    XML Resources    462

15.3.1    Default Serialization Format    462

15.3.2    Deserialization    468

15.3.3    Options    470

15.3.4    Dynamic EMF    479

15.3.5    Extended Metadata    482

15.3.6    Other Features    485

15.4    EMF Resource and Resource Factory Implementations    489

15.4.1    Base XML    489

15.4.2    Generic XML    490

15.4.3    XMI    490

15.4.4    Ecore    492

15.4.5    EMOF    492

15.4.6    Generated    493

15.5    Performance Considerations    494

15.5.1    Recommended XML Resource Options    494

15.5.2    Caching Intrinsic IDs    495

15.5.3    Caching Resource URIs    496

15.6    Custom Storage for Active Objects    497

15.6.1    Using an EStore    499

15.6.2    EStore and Generated Classes    500

Chapter 16    Client Programming Toolbox    503

16.1    Tree Iterators and Switches    503

16.2    Adapters    508

16.2.1    Object Adapting    508

16.2.2    Behavioral Extensions    515

16.2.3    Content Adapters    519

16.2.4    Observing Generated Classes    521

16.3    Cross-Referencers    523

16.3.1    Basic Cross-Referencers    523

16.3.2    Cross-Reference Adapters    526

16.4    Copying Objects    529

16.5    Comparing Objects    533

Chapter 17    The Change Model    537

17.1    Describing a Change    537

17.1.1    Applying a Change Description    539

17.1.2    Changing Multi-Valued Features    541

17.1.3    Changing Resources    544

17.2    Change Recording    545

17.2.1    Transaction Atomicity and Rollback    547

Chapter 18    The Validation Framework    549

18.1    Constraints and Invariants    549

18.2    Effects on Generated Code    553

18.3    Invoking Validation    557

18.4    Basic EObject Constraints    563

18.5    XML Schema Constraints    564

Chapter 19    EMF.Edit Programming    567

19.1    Overriding Commands    567

19.2    Customizing Views    573

19.2.1    Suppressing Model Objects    573

19.2.2    Using List and Table Viewers    580

19.2.3    Adding Non-Model Intermediary View Objects    587

Chapter 20 Outside of the Eclipse IDE    599

20.1    Rich Client Platform    599

20.1.1    RCP and EMF    600

20.1.2    Launching an RCP Application    601

20.1.3    Generated Code in an RCP Application    606

20.1.4    Deploying an RCP Application    608

20.2    Stand-Alone Applications    608

20.2.1    Adding EMF to the Class Path    609

20.2.2    Registering the Resource Factory    612

20.2.4    Registering the Package    614

Chapter 21    EMF 2.3 and 2.4    617

21.1    Java 5.0 Support     617

21.1.1    Enumerations     618

21.1.2    Generics     622

21.2    EMF Persistence Enhancements     632

21.2.1    Resource Deletion     633

21.2.2    Content Types     634

21.2.3    Other Enhancements     637

21.3    Other New Features     641

21.3.1    Ecore Validation     642

21.3.2    Reference Keys    643

21.3.3    Annotated Java Model Importer     645

21.4    Resource Options     646

21.4.1    XMLResource Options     647

21.5    Generator Model Properties     648

21.5.1    Model Object Properties     648

21.5.2    Package Properties     651

21.5.3    Enum Properties        652

Appendix A    UML Notation     653

Appendix B    Summary of Example Models     659

Index     675

 

Preface

Preface

This book is a comprehensive introduction and developer’s guide to the Eclipse Modeling Framework (EMF). EMF is a powerful framework and code generation facility for building Java applications based on simple model definitions. Designed to make modeling practical and useful to the mainstream Java programmer, EMF unifies three important technologies: Java, XML, and UML. Models can be defined using a UML modeling tool or an XML Schema, or even by specifying simple annotations on Java interfaces. In this last case, the developer writes just a subset of abstract interfaces that describe the model, and the rest of the code is generated automatically and merged back in.

By relating modeling concepts to the simple Java representations of those concepts, EMF has successfully bridged the gap between modelers and Java programmers. It serves as a gentle introduction to modeling for Java programmers and at the same time as a reinforcement of the modeler’s theory that a great deal of coding can be automated, given an appropriate tool. This book shows how EMF is such a tool. It also shows how using EMF lets you do more with your models that you might have thought possible.

EMF provides a runtime framework that allows any modeled data to be easily validated, persisted, and edited in a UI. Change notification and recording are supported automatically. Metadata is available to enable generic processing of any data using a uniform, reflective API. With all of these features and more, EMF is the foundation for data sharing and fine-grained interoperability among tools and applications in Eclipse, in much the same way that Eclipse is itself a platform for integration at the component and UI level. Numerous organizations are currently using Eclipse, EMF, and the growing number of EMF-based technologies in the Eclipse Modeling Project as the foundation for their own commercial and open source offerings.

This book assumes the reader is familiar with object-oriented programming concepts and specifically with the Java programming language. Previous exposure to modeling technologies such as UML, although helpful, is not required. Part I (Chapters 1 to 4) provides a basic overview of the most important concepts in EMF and modeling. This part teaches someone with basic Java programming skills everything needed to start using EMF to model and build an application. Part II (Chapters 5 to 9) presents a thorough overview of EMF’s metamodel, Ecore, followed by details of the mappings between Ecore and the other supported model-definition forms: UML, annotated Java, and XML Schema. Part III (Chapters 10 to 13) includes detailed analyses of EMF’s code generator patterns and tools, followed by an end-to-end example of a non-trivial EMF application. Finally, Part IV (Chapters 14 to 21) takes a close look at EMF’s runtime framework and discusses important EMF programming techniques.

The bulk of this book is based on EMF 2.2, the last version to support the venerable Java 1.4 language. In version 2.3, EMF adopted key language features of Java 5.0, making it incompatible with previous Java runtimes. EMF 2.2, which was current while much of this book was written, is therefore still popular and an excellent base for learning about the framework. The code in Chapters 1 to 20 is based on that version, but due to EMF’s backward compatibility, all examples run without change on version 2.4, the latest at the time of this book’s release. Chapter 21 focuses specifically on changes in EMF 2.3 and 2.4 and, as such, uses 2.4 as the basis for its examples.

Conventions Used in This Book

The following formatting conventions are used throughout this book:

  • Bold—Used for the names of model elements, such as packages, classes, attributes, and references; and of user-interface elements, including menus, buttons, tabs, and text boxes.
  • Italic—Used for filenames and URIs, as well as for placeholder text that is meant to be replaced by a particular name. New terms are often italicized for emphasis. Also, in Chapter 9’s example mappings, items shown purely to provide context appear in italics.
  • Courier—Used for all code samples and for in-text references to code elements, including the names of Java packages, classes, interfaces, methods, fields, variables, and keywords. Plug-in names, command lines, and elements of non-Java files, including XML, also appear in this font.
  • Courier Bold —Used to emphasize portions of code samples, usually new insertions or changes.
  • Courier Strikethrough —Used in code samples to indicate that text should be deleted.
Online Examples

The Web site for this book is located at http://www.informit.com/title/9780321331885. All of the example models and code used throughout this book can be downloaded from there. The site will also provide an errata list, and other news related to the book.

Eclipse and EMF are required to use the examples. You can download one of several Eclipse packages (we recommend Eclipse Classic) at http://www.eclipse.org/downloads/ and the all-in-one EMF SDK at http://www.eclipse.org/modeling/emf/downloads/.


© Copyright Pearson Education. All rights reserved.

From the B&N Reads Blog

Customer Reviews