Excerpt
PrefacePreface
This book is a comprehensive introduction and developers 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 modelers 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 EMFs 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 EMFs 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 EMFs 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 EMFs backward compatibility, all examples run without change on version 2.4, the latest at the time of this books 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:
- BoldUsed 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.
- ItalicUsed 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 9s example mappings, items shown purely to provide context appear in italics.
- CourierUsed 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 BoldUsed to emphasize portions of code samples, usually new insertions or changes.
Courier StrikethroughUsed 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.