Summary: This document provides basic information about the extension providing Apache Struts support for the JEE Analyzer.
Please see Apache Struts - 1.4 - Release Notes for more information.
This extension provides support for Apache Struts - this support is in addition to the basic support provided for Apache Struts in the JEE Analyzer. The extension's main role is to improve the detection of links and transaction computations where Apache Struts is implicated.
- At the current time, analysis results will contain duplicated objects: the Struts Operation object (created by the extension) corresponds to the Struts Action Mapping Operation object created by the JEE Analyzer - this duplication will be fixed in a future release.
- All Transaction results involving Apache Struts code are generated using the Struts Operation object (created by the extension) and not the Struts Action Mapping Operation object created by the JEE Analyzer.
In what situation should you install this extension?
If your JEE application source code uses the Apache Struts framework you should install this extension to benefit from improved support for Apache Struts.
Object structure and links
- Creates Struts Operations which represent entry-points for web services. For each operation, one Struts Operation object is created.
- The dependent Web Services Linker is responsible for detecting and creating links between the UI (JSP/HTML etc) to the Struts Operation object created by the extension.
Struts 1.1 support
In the "web.xml" file, the extension will detect the servlet pointing to "org.apache.struts.action.ActionServlet" class, indicating that Struts 1.1 is being used. The extension will detect the servlet-mapping (i.e. "*.perform" in the example below):
In the struts config xml files (struts-XXX.xml), the extension will detect the correspondence between an URL and a java class (i.e. /logout corresponds to the "com.company.lightspeed.struts.logon.StrutsActionLogout" java class):
The extension will search for the "execute" method in the corresponding java class (here StrutsActionLogout class) and create a StrutsOperation named with the corresponding URL (here /logout). A call link between the StrutsOperation and the "execute" method will be created.
Note that the "execute" method may be defined in a parent class of StrutsActionLogout. This specific case which is common to both struts 1 and struts 2 is described in section Modelling when the execute method is defined in a parent Struts class.
Classes inheriting from org.apache.struts.actions.DispatchAction
The extension will search for all java classes implementing "org.apache.struts.actions.DispatchAction".
We create a Struts Operation with the name "/BookEdit?do=editBook" (this name is found in the struts web xml file or, by default, is the class name without the Action part), and a call link to the "editBook" method. The "do" after the "?" is found in the struts web xml file in the "parameter" field of the "action" tag. The same is done for every method of the class.
Example of a struts-config.xml:
Classes inheriting from net.jspcontrols.dialogs.actions.SelectAction
The extension will search for all java classes implementing "net.jspcontrols.dialogs.actions.SelectAction".
In a SelectAction class, the method getKeyMethodMap provides a mapping between the methods and a parameter name. In the previous example, the method "getfoo" is mapped with a parameter DIALOG-EVENT-GET (DIALOG-EVENT is the output of getInitKey()).
We create a Struts Operation with the name "/MaintainMyAccount?DIALOG-EVENT-GET" (this name is found in the struts web xml file or, when no reference to this class is found in the web xml file, this name is set to the class name without the Action part), and a call link to the "getfoo" method.
Struts 1.x + Spring
Spring provides a special action class org.springframework.web.struts.DelegatingActionProxy that acts as a proxy for struts actions, allowing more indirections:
The class name is then found in a bean:
or in a bean alias.
Struts 2.x support
In the "web.xml" file, the extension will detect the filter pointing to "org.apache.struts2.dispatcher.FilterDispatcher" class, indicating that Struts 2.x is being used. The extension will detect the servlet-mapping (i.e. "*.action;/*" in the example below). The extension will also obtain the filter "struts2" and "BaseStrutsFilter" because "BaseStrutsFilter" points to a class that exists in the analysis.
If a struts config file exists as shown below, the extension can obtain a correspondence between the path and a java class: in the example below, name="Login" gives the name of the operation that will be created:
The extension will search for the "execute" method in the corresponding java class (here manning.chapterSix.Login class) and create a StrutsOperation named with the corresponding URL (here /Login). A call link between the StrutsOperation and the "execute" method will be created.
Classes with @Results annotation
The extension will search for all java classes using the "@Results" annotation which is resolved to "org.apache.struts2.config.Results".
The extension will then search for all methods which are public and have "String" as the return type. The extension will create a Struts Operation with the name "/Restringe!carregarRegistro" (Restringe is the class name without the ending "Action"), and a call link to the method.
Classes implementing SessionAware
The extension will search for all java classes implementing "org.apache.struts2.interceptor.SessionAware".
The extension will create a Struts Operation with the name "/Login" (this name is found in a struts XML config file or the class name by default), and a call link to the "execute" method.
Classes inheriting from com.opensymphony.xwork2.ActionSupport
The extension will search for all java classes implementing "com.opensymphony.xwork2.ActionSupport".
The extension will create a Struts Operation with the name "/ManageFieldsPV" (this name is found in the class name without the Action part), and a call link to the "execute" method.
Class and methods using @Action annotation
Annotations of the "struts2 convention plugin" can be used instead of struts.xml files.
For exemple :
The extension will create two Struts Operations :
- one named "/login" (which corresponds to the string assigned to value). A callLink from that operation to the execute method is created.
- one named "/foopath". A callLink from that operation to the a_method method is created.
Struts 2.x + Spring
Spring offers additional indirection for Struts 2 using org.apache.struts2.spring.StrutsSpringObjectFactory.
Again the real class will be indicated in a bean.
Modeling when the execute method is defined in a parent Struts class
In both struts 1 and struts 2 it is common that the "execute" method is not defined within the referred java class but in a parent of that class. This "execute" method then calls a method that is overridden in the referred java class. In that case, a call link is created between the Struts Operation and this method.
Let's for instance consider the struts 1 application using the following config xml file ( which defines that a /logout URL refers to the "com.company.lightspeed.struts.logon.StrutsActionLogout" java class):
If no "execute" method is found in "com.company.lightspeed.struts.logon.StrutsActionLogout" java class, the extension searches for the "execute" method in the class hierarchy.
In this example, the "execute" method is found in the parent java class ActionBaseCommon. The extension will analyze this "execute" method to see if a method of the "referred" java class (here StrutsActionLogout) is called from "execute" (here the "execute" method calls "executeExtended" which is in the "referred" java class StrutsActionLogout). The extension will create a Struts Operation named "/logout" (name found in the Struts xml file) and a call link between the operation and the "executeExtended" method.
Supported Apache Struts versions
Supported client frameworks
Function Point, Quality and Sizing support
- Function Points (transactions): a green tick indicates that OMG Function Point counting and Transaction Risk Index are supported
- Quality and Sizing: a green tick indicates that CAST can measure size and that a minimum set of Quality Rules exist
|Quality and Sizing|
CAST AIP release
|7.3.4 and all higher 7.3.x releases|
Supported DBMS servers
This extension is compatible with the following DBMS servers:
|An installation of any compatible release of CAST AIP (see table above)|
Dependencies with other extensions
Some CAST extensions require the presence of other CAST extensions in order to function correctly. The Apache Struts extension requires that the following other CAST extensions are also installed:
- JEE Analyzer
- Web Services Linker
- com.castsoftware.internal.platform (internal extension)
- when using the CAST Extension Downloader to download the extension and the Manage Extensions interface in CAST Server Manager to install the extension, any dependent extensions are automatically downloaded and installed for you. You do not need to do anything.
- the JEE Analyzer is not a dependency, but since this extension is always installed with AIP, you do not need to do anything.
Download and installation instructions
The latest release status of this extension can be seen when downloading it from the CAST Extend server.
CAST Transaction Configuration Center (TCC) setup
If you are using the extension with CAST AIP ≥ 8.3.x, an Apache Struts specific setup is automatically imported when the extension is installed. These items will be available in the CAST Transaction Configuration Center:
Manual import action for CAST AIP ≤ 8.2.x
If you are using the extensions with CAST AIP ≤ 8.2.x, you can manually import the TCC setup, should you want to:
- Locate the .TCCSetup file in the extension folder: Configuration\TCC\Base_Java_Struts.TCCSetup
- In the CAST Transaction Configuration Center, ensure you have selected the Templates node:
- This .TCCSetup file is to be imported into the CAST Transaction Calibration Center using either the:
- File > Import Configuration menu option:
- Or right clicking on the Template node and selecting Import Configuration:
- The import of the "Base_Java_Struts.TCCSetup" file will provide you with a sample Transaction Entry point in the Free Definition node under Templates:
- Now right click the "Standard Entry Point" item and select copy:
- Paste the item into the equivalent node under the Application, for example, below we have copied it into the Application MEUDON:
- Repeat for any additional items or generic sets that have been imported from the .TCCSetup file.
Packaging, delivering and analyzing your source code
Once the extension is installed, no further configuration changes are required before you can package your source code and run an analysis. The process of packaging, delivering and analyzing your source code does not change in any way:
- Package and deliver your application.
- Analyze your delivered application source code.
What results can you expect?
The following objects are displayed in CAST Enlighten:
Current known limitations
- The Class name to URL naming convention of the convention plugin is not supported
- When Dynamic Method Invocation is used, the method foo of action hello can be accessed with both the URLs: hello!foo.action and hello.action?method: foo. As the recommended approach is to use the first URL and in order to limit the number of objects created, the analyzer supports only the first approach.
The following structural rules are provided: