Welcome!

Java Authors: Carmen Gonzalez, Liz Dickinson, Pat Romanski, Bob Gourley, Yakov Fain

Related Topics: SOA & WOA, Java, AJAX & REA, Web 2.0

SOA & WOA: Article

SOA World Expo: Enterprise Mashup Services

Part 1: Real-World SOA or Web 2.0 Novelties?

Since Web 2.0 kicked off scarcely a day goes by without a headline targeting mashups and their enablers, AJAX and Web Services, as the next hot Web technologies. Mashups are Web sites that integrate a variety of services (e.g., news feeds, weather reports, maps, and traffic conditions) in new and interesting ways. Just take a look at Zillow.com, which provides instant home valuations plotted as thumbtacks on a map (Figure 1), or HousingMaps.com, which marks listings from craigslist.org as captions on a map, and you'll get a clear picture of the power behind converging data sources.

Google Maps is often identified as the disruptive force that spawned the mashups movement. The popular mapping service is now the home of more than 600 mashups according to ProgrammableWeb.com. Why the hype? Google Maps provides a simple JavaScript API that makes geo-spatial data, a historically cost-prohibitive service, easily accessible to a broad audience with a variety of technical skills. Web 2.0-savvy developers are highly attracted to this simplified and accessible approach to SOA development because it no longer confines their Web site functionally to a user interface, but opens the site up to syndicate functionality and data. Thus a site's success is no longer based on traffic alone, but on the number of subscribers. The proliferation of these services is mind-boggling. ProgrammableWeb.com, a mashup-tracking site, has more than 300 registered services available to mix-and-match, and more than 1,100 registered mashups. Roughly 2.8 new sites are registered every day.

Despite the momentum behind mashups, corporate IT departments only consume a handful of the services used by the mashup crowd. Instead, businesses have constructed their own ecosystem of services in parallel to the Web 2.0 movement. The problem with corporate adoption of mashups is two-fold. First, the concept of mashups is often considered a social phenomenon or a grassroots effort tangential to enterprise software. Second, there's no clear path to integrate business services with those available on the Web. This second issue is due, in part, to the impedance mismatch between business services and mashup services. Mashup APIs are generally written in JavaScript, while services deployed to the enterprise are developed using Java or .NET technologies. Thus, both perception and technology define the barriers to corporations adopting an enterprise mashup strategy that incorporates external services such as Google Maps.

Despite these initial hurdles, the services and collaborative development style that mashups provide have created a buzz among enterprise software vendors. IBM recently announced a R&D effort to create an enterprise "mashup maker" - a tool that lets developers blend corporate services with external services, and rapidly assemble applications. More recently, Oracle announced the Oracle WebCenter Suite, which uses JSR-168/286 and WSRP 1.0/2.0 to mix-and-match corporate services using a combination of AJAX and Java portlets. The "mashup maker" and "mashups as a portal" are both interesting concepts and quite possibly the future of rapid business application development. In a later installment we will take a closer look at JSR-168/286 and WSRP 1.0/2.0 and how these standards can be used to create enterprise mashups that mix corporate services. Meanwhile, the aim of this article is to give application developers, specifically enterprise Java developers, the tools to build meaningful enterprise mashups that take advantage of the popular mashup services.

Today's Toolkit
Business services developed with Java technologies generally fall into one of four categories: Enterprise JavaBeans, Spring, POJOs, or Web Services. The problem is that mashup APIs are generally implemented with JavaScript. There are a few services such as Flickr that offer parallel APIs written in Java, .NET, and a number of other technologies. For sites that don't offer a Java API, developers are left to their own devices to bridge the integration gap between JavaScript and Java. Existing Web Services provide the most direct path to integration, and processing XML over XMLHttpRequests, though tedious, is a relatively established method of binding AJAX-enabled interfaces to Web Services. There are a number of JavaScript packages, such as the vcXMLRPC Library, that help simplify the handling of XML-RPC requests. However, integrating Java-centric applications built with Spring or Enterprise JavaBeans makes for a more interesting problem. The first solution that comes to mind is to expose an existing EJB or Spring application as a Web Service, a simple task given that both EJB 3.0 and Spring 2.0 support remote method invocations via a Web Service end-point (JSR 181). Despite the simplicity of creating such a Web Service, we are still presented with the cumbersome task of processing XML with JavaScript.

