2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


An Introduction to Maven - Part III
Application development management using Maven 2 and Eclipse

In the parts 1 and 2 of this article, we demonstrated how to download and install Maven 2, how to install the Maven 2 plugin for Eclipse, and how to go about setting up a project directory structure using Maven 2. We used a simple use case for displaying employee details on the Web given an employee ID, but deliberately made the design a bit complex by introducing design concepts such as XML binding, EJBs, and JCA connectors to illustrate a few of the many features offered by Maven. In this final installment of the article, we continue with the remaining modules in our example and illustrate a few more developmental tasks that can be accomplished fairly easily using Maven that otherwise would demand significant time and effort to accomplish.

As described earlier, the 'connector' module yields a RAR artifact containing a JCA connector that uses 'xmlBinding' classes to return Employee information. This means that the 'connector' module will have a dependency on the 'xmlBinding' artifact and any artifact that can provide JCA classes. We'll use Maven's 'Add Dependency' feature in Eclipse to add these dependencies as described below.

1.  In the Eclipse 'Package Explorer' pane, right-click on the 'connector' module's POM file and in the menu, select 'Add Dependency' Maven2 option as shown in Figure 1.
2.  A dialog window to search for artifacts in the Maven repository will be displayed. In the search box, type 'com.somecompany.' The search results will be displayed in the text area as shown in Figure 2.
3.  Expand the 'com.somecompany xmlBinding' result entry, select the 'xmlBinding-1.0.jar' option, and click the 'OK' button. The dependency on the 'xmlBinding' artifact will be added in the POM file.
4.  To add JCA specification classes, we'll use a Geronimo JCA specification artifact as a dependency. Following the same approach as described before, search for 'geronimo' in the repository search window and select 'geronimo-spec-j2ee-connector-1.0-M1.jar' as a dependency to be added as shown in Figure 3.
5.  The two dependencies will be added to the POM file. The scope element should be added to the 'geronimo-spec-j2ee-connector' dependency element with a value of 'provided' indicating that JCA classes will be provided by the underlying J2EE application server. Below is the modified POM.

<project>
    <parent>
       <artifactId>EmployeeInfo</artifactId>
       <groupId>com.somecompany</groupId>
       <version>1.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>connector</artifactId>
    <packaging>rar</packaging>
    <name>connector</name>
<dependencies>
    <dependency>
       <groupId>com.somecompany</groupId>
       <artifactId>xmlBinding</artifactId>
       <version>1.0</version>
    </dependency>
    <dependency>
       <groupId>geronimo-spec</groupId>
       <artifactId>geronimo-spec-j2ee-connector</artifactId>
       <version>1.0-M1</version>
       <scope>provided</scope>
    </dependency>
   </dependencies>
</project>

It's time to add connector implementation Java classes. The source files that we developed for the connector are shown in Figure 4.

Download and review the source files to understand the complete implementation. However, the important classes to note are 'EmployeeInfoCCIConnection,' 'EmployeeInfoCCIInteraction,' and 'EmployeeInfoSPIManagedConnection.' The sequence diagram as shown in Figure 5 gives a high-level view of the method calls that a client will invoke to retrieve employee information using an employee ID. For brevity's sake, the sequence diagram is kept simple.

The RAR artifact for the 'connector' module can be created by adding 'maven-rar-plugin.' By default, this plug-in will look for RAR meta-information such as the 'ra.xml' descriptor file under the 'src/main/rar/META-INF' directory. The 'ra.xml' descriptor is in Listing 1.

Static Analysis of Code using Maven
Errors in the code are typically detected via code reviews, unit testing, system testing, integration testing, and user-acceptance testing. Code reviews certainly help in early bug detection by enforcing language-specific programming standards and best practices. However code reviews are carried out manually and hence the process can be cumbersome and inefficient particularly in case of large projects. Static analysis is a tool-based automated code review mechanism typically used to find code defects early in the build phase. Static analysis ensures early bug detection and remediation by comparing source code with predefined language patterns. It also helps in enforcing coding conventions and thereby improves code quality.

PMD is a static analysis tool for Java code. PMD packages a number of ready-to-run rules that can identify unused variables, unnecessary object creation, and empty catch blocks in the source code. Custom rules can also be incorporated. PMD can be executed using Maven by including 'maven-pmd-plugin' in the POM file as shown in the following snippet. The PMD plug-in lets you automatically run the PMD code analysis tool on your project's source code and generate a site report with its results. For more information on the PMD Maven plug-in, refer to plug-in documentation available at http://maven.apache.org/plugins/maven-pmd-plugin/.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
       </plugin>

