Enable or disable validators in Rational Application Developer

An introduction to managing validators in the Validation Framework

The Validation Framework provides an extendable framework that is used to develop new custom validators to validate projects and resources created with IBM Rational Application Developer. The framework provides a set of interfaces and APIs to control how, when, and what type of validator is launched on the resources in the workspace. This article is an introductory guide to enable and disable validators in IBM Rational Application Developer.

Rosendo Martinez (rosendo@mx1.ibm.com), Software Engineer, J2EE Tools Developer and Validation Framework Lead, IBM

author photoRosendo Martinez has been working for IBM in the Rational Application Developer project in Guadalajara, Mexico, since 2009. Initially, he worked on the SCA (Service Component Architecture) component. Then he was assigned to Java Enterprise Editing Tools component as developer and took the leadership of Validation Framework. Since then, he has collaborated in the Eclipse community and Rational Application Developer by developing new features, fixing defects, and answering developers' questions regarding the Validation Framework.



16 October 2012

Extending the Validation Framework to create validators

The Validation Framework offers a set of APIs to create and manage validators easily in IBM® Rational® Application Developer. The Validation Framework is an open source project, and it is controlled by the Eclipse community (Web Tools Platform). The resource to be validated can be an Eclipse Resource (IResource), an Eclipse Modeling Framework, or an EMF Resource (EObject).

The framework puts out problems found during validation as problem markers in the Problems View or Markers View of the Rational Application Developer user interface providing you the ability to identify problems during development phase and avoiding defects in later test stages, therefore helping you to save time and money for your team.

You must create an extension in your plug-in to extend the validator extension point from the framework in order to create a new validator. The example in Listing 1 shows how an extension would look.

Listing 1. Plug-in extension example
<extension
    id="test1"
    name="Test1 Validator"
    point="org.eclipse.wst.validation.validatorV2">
        <validator
            class="org.eclipse.wst.validation.tests.TestValidator"
            build="false"
            manual="false" >
            <include>
                <rules>
                    <fileext ext="test1"></fileext>
                    <pattern regex=".*/secondx/third/.*"></pattern>
                    <facet id="java" version="1.6" />
                </rules>
            </include>
            <exclude>
                <rules>
                    <targetRuntime id="JBoss v5.0"/>
                    <file
                        caseSensitive="true"
                        name=".project"
                        type="file">
                    </file>
                </rules>
            </exclude>
            </validator>
</extension>

All validators must extend org.eclipse.wst.validation.validatorV2. In addition, they must define an ID, a name, a class where the validator implementation is defined, and some includes and excludes where filter rules are defined.

Filter rules are stored in groups. There are two types of groups: Include and Exclude. You can have as many Include groups as you like. Filters inside of an Include group cause resources to be validated. If any rule matches, the entire group matches. Inside of a group the filter rules are ORed together. However, individual Include groups are ANDed together. You can have one Exclude group. If any of its filter rules match, then the resource is excluded. Exclusion takes precedence over inclusion.

After the validator has been added into your plug-in and Rational Application Developer has been restarted, the new validator will be shown ( Windows > Preferences > Validation).

Figure 1. Test Validator option in validation preferences
Screen capture shows the new Test1 Validator

Validation options

The framework offers four validation options, which the subsections that follow explain:

  1. Allow projects to override these preferences settings.
  2. Suspend all validators.
  3. Save all modified resources automatically before validating.
  4. Show confirmation dialog when performing manual validation.:
Figure 2. Selecting validation options
Validation options to perform validation

1. Allow projects to override these preferences settings

Projects can override the options in Window > Preferences > Validation. By doing this, individual projects will be validated depending on the current selected option. It can be Manual, Build, and the selectable Settings.

2. Suspend all validators

If you select this option, all validators will be suspended, which means that the projects and resources in your workspace will not be validated.

3. Save all modified resources automatically before validating

By selecting this option, if a resource has not been saved and Manual validation is performed, a pop-up dialog window confirms that the resource must be saved to be validated.

You can avoid showing this dialog by checking Always save all modified resources automatically prior to validating in the dialog window.

Figure 3. Save modified resources
Modified resource to be saved before validating

4. Show confirmation dialog when performing manual validation

By selecting this option, if Manual validation is performed, a pop-up dialog window confirms that there were or were not errors or a warning during the validation.

Figure 4. Showing no errors after running validation
Information message shows manual validation result
Figure 5. Showing errors after running validation
Error message shows manual validation result

Calling the Manual or Build validators

If the build operation takes a long time, you might want to disable some of the validators. When a validator is disabled, errors, warnings, and information messages are not shown in the Markers nor Problems views.

All of the validators can be called by two different options in Rational Application Developer:

  • Manual
  • Build

Manual validation lets resources to be validated by selecting the project that contains the resource, right-clicking on it, and then selecting Validation context menu option. You can enable or disable Manual validation:

  1. Select the resource or its parent project.
  2. Right-click and select the Validate menu option.

