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/
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.
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 thejavaclass
condition. -
The
javaclass
<when>
condition finds instances of the{{remoteclass}}
named in the filtered results from thexmlfile
condition, looks for the referencedorg.jboss.seam.annotations.async.Asynchronous
annotation, and saves the results in the variableasyncUsingSessionBeans
. -
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/
The Windup rules schema is located here: https://github.com/windup/windup/blob/master/config-xml/rule-schema.xsd
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.
If you have not installed Windup, follow the instructions here: Download and Install 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/
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.
-
Open a command prompt and navigate to the
WINDUP_HOME
directory. -
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
-
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
-
Open the link to the
QUICKSTART_HOME/windup-reports-xml/index.html
file in a browser. You are presented with theApplication List
page. -
Click on the
src_example
link. This takes you to theReport Index
page, which provides summary information about findings from the migration analysis. -
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. -
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.
-