Skip to content

Latest commit

 

History

History
116 lines (80 loc) · 5.84 KB

File metadata and controls

116 lines (80 loc) · 5.84 KB

ejb-beanutils-async: XML Rule That Detects Seam Asynchronous Annotation in Remote EJBs

Author: Jess Sightler
Level: Intermediate
Summary: Windup XML-based rule that reports on reports on use of the Seam Asynchronous annotation in remote EJBs
Source: https://github.com/windup/windup-quickstarts/

What is it?

The Seam @Asynchronous annotation is not compatible with remote EJBs in Red Hat JBoss Enterprise Application Platform. This XML rule tests for use of org.jboss.seam.annotations.async.Asynchronous annotations in remote EJBs and reports that it must be replaced with the standard Java EE 6 @Asynchronous annotation.

Note: Windup only analyzes XML files with names ending in .windup.xml. Be sure to name XML-base rules using this naming convention!

These instructions use the following replaceable variables.

  • QUICKSTART_HOME: Replace this variable with the fully qualified path to the root directory of this quickstart.

  • WINDUP_HOME: Replace this variable with the fully qualified path to your Windup installation.

  • WINDUP_RULES_DIR: Replace this variable with the fully qualified path to your ${user.home}/.windup/rules/ directory. This directory is created by Windup the first time it is executed and contains rules, add-ons, and the Windup log.

    For Linux or Mac: ~/.windup/rules/
    For Windows: "\Documents and Settings\USER_NAME\.windup\rules\" or "\Users\USER_NAME\.windup\rules\"

A {ProductShortName} rule is installed simply by copying the XML rule to the WINDUP_RULES_DIR folder.

Review the Quickstart Code

The QUICKSTART_HOME/rules-xml/ejb-beanutils-async-method.windup.xml rule first tests for XML file criteria and the filtered results are then used as input for Java class criteria. The final results are assigned an effort level of 8.

  • The xmlfile <when> condition tests for XML files with the "ejb" namespace prefix and matching the XPath /ejb:ejb-jar//ejb:session[windup:matches(ejb:remote/text(). The <remote> element text value is stored in the variable {{remoteclass}} for later access by the javaclass condition.

  • The javaclass <when> condition finds instances of the {{remoteclass}} named in the filtered results from the xmlfile condition, looks for the referenced org.jboss.seam.annotations.async.Asynchronous annotation, and saves the results in the variable asyncUsingSessionBeans.

  • When the condition is met, the <perform> action provides a hint message along with a link to more information and assigns it a level of effort of "8".

The Windup JavaDoc is located here: http://windup.github.io/windup/docs/latest/javadoc/

System requirements

The rule this project produces is designed to be run on Windup 2.0 or later.

This project requires Java 7 (Java SDK 1.7) or later and Maven 3.0 or later.

Install Windup

If you have not installed Windup, follow the instructions here: Download and Install Windup.

Add the Quickstart to Windup

To install the rule in Windup, simply copy the QUICKSTART_HOME/rules-xml/ejb-beanutils-async-method.windup.xml file into the WINDUP_RULES_DIR directory.

cd QUICKSTART_HOME/rules-xml
cp ejb-beanutils-async-method.windup.xml ~/.windup/rules/

Test the Quickstart Rule

This quickstart provides example files containing the Seam org.jboss.seam.annotations.async.Asynchronous annotation to use when testing the quickstart. It is located in the quickstart’s test-files/src_example/ directory.

The command to test the rule uses this syntax:

WINDUP_HOME/bin/windup [--sourceMode] --input INPUT_ARCHIVE_OR_FOLDER --output OUTPUT_REPORT_DIRECTORY --target TARGET_TECHNOLOGY --packages PACKAGE_1 PACKAGE_2 PACKAGE_N

To test this quickstart using the test-files/src_example/ folder provided in the root directory of this quickstart, follow these steps.

  1. Open a command prompt and navigate to the WINDUP_HOME directory.

  2. Type the following command to test the rule.

    bin/windup --sourceMode true --input QUICKSTART_HOME/test-files/src_example/ --output QUICKSTART_HOME/windup-reports-xml/ --target eap --packages org.windup
  3. You should see the following result:

    ***SUCCESS*** Windup report created: QUICKSTART_HOME/windup-reports-xml/index.html
                  Access it at this URL: file:///QUICKSTART_HOME/windup-reports-xml/index.html

Review the Quickstart Report

  1. Open the link to the QUICKSTART_HOME/windup-reports-xml/index.html file in a browser. You are presented with the Application List page.

  2. Click on the src_example link. This takes you to the Report Index page, which provides summary information about findings from the migration analysis.

  3. Under Additional Reports, click on Application Details. This opens the Application Details Report page that shows a total of 8 story points and the list of the relevant files along with warning messages.

  4. Click on the org.windup.examples.ejb.BeanUtilsAsyncUsingRemote file link to drill down for more information about the Java source.

    • The Information section reports on the matching conditions and provides a link to the standard Java EE servlet annotation documentation.

    • This is followed by the source code matching the condition with a detailed message desription.

Remove the Quickstart Rule from Windup

To remove the rule from Windup, simply delete the ejb-beanutils-async-method.windup.xml file from the WINDUP_RULES_DIR directory.