NetUI Page Flows: An Evolution of Struts
Pages: 1, 2, 3, 4, 5

Integration: Struts Merge

Struts mergeĀ converts simple Struts applications into Page Flow applications. This approach can be a fast way to move simple Struts applications to the Page Flow framework.

The Struts merge feature is different from the Struts interoperability feature. In the case of the Struts merge feature, a Struts XML configuration file can be specified at controller level as follows:

/**
                        
* @jpf:controller struts-merge= "/WEB-INF/struts-config-merge-example.xml"
*/
public class ExampleStrutsMergeController extends PageFlowController
{
...
}

This step enables an existing, all-Struts XML configuration file to be merged (at project compilation time) with the Page Flow's generated jpf-struts-config-<pageflow>.xml file. The purpose of the Struts merge feature is to override Page Flow defaults, or to specify settings for the Page Flow that are not provided by Page Flow annotations or by their attributes. The Struts merge files typically should be small and only modify the Page Flow and its actions and form beans. Though action mappings can be added in the Struts merge file, this practice is not recommended. Struts action mappings should be declared in the Page Flow's .jpf file with @jpf annotations, and then (if necessary) modified with the Struts merge file.

You can also use the Struts merge feature to read configuration data from a pure Struts application into the Page Flow application's configuration files. Ordinarily, a Page Flow's configuration files are generated entirely from the application's Java source files (specifically from the metadata annotations that decorate the controller files). But, in cases of integration of a Struts module into an application, the configuration files can be generated from both the Java source files and the Struts module's configuration files. In that case, you have flexibility to change or add any tag in the generated configuration file. For example, an action form's default scoping can be overridden from request-scoping to session-scoping. You can do thisĀ  simply by creating a Struts configuration file that overrides the appropriate parts of the Page Flow's configuration file, and then refer to this override file from within the Page Flow's Java source file, as indicated in the example above.

Both the Struts merge and Struts interoperability features can be used in a Page Flow for best results, taking into consideration parameters like complexity of existing Struts, time, and effort.

Beehive

The Apache Beehive Project contains a lot more than Page Flows. It has three sub-projects:

  • NetUI PageFlows: the Web application framework introduced in this article.
  • Controls: a lightweight component framework that helps programmers build components, such as JavaBeans, that incorporate metadata into their programming model. This project comes with a few pre-made controls as well.
  • Web Services: an annotation-driven programming model for Web services conforming to JSR-181.

Java Page Flows have full support for Java controls, a simple programming model abstraction for accessing enterprise resources and packaging business logic. Java controls give developers access to the powerful features of the J2EE platform (security, transactions, and asynchrony) in a simple, intuitive environment with methods, events, and properties, and enable developers to build Web applications conforming to best practices for service-oriented architectures (SOAs). For example, a Web service control can be declared in a Page Flow with a simple annotation as shown below:

@Control
                        
public MyWebService myWebService;

The control will then be automatically injected in the Page Flow by the environment.

In combination with XMLBeans, Beehive provides infrastructure to seamlessly build and deploy enterprise SOAs. Beehive 1.0 is scheduled for release later this month, and plans for 2.0 are in progress. Beehive applications can be developed using IDEs like BEA WebLogic Workshop, or using Eclipse plug-ins being developed within the Pollinate project.

Conclusion

Page Flows come with a strong promise to make enterprise software development and maintenance easier and quicker. In this article, we examined some of the advantages of Page Flows over Struts, how Page Flows can enhance existing Struts applications, and several methodologies, including Struts interoperability and Struts merge, you can use to upgrade and seamlessly build enterprise-level SOA business applications.

References

Srinivas Jaini is a software architect with heavy experience in SOA and in building enterprise wide portals on J2EE and the WebLogic Platform for banking and other industries. He has a passion for technology and music.