PMD plug-in can be invoked at the command line within the module directory by running the command below. However, with the current implementation, the plug-in will generate reports only in case of 'jar,' 'war,' and 'ejb' POM packaging types. Since the current POM is a 'rar' packaging type, the packaging type should be temporarily changed to 'jar' so that PMD plug-in can generate the reports.

      mvn pmd:pmd

When this command is executed after temporarily changing the packaging type to 'jar,' Maven will invoke the PMD plug-in that will run the code analysis and create reports under the 'target/site' directory with the main report in the 'pmd.html' file. Figure 6 is the report generated for the 'connector' module source code. Make sure to reset the packaging type back to 'rar.'


About Murali Kashaboina
Murali Kashaboina is a lead architect at Ecommerce Technology, United Airlines, Inc. He has more than 10 years of enterprise software development experience utilizing a broad range of technologies, including JEE, CORBA, Tuxedo, and Web services. Murali previously published articles in WLDJ and SilverStream Developer Center. He has master’s degree in mechanical engineering from the University of Dayton, Ohio.

About Geeth Narayanan
Geeth Narayanan is a senior architect at Ecommerce Technology, United Airlines, Inc. He has 10 years of experience in the IT industry, specializing in solutions using Java EE technologies. Geeth has master's degree in electrical engineering from the University of Toledo, Ohio.

YOUR FEEDBACK
Aladin SOHAILI wrote: Any link to download source files ?
Bob Arnold wrote: Regarding: "It's time to add connector implementation Java classes. The source files that we developed for the connector are shown in Figure 4. Download and review the source files to understand the complete implementation." Please specify the download link for the source code referred to.
vinny wrote: Where is the link to download source files for connector EmployeeInfoCCIConnection??
Magne wrote: It was with great interest I read these articles. Article 3 refers to source files available for download. Where can they be downloaded form? -magne
Duty Editor wrote: The Links to Parts I and II are to be found at the foot of the final page. -Duty Editor
Jim wrote: Next time you write part 3 of a three-part series, please include clickable links to the first two parts right there at the top. Unless, of course, you want to keep the first two parts secret.
LATEST JAVA STORIES & POSTS
Continuent has announced support and enhancements to MySQL Server 5.1.30 GA release, the 5.1 production version of the open source database. MySQL 5.1.30 is recommended for use on production systems by the MySQL build team at Sun Microsystems. Continuent Tungsten provides advance...
As a software journalist, there are times when certain vendors will shut the door on reporting opportunities that might represent too much of an "inside view" of their technology or their organization. I've been to more developer events than I can remember where I've been handed ...
Active Endpoints has announced the general availability of ActiveVOS 6.0.2, in response to ever increasing demands for improved process performance and efficiencies. ActiveVOS is an all-in-one, 100% standards-based orchestration and business process management system (BPM) that p...
Just because the web has been open so far doesn't mean that it will stay that way. Flash and Silverlight, arguably the two market-leading technology toolkits for rich media applications are not open. Make no mistake - Microsoft and Adobe aim to have their proprietary plug-ins, ak...
Doing network I/O on the user interface (UI) thread is bad. Most developers know that and can tell you why; unfortunately, it’s still done. At this year's JavaOne, one of the keynote JavaFX demos bombed because the network was slow, something that would be forgivable had the en...
Over the course of the past few decades, the consumer media industry has evolved from a slow-moving oligopoly dominated by a handful of vertically integrated networks to a highly fragmented and competitive marketplace of content creation, publication, and distribution players. Th...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

SPONSORED BY INFRAGISTICS
In every field of design one of the first things students do is learn from the work of others. They ...
There are many forces that influence technological evolution. After a decade of building enterprise ...
2008 is going to be an important year for Rich Internet Applications. Most organizations are deliver...
The OpenAjax Alliance is developing an Ajax industry wishlist for future browsers, using a dedicated...
Infragistics announced the availability of two Community Technology Preview (CTP) User Interface (UI...
The YUI development team has released version 2.5.2; you can download the new release from SourceFor...
ADS BY GOOGLE