Java-to-AJAX libraries such as Direct Web Remoting (DWR) and JSON-RPC-Java offer a simple alternative by marshaling Java objects to JavaScript and letting JavaScript communicate directly with server-side Java objects (Figure 2). So developers can interact with Java objects as if they were client-side JavaScript objects, negating the need to work with XML. For instance, by using a Java-to-AJAX library we can expose operations performed by a session bean to an AJAX-enabled Web interface and then combine the outcomes of those operations with a mashup service. An added benefit of the servlet architecture used by DWR and JSON-RPC-Java is that both libraries can take advantage of the authentication and session management provided by Java EE 5. Despite the similarities shared by both DWR and JSON-RPC-Java, DWR has a few advantages, two of which are the ability to handle recursive object structures and its integration with a large number of other libraries and frameworks such as Spring, Struts, JSF, Rife, WebWorks, and Hibernate. Thus, the amalgamation of DWR, enterprise Java services, and JavaScript mashup APIs blends the flexibility and creativity behind Web 2.0 with the reliability, scalability, and security of the Java EE architecture without needing to manipulate XML documents.

Building an Enterprise Mashup
The example application referenced in this article uses the Java Persistence API (JPA), Google Maps, and DWR to create a simple customer address book application (Figure 3). The application plots customers by address on a map using Google Map's JavaScript API. Users can update an entry by selecting a marker on a map and editing associated values in a form. Changes are committed by clicking the update, remove, and create. All records are stored in an Oracle database and persisted using the JPA.

The application provides a simple end-to-end example that demonstrates one method of blending external mashup services with Java-centric business services. Note that this article does not provide an in-depth look at DWR, JPA, or Google Maps. Instead, the intention is to prove the simplicity of integration between these technologies and enable you, the reader, to build your own enterprise mashups that leverage popular JavaScript APIs like Google Maps. Please refer to the references included in this article for more information on DWR, JPA, and Google Maps.

Setting up the DWR servlet is simple and can easily be added to an existing application. To install the servlet, first put the DWR jar in the lib directory under the WEB-INF directory, and add the following lines to the web.xml descriptor:

