Comments
bruce.armstrong wrote: Somebody just said it better than I did, and with more chops to say it: Open Letter to Mark Zuckerberg, Sheryl Sandberg & Facebook Mobile
Cloud Expo on Google News

SYS-CON.TV
Cloud Expo & Virtualization 2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
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 leads Enterprise Architecture at United Airlines, Inc. He has 15+ 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.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Any link to download source files ?

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.

Where is the link to download source files for connector EmployeeInfoCCIConnection??

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

The Links to Parts I and II are to be found at the foot of the final page.

-Duty Editor

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.


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 Cloud Developer Stories
We’re happy to announce general availability of Intel Cloud SSO IAM-as-a-service today after running it in private beta mode for 2 months with select customers. See press release here. Intel has partnered with Salesforce to develop and run this application …
With Cloud Expo 2012 New York (10th Cloud Expo) now just under three weeks away, what better time to introduce you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...
With BigDataExpo 2012 New York (www.BigDataExpo.net), co-located with 10th Cloud Expo, now just three weeks away, what better time to introduce you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the ...
In his session at the 10th International Cloud Expo, Marvin Wheeler, Open Data Center Alliance Chairman, will discuss the success the organization has had in charting the requirements for broad-scale enterprise adoption of the cloud and how 2012 is forecast to be the tipping poin...
The move to cloud-based applications has undeniably delivered tremendous benefits. However, the associated distribution creates various challenges from the quality perspective: End-to-end tests need to pass through multiple dependent systems, which are commonly unavailable, evo...
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
ADS BY GOOGLE