Build lets you select resources to be validated by selecting Project > Clean menu options. You can enable or disable Build validation, too:

  1. Select Window > Preferences > Validation
  2. Pick the validator you may want to change its behavior.
  3. On the Manual column of the validator, check or uncheck the option.

In both cases, the resources will be validated or not, depending on your selection.

It is important to notice that not all of the validators must be enabled in order to validate your application. Depending on what kind of application you are working on, you can enable a specific validator.

Validating a very large workspace can take time, so you might enable only the validators that you need in your application to reduce the amount of validation.

Figure 6. Enabling and disabling Manual and Build validation
Manual is enabled and Build is disabled
Table 1. Validators in Rational Application Developer
ValidatorDescriptionRAD only
Application Client Validator Validates the following Application Client project resources:
  • Deployment descriptor (application-client.xml)
  • EJB references
  • Resource references
Yes
Application Manifest Validator Performs validations on the APPLICATION.MF file in OSGi application projects. Yes
Blueprint File Validator Performs validations on blueprint XML files in OSGi bundle projects. Yes
Bundle Manifest Validator
Performs validations on the MANIFEST.MF file in OSGi bundle projects.
Yes
Classpath Dependency Validator Verifies potential runtime classpath errors. These are classpath issues where even though everything is compiling fine in the Eclipse environment, when the applications are deployed to a Java EE server, there could be classpath errors. No (Eclipse)
Client-side JavaScript Takes the JavaScript in a web page and validates it, first by translating the page contents into just JavaScript and running that through our regular JavaScript compiler. The reported problems then have their location information adjusted so that they show up against the right content in the web page. No (Eclipse)
Composite Bundle Manifest Validator Performs validations on the COMPOSITEBUNDLE.MF file in OSGi composite bundle projects. Yes
Connector (1.0,1.5) Validator Checks for invalid J2EE specification levels in connector projects. No (Eclipse)
DTD Validator Determines whether the current state of a DTD is semantically valid. XML files are validated according to the XML specification Extensible Markup Language (XML) 1.0 from the W3C Web site. As well, the DTD validator checks for errors such as references to entities and elements that do not exist. No (Eclipse)
Deployment Manifest Validator Performs validations on the DEPLOYMENT.MF file in OSGi application projects. Yes
EJB Validator Verifies that enterprise beans contained in an EJB project comply with the Oracle Enterprise JavaBeans Specifications, depending on the level of the bean. Specifically, the EJB Validator validates the following resources:
  • Java .class files that are members of an enterprise bean (home interface, remote interface, enterprise bean class, and, if the bean is an entity bean, the key class)
  • ejb-jar.xml
Yes
Enterprise Application Validator Validates the following:
  • EAR deployment descriptor (application.xml)
  • EJB references of all module projects in the enterprise application project
  • Security roles, Resource references.
  • Manifest files for all contained or referenced modules and utility JAR files.
  • Target server consistency between the enterprise application project and any utility and module projects Existence of projects for each module defined in enterprise application.
Yes
Fragment Manifest Validator
Performs validations on the MANIFEST.MF file in OSGi fragment projects.
Yes
HTML Syntax Validator Validates HTML basic syntax and HTML DTD compliance in the following Web project resources:
  • HTML files
  • JSP files
No (Eclipse)
J2EE Classpath Validator Validates that the classpath container dependencies exist. Yes
JSF Application Configuration Validator Test the value of a string or JavaScript object (string, number, date) to see if the value conforms to JSF validation rules. No (Eclipse)
JSF View Extended Validator Test the value of a string or JavaScript object (string, number, date) to see if the value conforms to JSF validation rules. Yes
JSF View Validator Test the value of a string or JavaScript object (string, number, date) to see if the value conforms to JSF validation rules. No (Eclipse)
JSP Content Validator Reports if the library referred to by a Tag Library Directive cannot be found, as well as any problems it finds regarding the prefix value in the JSP file content. No (Eclipse)
JSP Syntax Validator Validates JSP files in a project by translating them into the corresponding Java code and then checking the Java code for compile errors. No (Eclipse)
Map Validator Verifies that the fields in the database and the members of the EJBs are mapped and synchronized correctly. Yes
Project Structure Validator Validates whether any component resources point to a non-existing source folder and whether there are unnecessary resource mappings in the project structure. Yes
SCA 1.0 Composite Validator Validates the OSOA files *.composite. Yes
SCA 1.0 Contribution Validator Validates the OSOA file META-INF/sca-contribution-xml. Yes
SCA 1.1 Composite Validator Validates the OASIS files *.composite. Yes
SCA 1.1 Contribution Validator Validates the OASIS file META-INF/sca-contribution-xml. Yes
SIP 1.0 Converged Project Validator Verifies that the sip.xml and the web.xml are merged correctly. Yes
SIP 1.1 Converged Project Validator Verifies that the sip.xml and the web.xml are merged correctly. Yes
SIP 1.1 Deployment Descriptor Validator Verifies the SIP project is correct and valid. Yes
SIP 1.1 Semantic Validator Verifies the SIP rules Y maps Yes
SIP 1.1 Servlet Selection Validator Verifies the servlet is valid and there is one servlet selected. Yes
SIP 1.1 Servlet Validator Verifies the servlet is valid and has a main entry. Yes
Struts Configuration File Validator Checks the semantic errors that are not caught by the XML syntax checker. These are semantic as defined in the files : struts-config _1_1.dtd and for Struts 1.0, struts-config_1_0.dtd. Note: Only the configured configuration files are validated. That means if it’s not defined within web.xml (or portal.xml), it is not validated. Yes
Struts Configuration File Validator - Portlet Checks the semantic errors that are not caught by the XML syntax checker. These are semantic as defined in the files: struts-config _1_1.dtd and for Struts 1.0, struts-config_1_0.dtd. Note: Only the configured configuration files are validated. That means if it’s not defined within web.xml (or portal.xml), it is not validated. Yes
Tag Library Descriptor Validator A tag library descriptor is an XML document that contains information about a library as a whole and about each tag contained in the library. TLDs are used by a web container to validate the tags and by JSP page development tools. This validator can be used to validate the conformance of any JSP page importing this tag library to its requirements. No (Eclipse)
WS-I Message Validator Checks SOAP messages against WS-I Profiles. A user can capture and verify SOAP messages using the TCP/IP Monitor. The validator checks a message log that is saved as a project resource (.wsimsg). The log conforms to a format as specified by WS-I. No (Eclipse)
WSDL Validator The WSDL validator checks the following in WSDL files:
  • XML syntax
  • XML schema types in the <types> section
  • Referential integrity of the various constructs in WSDL