<servlet>
   <display-name>DWR Servlet</display-name>
   <servlet-name>dwr-invoker</servlet-name>
   <servlet-class>uk.ltd.getahead.dwr.DWRServlet
   </servlet-class>
   <init-param>
     <param-name>debug</param-name>
     <param-value>true</param-value>
     </init-param>
  </servlet>
  <servlet-mapping>
     <servlet-name>dwr-invoker</servlet-name>
     <url-pattern>/dwr/*</url-pattern>
</servlet-mapping>

Next, DWR must be made aware of the Java objects that should be remotable as JavaScript interfaces. The Customers object is the single JPA entity used in the application and maps to a Customers table (Listing 1). A session façade named JavaServiceFacade is used to encapsulate operations on the Customers entity object (Listing 2). Both the JavaServiceFacade and Customers classes must be registered with DWR to interact with each object via JavaScript. To do so, simply create a dwr.xml file in the WEB-INF directory as follows:

<dwr>
   <allow>
   <create creator="new" javascript="JavaServiceFacade">
   <param name="class" value="com...JavaServiceFacade"/>
     <include method="queryCustomersFindAll"/>
     <include method="queryCustomersFindById"/>
     <include method="mergeCustomers"/>
     <include method="persistCustomers"/>
     <include method="removeCustomers"/>
   </create>
   <convert converter="bean" match="com...Customers"/>
    </allow>
</dwr>

The dwr.xml descriptor defines a subset of methods on the JavaServiceFacade object to expose and declares a JavaBean converter to marshal the Customers entity as a return value or method parameter. In this example, two query methods as well as the merge, persist, and remove operations contained in the JavaServiceFacade are exposed. Once the dwr.xml file is created, three JavaScript files must be imported in the JSP or HTML pages contained in the application. This enables the use of the JavaScript representation or remote interfaces of the JavaServiceFacade and Customers Java objects. The imports are as follows:

<script type='text/javascript'
src='../dwr/interface/JavaServiceFacade.js'></script>
<script type='text/javascript' src='../dwr/engine.js'></script>
<script type='text/javascript' src='../dwr/util.js'></script>

Note that only the JavaScript interface for the JavaServiceFacade is imported because it's the sole object that contains methods that are invoked explicitly. With the web.xml file configured, the dwr.xml file created, and all the necessary JavaScript files imported, the methods contained in the JavaServiceFacade are now accessible from a Web browser via JavaScript. To test the installation, open a Web browser and navigate to http://localhost:[port]/[nameofwebapp]/dwr. A screen should appear resembling that shown in Figure 4. Figure 5 shows all of the methods on the JavaServiceFacade that are accessible remotely.

The next step is to integrate the JavaScript interface for the JavaServiceFacade with the Google Maps API. To use the Google Maps API, an activation key is required. Visit www.google.com/apis/maps/signup.html to obtain a key. Keys are mapped to a unique URL so the key included in this article will only work with the source code provided. To use a key different from the one included in this example, simply add the following import statement to the top of your JSP page, replacing the key contained in the URL with the one obtained from the Google Maps registration page. The import below is required in the JSP page irrespective of the activation key used.

<script src="http://maps.google.com/maps?file=api&v=2&key=value"
type="text/javascript"></script>

With both DWR and Google Maps configured, DWR calls to the JPA façade and the Google Maps API can be integrated. A simple load function and a div tag, in this case named "map," are used to initialize the mapping UI. The load function is assigned to the onload attribute of the body tag in the HTML or JSP page. Note that if you're using Dojo you must use the frameworks dojo.addOnLoad function instead of the onload attribute. The load function used in the example application not only initializes the Google Maps API, but also calls the queryCustomersFindAll function defined in the JavaServiceFacade JavaScript interface to retrieve all the Customers objects. The JavaServiceFacade.queryCustomersFindAll function accepts a reference to another function as an argument. The argument handles the return value of the JavaServiceFacade.queryCustomersFindAll function as an asynchronous callback. In this case the callback handler is the processCustomers function, which processes the list of Customers returned by the JavaServiceFacade.queryCustomersFindAll function, plotting each Customers object on the map as a marker (Figure 6).

// Called on intial page load
function load() {
   if(GBrowserIsCompatible()){
     // Remotely call Java method
     // to extract all Customers
     JavaServiceFacade.queryCustomersFindAll(processCustomers);
     // Initalize map object
     map = new GMap2(document.getElementById("map"));
     // Add navigation controls to map
     map.addControl(new GSmallMapControl());
     map.addControl(new GMapTypeControl());
     // Initalize geocoder
     geocoder = new GClientGeocoder();
   }
}

// Plots an array of Customers on
var processCustomers =
   function(customers){
   // test if array is null
   if(customers != null &&
     typeof customers == 'object'){
     // iterator over array of customers
     for(var i=0;i < customers.length; i++){
       // plot each customer on the map
       addMarkerForCustomer( customers[i] );
       }
   } else {
     alert("Customer record is null!");
   }
   // Set map center and magnification
   map.setCenter(
     new GLatLng(37.4419, -122.1419), 9);
}

Plotting markers with Google Maps requires three simple steps. First, a geo-spatial point on the map is obtained by using the Google geocoder API. Second, a GMarker object representing the geo-spatial is created. Finally, the marker is added to the map at the given point by calling the addOverlay function on the current instance of the GMap2 object - the object that represents the map displayed in the UI. Below is the function used to plot a Customers object as a marker. In the example a geo-spatial point is generated with the address information provided by the Customers object. A helper function is used to create a new GMarker, which is then added to the map object with a call to the addOverlay function.

// Plots a customer on the map as a marker
function addMarkerForCustomer(customer){
...
   // create address string
   var address = customer.address + ...;
   // create point using geocoder
   geocoder.getLatLng(
     address,
     function(point) {
     ...
     // create marker
     var marker = createMarker(point, customer);
     // overlay marker on map
     map.addOverlay(marker);
     }
   );
...
}


More Stories By Ric Smith

Ric Smith is director, business and product strategy at Kaazing. provides Kaazing Corporation with a wealth of experience in product management and consulting for enterprise products and services. Prior to joining Kaazing, Ric was a principal product manager for Oracle's Fusion Middleware at Oracle's Headquarters in Redwood Shores, CA. In his role as a Principal Product Manager he was responsible for the evangelism and product direction of Oracle's AJAX and Java EE Web Tier offerings. Before joining the Fusion Middleware team, Ric worked for Oracle's consulting business as a principal consultant where he led development of mission-critical applications for prominent organizations within the defense/intelligence industry. In addition, Ric won consecutive awards for technical achievement for each year of his tenure as a consultant. Ric is a frequent speaker at international events and has written articles featured in leading industry publications such as Java Developer's Journal and AJAXWorld Magazine. He is also a representative to the OpenAjax Alliance and an honors graduate of the University of Arizona.

Comments (3)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
SYS-CON Events announced today that SOA Software, an API management leader, will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. SOA Software is a leading provider of API Management and SOA Governance products that equip business to deliver APIs and SOA together to drive their company to meet its business strategy quickly and effectively. SOA Software’s technology helps businesses to accelerate their digital channels with APIs, drive partner adoption, monetize their assets, and achieve a...
SYS-CON Events announced today that Aria Systems, the recurring revenue expert, has been named "Bronze Sponsor" of SYS-CON's 15th International Cloud Expo®, which will take place on November 4-6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Aria Systems helps leading businesses connect their customers with the products and services they love. Industry leaders like Pitney Bowes, Experian, AAA NCNU, VMware, HootSuite and many others choose Aria to power their recurring revenue business and deliver exceptional experiences to their customers.
SYS-CON Events announced today that AgilePoint, the leading provider of Microsoft-centric Business Process Management software, will exhibit at SYS-CON's 2nd International @ThingsExpo which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. AgilePoint is the leading provider of Microsoft-based Business Process Management (BPM) software products, has 1,300+ on-premise and cloud deployments in 25+ countries and provides the same advanced BPM feature set as J2EE vendors like IBM and Appian for the Microsoft .NET native environment. AgilePoint customer...
The Internet of Things (IoT) promises to evolve the way the world does business; however, understanding how to apply it to your company can be a mystery. Most people struggle with understanding the potential business uses or tend to get caught up in the technology, resulting in solutions that fail to meet even minimum business goals. In his session at Internet of @ThingsExpo, Jesse Shiah, CEO / President / Co-Founder of AgilePoint Inc., will show what is needed to leverage the IoT to transform your business. He will discuss opportunities and challenges ahead for the IoT from a market and tec...
SYS-CON Events announced today that Utimaco will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Utimaco is a leading manufacturer of hardware based security solutions that provide the root of trust to keep cryptographic keys safe, secure critical digital infrastructures and protect high value data assets. Only Utimaco delivers a general-purpose hardware security module (HSM) as a customizable platform to easily integrate into existing software solutions, embed business logic and build s...
One of the biggest challenges when developing connected devices is identifying user value and delivering it through successful user experiences. In his session at Internet of @ThingsExpo, Mike Kuniavsky, Principal Scientist, Innovation Services at PARC, will describe an IoT-specific approach to user experience design that combines approaches from interaction design, industrial design and service design to create experiences that go beyond simple connected gadgets to create lasting, multi-device experiences grounded in people’s real needs and desires.
SYS-CON Events announced today that TeleStax, the main sponsor of Mobicents, will exhibit at Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. TeleStax provides Open Source Communications software and services that facilitate the shift from legacy SS7 based IN networks to IP based LTE and IMS networks hosted on private (on-premise), hybrid or public clouds. TeleStax products include Restcomm, JSLEE, SMSC Gateway, USSD Gateway, SS7 Resource Adaptors, SIP Servlets, Rich Multimedia Services, Presence Services/RCS, Diame...
Samsung VP Jacopo Lenzi, who headed the company's recent SmartThings acquisition under the auspices of Samsung's Open Innovaction Center (OIC), answered a few questions we had about the deal. This interview was in conjunction with our interview with SmartThings CEO Alex Hawkinson. IoT Journal: SmartThings was developed in an open, standards-agnostic platform, and will now be part of Samsung's Open Innovation Center. Can you elaborate on your commitment to keep the platform open? Jacopo Lenzi: Samsung recognizes that true, accelerated innovation cannot be driven from one source, but requires a...
The Internet of Things will greatly expand the opportunities for data collection and new business models driven off of that data. In her session at Internet of @ThingsExpo, Esmeralda Swartz, CMO of MetraTech, will discuss how for this to be effective you not only need to have infrastructure and operational models capable of utilizing this new phenomenon, but increasingly service providers will need to convince a skeptical public to participate. Get ready to show them the money! Speaker Bio: Esmeralda Swartz, CMO of MetraTech, has spent 16 years as a marketing, product management, and busin...
Things are being built upon cloud foundations to transform organizations. This CEO Power Panel at 15th Cloud Expo, moderated by Roger Strukhoff, Cloud Expo and @ThingsExpo conference chair, will address the big issues involving these technologies and, more important, the results they will achieve. How important are public, private, and hybrid cloud to the enterprise? How does one define Big Data? And how is the IoT tying all this together?
We certainly live in interesting technological times. And no more interesting than the current competing IoT standards for connectivity. Various standards bodies, approaches, and ecosystems are vying for mindshare and positioning for a competitive edge. It is clear that when the dust settles, we will have new protocols, evolved protocols, that will change the way we interact with devices and infrastructure. We will also have evolved web protocols, like HTTP/2, that will be changing the very core of our infrastructures. At the same time, we have old approaches made new again like micro-services...
SYS-CON Events announces a new pavilion on the Cloud Expo floor where WebRTC converges with the Internet of Things. Pavilion will showcase WebRTC and the Internet of Things. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devices--computers, smartphones, tablets, and sensors – connected to the Internet by 2020. This number will continue to grow at a rapid pace for the next several decades.
The only place to be June 9-11 is Cloud Expo & @ThingsExpo 2015 East at the Javits Center in New York City. Join us there as delegates from all over the world come to listen to and engage with speakers & sponsors from the leading Cloud Computing, IoT & Big Data companies. Cloud Expo & @ThingsExpo are the leading events covering the booming market of Cloud Computing, IoT & Big Data for the enterprise. Speakers from all over the world will be hand-picked for their ability to explore the economic strategies that utility/cloud computing provides. Whether public, private, or in a hybrid form, clo...
SYS-CON Events announced today that Gridstore™, the leader in software-defined storage (SDS) purpose-built for Windows Servers and Hyper-V, will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Gridstore™ is the leader in software-defined storage purpose built for virtualization that is designed to accelerate applications in virtualized environments. Using its patented Server-Side Virtual Controller™ Technology (SVCT) to eliminate the I/O blender effect and accelerate applications Gridsto...
SYS-CON Events announced today that Red Hat, the world's leading provider of open source solutions, will exhibit at Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Red Hat is the world's leading provider of open source software solutions, using a community-powered approach to reliable and high-performing cloud, Linux, middleware, storage and virtualization technologies. Red Hat also offers award-winning support, training, and consulting services. As the connective hub in a global network of enterprises, partners, a...
As the Internet of Things unfolds, mobile and wearable devices are blurring the line between physical and digital, integrating ever more closely with our interests, our routines, our daily lives. Contextual computing and smart, sensor-equipped spaces bring the potential to walk through a world that recognizes us and responds accordingly. We become continuous transmitters and receivers of data. In his session at Internet of @ThingsExpo, Andrew Bolwell, Director of Innovation for HP’s Printing and Personal Systems Group, will discuss how key attributes of mobile technology – touch input, senso...
The Internet of Things (IoT) is making everything it touches smarter – smart devices, smart cars and smart cities. And lucky us, we’re just beginning to reap the benefits as we work toward a networked society. However, this technology-driven innovation is impacting more than just individuals. The IoT has an environmental impact as well, which brings us to the theme of this month’s #IoTuesday Twitter chat. The ability to remove inefficiencies through connected objects is driving change throughout every sector, including waste management. BigBelly Solar, located just outside of Boston, is trans...
Connected devices and the Internet of Things are getting significant momentum in 2014. In his session at Internet of @ThingsExpo, Jim Hunter, Chief Scientist & Technology Evangelist at Greenwave Systems, will examine three key elements that together will drive mass adoption of the IoT before the end of 2015. The first element is the recent advent of robust open source protocols (like AllJoyn and WebRTC) that facilitate M2M communication. The second is broad availability of flexible, cost-effective storage designed to handle the massive surge in back-end data in a world where timely analytics...
Internet of @ThingsExpo Silicon Valley announced on Thursday its first 12 all-star speakers and sessions for its upcoming event, which will take place November 4-6, 2014, at the Santa Clara Convention Center in California. @ThingsExpo, the first and largest IoT event in the world, debuted at the Javits Center in New York City in June 10-12, 2014 with over 6,000 delegates attending the conference. Among the first 12 announced world class speakers, IBM will present two highly popular IoT sessions, which will take place November 4-6, 2014 at the Santa Clara Convention Center in Santa Clara, Calif...
From a software development perspective IoT is about programming "things," about connecting them with each other or integrating them with existing applications. In his session at @ThingsExpo, Yakov Fain, co-founder of Farata Systems and SuranceBay, will show you how small IoT-enabled devices from multiple manufacturers can be integrated into the workflow of an enterprise application. This is a practical demo of building a framework and components in HTML/Java/Mobile technologies to serve as a platform that can integrate new devices as they become available on the market.