Skip to content

Latest commit

 

History

History
188 lines (134 loc) · 6.93 KB

File metadata and controls

188 lines (134 loc) · 6.93 KB

ejb-beanutils-async: Java Rule Add-on That Detects Seam Asynchronous Annotation in Remote EJBs

Author: Jess Sightler
Level: Intermediate
Summary: Windup Java rule add-on that reports on use of the Seam Asynchronous annotation in remote EJBs
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 Java rule add-on 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.

These instructions use the following replaceable variables.

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

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

Review the Quickstart Code

The EjbBeanUtilsAsyncUsageRuleProvider class extends AbstractRuleProvider and overrides the getConfiguration(GraphContext context) method.

This method looks for annotations named "com.beanutils.async.AsynchronousMethod". When found, it adds the following text to the report and points the person to the JBoss EAP 6 documentation:

`REMOTE_EJB_CLASS_NAME` uses the Seam @Asynchronous annotation. It is not compatible with JBoss EAP Remote EJBs and should be replaced with the standard Java EE 6 @Asynchronous annotation.

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.

Configure Maven

If you have not yet installed and configured Maven, follow the instructions here: Install and Configure Maven.

An example settings.xml file is provided in the root directory of the quickstarts.

Build the Quickstart Rule Add-on

Before Windup can use this rule, it must be compiled and added to the local Maven repository.

  1. Open a command prompt and navigate to the QUICKSTART_HOME/rules-java/ directory.

  2. Type the following command to compile the quickstart and install it into the local Maven repository:

    mvn clean install
  3. You should see the message BUILD SUCCESS

Add the Quickstart Rule to Windup

The command to install the rule in Windup uses the Maven GAV (groupId, artifactId, and optional version) to locate the rule in the Maven repository. The command uses the following syntax.

WINDUP_HOME/bin/windup --install GROUP_ID:ARTIFACT_ID[,VERSION]

To find these values, open the QUICKSTART_HOME/rules-java/pom.xml file. These values are located near the beginning of the file.

<groupId>org.jboss.windup.quickstarts</groupId>
<artifactId>windup-ejb-beanutils-async-rules-java</artifactId>
<version>2.6.0-SNAPSHOT</version>

Follow these steps to add the rule to Windup.

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

  2. Type the following command, which does not include the optional version.

    bin/windup --install org.jboss.windup.quickstarts:windup-ejb-beanutils-async-rules-java
  3. At the following prompt, choose Y.

    Confirm installation [Y/n]? Y
  4. You should see the following result.

    Installation completed successfully.

Test the Quickstart Rule

This quickstart provides an example file 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 --input QUICKSTART_HOME/test-files/src_example/ --output QUICKSTART_HOME/windup-reports-java/ --target eap --packages org.windup
  3. You should see the following result:

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

Review the Quickstart Report

  1. Open the link to the QUICKSTART_HOME/windup-reports-java/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.

Run the Arquillian Tests

This quickstart provides Arquillian tests.

  1. Open a command prompt and navigate to the QUICKSTART_HOME/rules-java/ directory.

  2. Type the following command to run the test goal.

    mvn clean test
  3. You should see the following results.

    Results :
    
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

Remove the Quickstart Rule from Windup

You remove the rule from Windup using its Maven GAV (groupId, artifactId, and version).

The command takes the following form:

WINDUP_HOME/bin/windup --remove GROUP_ID:ARTIFACT_ID[,VERSION]

Follow these steps to remove the rule from Windup.

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

  2. Type the following command.

    bin/windup --remove org.jboss.windup.quickstarts:windup-ejb-beanutils-async-rules-java
  3. Enter Y to confirm. You should see the following response.

    Uninstallation completed successfully.