Chapter 8. Validator

8.1. Introduction

The JBoss JCA container features a validator which checks resource adapter archives against the Java Connector Architecture (JCA) specification.

The validator is doing a static analysis of the resource adapter classes and checks them against the rules defined in the validator.

The validator is used in the deployer chain of the JCA container, and is available as a standalone tool and an Apache Ant too.

8.2. Reports

The validator works by scanning the resource adapter in question and output a report which lists which rules have been violated.

An example could be

Severity: ERROR
Section: 19.4.2
Description: A ResourceAdapter must implement a "public int hashCode()" method.
Code: com.mycompany.myproject.ResourceAdapterImpl

Severity: ERROR
Section: 19.4.2
Description: A ResourceAdapter must implement a "public boolean equals(Object)" method.
Code: com.mycompany.myproject.ResourceAdapterImpl
      

which means that com.mycompany.myproject.ResourceAdapterImpl is missing an equals and hashCode implementation.

Table 8.1. Validator report

KeyDesciption
Severity Specifies the severity of the rule.

  • ERROR: Critical error which must be fixed in order for the resource adapter to operate correctly.
  • WARN: Error which should be fixed in order for the resource adapter to operate correctly.

Section A reference to a section in the Java Connector Architecture specification where the requirement is defined.
Descrption A short description of the rule.
Code The class which triggered the rule.

8.3. Running the standalone validator

The validator can be run on the command line by

java -jar jboss-jca-validator.jar <file>
      

The reports will be generated into the current directory under the name of <file>.log.

8.4. Apache Ant integration

The validator integrates with Apache Ant such that you can generate the reports directly from your build environment before deploying the resoruce adapter into the JBoss JCA container.

First you have to define the taskdef for the task

<taskdef name="validator"
         classname="org.jboss.jca.validator.ant.ValidatorTask"
         classpathref="jbossjca.lib.path.id"/>
      

See the Apache Ant documentation for additional instructions on installation.

8.4.1. Usage

<validator rarFile="${myArchive.rar}" outputDir="${report.dir}"/>
        

Table 8.2. Apache Ant: validator

KeyValue
rarFile The resource adapter file
outputDir The directory where the reports should be generated
classpath A classpath to resolve additional dependencies against