YOUR FEEDBACK
Cloud Computing: Do You Really Want Your Data in the Cloud?
Don Dodge wrote: D Cheng, Of course in-house systems go down. What I am sa...
AJAXWorld RIA Conference
$300 Savings Expire July 25
Register Today and SAVE!

READ DIGITAL EDITION


SYS-CON.TV

2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
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
TOP THREE LINKS YOU MUST CLICK ON


Constructing Services with SOA & Open Source Java
The Jedi mind trick is a Force power that can influence the actions of weak-minded sentient beings

Digg This!

Page 2 of 3   « previous page   next page »

Now, Onto Building a Better Death Star
Everybody knows that the Death Star was destroyed by Luke Skywalker in Star Wars Episode IV: A New Hope. What they don't know is that another Death Star is being built using the latest and greatest Java frameworks. I guess you could say it's our lucky day. It's not easy constructing a monumental bringer of death out in the middle of nowhere. Droids, and many of them, must be gathered from across the galaxy to help in its construction. The system we'll be building for the Galactic Empire is an android (droid for short) provisioning system. I know that the Federation is in essence the Dark Side but the rates and benefits are outstanding. It doesn't hurt that there's free light saber training and laser target practice on Wednesday nights.

The key concepts that should be remembered throughout this exercise are:

  • All of the services (modules) are POJOs that can be injected into any other module. These services could be a Web Service, data access service, common framework, business logic, or any number of other things required to make your application function.
  • A service is a service is a service. Since our services are POJOs as well as Spring wired beans they can be exposed externally through any number of transport protocols. There are many frameworks that are tightly integrated with Spring that let you expose a Spring bean over HTTP, JMS, RMI, etc.
Let's look at the services that comprise our droid provisioning system as well as the key technologies that are used to bring it to life. Figure 2 shows the Maven modules of the droid provisioning application and their mapping to logical services with technology implementations.

This sample application will demonstrate injecting services (both through Spring and Maven), WSDL-first development using XFire, and the creation of a data access service layer using Hibernate. All of the corresponding code for this example can be found at http://dozer.sourceforge.net/example.zip.

Anatomy of the Parent POM
Maven provides the concept of a parent module that is key to project inheritance. This module lets you define common dependencies, organizational information, deployment information, and common plug-ins. A skeleton of the provisioning application's POM file is shown in Listing 1.

This listing shows a typical POM layout structure. This file defines project-wide dependencies, project metadata, and common plug-in configurations.

In a Galaxy Far, Far Away
Let's code. The first thing we need is a common module that can be used by all upstream modules. This core module is comprised of one service but could potentially hold many others. Our core service really doesn't do much except elaborate on the concept of injecting and reusing services. Here's our service defined as a Spring bean in our module's Spring context file:

<bean id="coreService" class="com.examples.droid.core.service.CoreService"/>

This bean references a Java class called CoreService that executes some core functionality.

The Maven configuration for this module is in Listing 2.

By defining our core module as a packaging type of jar Maven will compile our code, run unit tests, and package our classes into a jar file. The parent module inheritance is defined at the top of the configuration. No dependency version numbers are needed since they are defined in the parent. Let's see how this service can be used in sibling modules.

Springtime for Storm Troopers
Maven has the concept of dependency management to Spring's concept of dependency injection. At an abstract level the two are very similar and work hand-in-hand allowing for a reusable pluggable architecture. To add the core module as a dependency of another module we simply have to define it in our sibling module's POM file.

<dependencies>
    <dependency>
       <groupId>com.examples.droid</groupId>
       <artifactId>droid-core</artifactId>
    </dependency>
    ...
<dependencies>

The version for the dependency has been defined in the parent module. To use the service defined in the core module we'd simply inject it into the service defined in the sibling module's Spring context file.

<bean id="provisioningServiceImpl" class="com.examples.droid.ws.provisioning.ProvisioningServiceImpl">
    <property name="coreService" ref="coreService"/>     ...
</bean>

To reference the Spring context defined in the core module it needs to be included in the list of context files that make up the system's Spring ApplicationContext:

String[] configFiles = new String[] { "spring/droid-core-beans.xml",
       "spring/droid-dao-provisioning-beans.xml" };
BeanFactory factory = new ClassPathXmlApplicationContext(configFiles);

We now know how to create a service module and inject it through Maven dependency management as well as through Spring's dependency injection. Let's create some more services while working up our layers of the architecture.

Darth Vader Wants His TPS Reports!
Darth Vader has seen the initial budget for the new Death Star and is having heartburn. He needs a way to run some queries on our android provisioning database. Darth is pretty savvy so he chose Hibernate for the application's object relational mapping (ORM) persistence framework. Using Hibernate tools to reverse-engineer the database lets us dynamically generate our ORM files and data access objects. Since we rely on this generated code before we compile our persistence module we can simply bind the Hibernate tool's source generation task to a particular Maven lifecycle phase. The Hibernate source generation is done at the generate-sources lifecycle phase in Maven by defining our plug-in's phase element as shown in Listing 3.

This task was done in a maven-antrun-plugin as an Ant task since when this article was written the Hibernate tool's Maven plug-in wasn't as robust as the Ant task. The Maven variable maven.compile.classpath lets you have all of the module's dependencies and transitive dependencies at your fingertips.


Page 2 of 3   « previous page   next page »

About Franz Garsombke
Franz Garsombke has been developing and architecting enterprise software solutions in Colorado for the last eleven years and is currently employed at Rally Software. Franz is a huge proponent of open source frameworks and is passionate about developing and delivering simple, quality, pragmatic applications. He is proud to be the co-founder of a Java Bean mapping framework (http://dozer.sourceforge.net) and can be reached at fgarsombke@yahoo.com or on his mountain bike.

WIRELESS BUSINESS & TECHNOLOGY LATEST STORIES . . .
Adobe's Kevin Lynch and Microsoft's Scott Guthrie to Keynote AJAX World RIA Conference & Expo
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted to be
Troll-Evading Trust Formed To "Catch & Release" Patents
Verizon, Google, Cisco, HP, Motorola, Sun, Telefon AB and Ericsson have banded together as the Allied Security Trust to buy IP before any trolls can take them to court. They've paid $250k to join and are each kicking it about $5 million in funding. They will then get non-exclusive lice
ARC Wireless Solutions Announces the Official Launch of the Freedom Blade
ARC Wireless Solutions' Wireless Communications Solutions Division announces that the Freedom Blade and supporting Freedom Clip Pack have been fully launched and are now available to ship domestically and internationally via their retail and distributor partners. The Freedom Blade is t
Android Won't Be Home for Xmas
Android, due in the second half, could reportedly be delayed until Q4 or maybe even next year, according to the tale the Wall Street Journal tells, a situation that opens up a can of worms for Google. Google has to prove that it's more than a one-trick pony and that it can deliver some
Nokia Wants To Open-Source Symbian OS
Nokia wants to buy the 52% of the Symbian operating system that it doesn't already own to open source it and set it free. It's a defense against advances into the fragmented mobile space that Nokia and Symbian dominate - particularly - from the looks of case - against Google's nascent
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