WTP Logo Banner
Back
Validation Component Overview
overview
Vijay Bhadriraju
IBM Rational
January 22, 2005
 
Introduction
 

The Validation Component in the wst sub project provides an extendable framework that is used to develop new custom validators to validate resources in the workbench. The resources can be an eclipse Resource (IResource) or an EMF Resource (EObject). The framework provides a set of interface and api to control how, when and what type of valdation is launched on the resources in the workbench. The framework puts out problems found during validation as problem markers in the Problems View of the workbench. The framework provides a set of function and the details of each of this functions are discussed in the following section.

 
Functional Overview
 

This section provides a functional overview of the validation framework in the validation component.

 
 

Validation Registration

 

All custom validators developed extending the framework are registered on a IProject, when registered the project nature type is used for registration. The registration ensures that the custom validator runs on only on projects with that project nature. This registration is done in the custom validator extension implementation.

 
 

Enabling/Disabling Validation

 

All custom validators developed can enabled/disabled at 2 levels, one at the project level and one globally. The project level has the option to enable it even though it is diabled globally. The global enablement/disablement is available thorugh the Validation Perferences page (Window -> Preferences -> Validation). The project level enablement/disablement is available through the project proerties page (Right Click on IProject -> Properties -> Validation). By default all custom validators are enabled by default at project level and global level. There are more options on enablement Global Validation Preferences pagen and the Project Validation properties page that are self explaintory.

 
 

Manual Validation

 

The framework provides validation to be triggered manually on resources using the "Run Validation" pop up menu item that is available on resources. The Run Validation runs all enabled validators registered on the resource. The manual validation provides an progress dialog to display the status of the validation.

 
 

Incremental Validation

 

Incremental validation is provided by the framework using the core Incremental Builder technology. The framework defines a validation builder that is of a incremental builder type. The Valdiation Builder is added to the build spec of the project. The builder triggers all enabled custom validators on a Auto Build in the workbench. The validation builder uses the core delta that is maintained by the eclipse Build Manager to determin the kind validation to be triggered on the resources that have custom valdators registered.

 
 

Dependency Validation

 

The dependency validation works on IProjects. This dependency validation when set to true in the extension implementation of a custom validator validate all project referencing the current project being validated. This dependency check is recurrsive and goes down the chain of project referencing the referenced projects.

 
 

Validation Filters

 

A custom validator developed extending the framework has the option to provide file filters to be validated. These filter can specified as file type or even specific files to be validated. These resource defined in the filters are only validated when validation is run manually or incrementally. An example of defining a filter is shown in the SampleValidation extension below.

 
 

Validation Markers

 

The framework extends the core eclipse problemMarker extension point and has a Validation marker type. The problem found during validation are put out as Validation Markers in the problems view of the workbench. The validation markers provides 3 levels of severity (Errors, Warning and Informational) for a custom validator to display problem found during validation. It is the resposiblity of the custom validator implementor to cleanup the problem markers that it has put out on each run of the validator. The framework provides api to cleanup existing validation problem markers.

 
 

Extension points defined

 

The framework extension points are defined in the org.eclipse.wst.validation plugin. The extensions point are listed below.

<extension-point id="validator" name="Validator" schema="xsds/validatorExtSchema.exsd" />

Every validator must extend org.eclipse.wst.validation.validator. Provided by the validation framework, this extension point is packaged in the org.eclipse.wst.validation plugin. point must always have a value of org.eclipse.wst.validation.validator
<extension-point id="referencialFileValidator" name="ReferencialFileValidator"
schema="xsds/referencialFileExtSchema.exsd"/>

This extension point is used to referenced file validation where the implementer of the this extension point gives a flattened list of referenced file to be validated for a given file. By extending this extension point custom file validators can validate files referencing the current file being valdiated.

 
 

SampleValidator Extension

 

The extension below shows an implmentation of the custom EJB Validator extending the validator extension point from the framework.

 
	
		<extension
	         id="EJBValidator"
	         name="%EJB_VALIDATOR"
	         point="org.eclipse.wst.validation.validator">
	      	<validator>
		         <projectNature
		               id="org.eclipse.wst.common.modulecore.ModuleCoreNature">
		         </projectNature>
		         <filter
		               objectClass="org.eclipse.core.resources.IFile"
		               nameFilter="ejb-jar.xml">
		         </filter>
		         <filter
		               objectClass="org.eclipse.core.resources.IFile"
		               nameFilter="*.class">
		         </filter>
		         <filter
		               objectClass="org.eclipse.core.resources.IFile"
		               nameFilter="*.java">
		         </filtergt;
		         <helper
		               class="org.eclipse.jst.j2ee.internal.ejb.workbench.validation.EJBHelper">
		         </helper>
		         <dependentValidator
		               depValValue="true">
		         </dependentValidator>
		         <markerId
		               markerIdValue="EJBValidatorMarker">
		         </markerId>
		         <run
		               class="org.eclipse.jst.j2ee.internal.ejb.workbench.validation.UIEjbValidator">
		         </run>
	      	</validator>
	   </extension>
	  
 
 

Custom Marker Support (New in M3)

 

A new feature has been added to the validation framework where custom validator developers can define their own problem marker for their validator. The user defined marker Id is used to add problem markers for that validator. The customer marker support gives the flexiblity of filtering the problem markers for a validator from the filters dialog, these filters filter the problem markers in the problems view. To get this functinalaity the the custom validator needs to be define a markerId element in the validator extension and a problem marker extension as shown below.

 
      <markerId
            markerIdValue="EJBValidatorMarker">
      </markerId>
      
 

A problem marker extension extending the core problem marker needs to be defined with the same id of the markerId as shown below.

 
      <extension
         id="EJBValidatorMarker"
         name="%EJB_VALIDATION_PROBLEMMARKER_NAME"
         point="org.eclipse.core.resources.markers">
      <super
            type="org.eclipse.wst.validation.problemmarker">
      </super>
      <persistent
            value="true">
      </persistent>
      <attribute
            name="owner">
      </attribute>
      <attribute
            name="validationSeverity">
      </attribute>
      <attribute
            name="targetObject">
      </attribute>
      <attribute
            name="groupName">
      </attribute>
      <attribute
            name="messageId">
      </attribute>
     </extension>
      
API Overview
 

The following document provides an overview of the API available in the framework.
Validation Framework Api

Component Plugins and Dependency
 

The following picture depicts ths plugin dependencies of plugins that are in the validation component.