Using the EMF validation framework to validate the EMF model

Source: Internet
Author: User

The EMF (Eclipse Modeling Framework) Modeling framework can help us transform models (UML, XSD, etc.) into robust and rich Java code. Using EMF to build an application, not only can greatly improve the development efficiency, but also take advantage of the many features provided by EMF to ensure the robustness and perfection of the model, including model change notification mechanism, model persistence and model validation framework. The EMF Validation framework that this article will introduce is an important part of EMF, and by using the EMF Validation Framework, we can easily add validation constraints to the defined EMF model to ensure that the model data is compliant with user-defined constraints.

The EMF Validation Framework provides a validation framework for EMF Eobjects, compared to the EMF Evalidator API

It provides more complex and comprehensive validation and is easy to expand. The EMF Validation Framework provides flexible validation definitions and supports two validation triggers: Batch and Live. It supports the implementation of constraints in the JAVA and OCL languages, and it also supports custom validation of model scanning algorithms, and provides a Validation Client context to circumvent unnecessary validation.

Implementation principle of EMF Validation Framework

There are several important concepts in the EMF Validation framework, which form the basic part of the validation framework, which we describe here:

Constraint (constraints)

All constraints must implement the Imodelconstraint interface, define the logic for validation execution (validate ()), and have a constraint descriptor (a class that implements the Iconstraintdescriptor interface) that contains the source information for this constraint. For example, the validation mode is live or batch, the target object of the validation, and so on, figure 1 can give you a basic concept.

Figure 1. Constraints

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.