The validator also includes an extension point to allow other validators to be plugged into the WSDL validation to provide additional verification of the WSDL file. Through this mechanism, interoperability is checked by validating a WSDL file against WS-I profiles.
No (Eclipse)
Web Service Annotation Validator Validates JAX-WS Web services annotations and ensures the application is properly configured for the target runtime. Yes
Web Service Project Validator Validates WebSphere based EJB Web services to ensure that all necessary modules are configured. Yes
Web Validator Validates the following web project resources:
  • Deployment descriptor (web.xml)
  • Servlets
  • Security roles
  • Servlet and servlet mappings
  • EJB references
Yes
WebSphere Application Manifest Validator Performs IBM® WebSphere®-specific validations on the APPLICATION.MF file in OSGi application projects. Yes
WebSphere Composite Bundle Manifest Validator Performs WebSphere-specific validations on the COMPOSITEBUNDLE.MF file in OSGi composite bundle projects. Yes
WebSphere EJB 3.0 Deployment Descriptor Validator Validates the ejb-jar.xml file with respect to WebSphere bindings and extensions related meta-data. Yes
WebSphere EJB Bindings Validator Validates the ibm-ejb-jar-bnd.xml file where WebSphere EJB bindings meta-data is defined (i.e. such as bindings to data sources, etc). Yes
WebSphere EJB Extensions Validator Validates the ibm-ejb-jar-ext.xml file where WebSphere EJB extensions meta-data is defined. Yes
WebSphere EJB Programming Model Extensions Validator Validates the ibm-ejb-jar-ext-pme.xml file where WebSphere EJB programming model extensions meta-data is defined. Yes
WebSphere JPA Validator Validates the JPA persistence.xml file of any WebSphere/OpenJPA specific meta-data. Yes
WebSphere Legacy EJB Extensions Validator Validates the ibm-ejb-jar-ext.xmi file where WebSphere EJB extensions meta-data is defined. Yes
WebSphere Legacy Web Extensions Validator Validates the ibm-web-jar-ext.xmi file where WebSphere Web extensions meta-data is defined. Yes
WebSphere Web Bindings Validator Validates the ibm-web-jar-bnd.xml file where WebSphere Web bindings meta-data is defined. Yes
WebSphere Web Extensions Validator Validates the ibm-web-jar-ext.xml file where WebSphere Web extensions meta-data is defined. Yes
WebSphere Web Programming Model Extensions Validator Validates the ibm-web-ext-pme.xml file where WebSphere Web programming model extensions meta-data is defined. Yes
XML Schema Validator Determines whether the current state of an XML schema file is semantically valid. XML schemas are validated according to the XML Schema specification XML Schema. No (Eclipse)
XML Validator The XML validator ensures that an XML file is well-formed. It also verifies if an XML file is valid - that is, it follows the constraints established in the DTD or XML schema the XML file is associated with. No (Eclipse)
XSL Validator Ensures that the XSL file is well-formed. It tries to detect any static errors, that is, an error that can be detected in a style sheet before execution starts. No (Eclipse)
iWidget Validator Ensures that an iWidget must have at least one content element in View mode, the content element mode has to be unique within the XML document and the mode of any content element that you add should synchronize with the Supported Modes field. No (Eclipse)
xJCL Batch Validator Verifies that the XML Job Control Language (xJCL) file is well-formed. No (Eclipse)

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Rational software on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational, DevOps
ArticleID=839983
ArticleTitle=Enable or disable validators in Rational Application Developer
publish-date=10162012