 | Level: Intermediate Ramakrishnan Kannan (rkrishnan@in.ibm.com), Staff Software Engineer,
IBM
Prasad K. Nagaraj (prasad.kn@in.ibm.com), Software Engineer, IBM Saikrishna Vaidyanathan (savaidya@in.ibm.com), Software Engineer, IBM
15 Apr 2008
Mashups, a critical component of Web 2.0, aggregate feeds
from many applications to generate new content. Because many
of today's core enterprise business applications run in
mainframes, the content in mainframes must be delivered as
feeds before mashups can be successful in the
enterprise. This article presents a step-by-step guide to
using IBM® WebSphere® Host Access Transformation Services (HATS) to generate Atom
feeds for mainframe content.
 |
Frequently used acronyms
- DOM: Document Object Model
- GUI: Graphical User Interface
- RSS: Really Simple Syndication
- XML: Extensible Markup Language
|
|
Nowadays, content distributors deliver all content,
including news and site updates, as feeds. Most
enterprise applications use feeds for various purposes,
including to monitor an application and check the
status of a project. Content providers publish a feed
link on their site that users register with a feed
reader. The feed reader checks for updates to the
registered feeds at regular intervals. When it detects
an update in the content, the feed reader requests the
updated content from the content provider. The feeds
contain only a summary of the content, but they provide
a link to the detailed content. Atom Syndication Format and
RSS are the most common
specifications of feeds. We're using Atom feeds in this
article, but you can change easily to RSS feeds with a
little modification.
 |
History of RSS/Atom
RSS is the marriage between the Resource Description
Framework (RDF), an XML format homegrown at Netscape,
and Scripting News, a Weblog created by Dave Winer,
founder of Userland Software. The incompatibility
between different versions of RSS prompted Ben Trott,
cofounder of Six Apart, to first advocate Atom feeds.
|
|
Most Fortune 500 companies have many applications and
data hosted in mainframes. Delivering the content in
mainframes as feeds can be a challenge, but it's
critical to the successful adoption of Web 2.0 in the
enterprise.
To meet this challenge, a tool or programming
methodology must be able to deliver identified content
in mainframes as Atom/RSS feeds. This article leverages
a product called IBM WebSphere Host Access
Transformation Services (HATS), which converts any given
green-screen, character-based 3270 or 5250 host
application into a Web application (HTML) or rich-client
application. HATS also allows programmatic interfaces to
convert the identified content in these host
applications into any other format. We'll take a
step-by-step approach to show you how to write a HATS
program that converts the host application content into
Atom feeds.
Figure 1
shows a bird’s-eye view of this solution.
Figure 1. Bird's-eye view of the HATS-Atom solution
To create this solution, you need the following
products:
-
IBM Rational® Software Delivery Platform: This middleware can help you automate the
development process.
-
HATS: Use HATS to create Web and rich-client
applications that provide a GUI for character-based 3270 and 5250 host
applications.
-
Apache Abdera (optional): Abdera is an implementation of the Internet
Engineering Task Force (IETF) Atom Syndication
Format and Atom Publishing Protocol specifications.
Overview of the solution
 |
Mainframe trivia
"I predict that the last mainframe will be unplugged on
March 15, 1996." -- Stewart Alsop,
InfoWorld, March 1991.
IBM released its latest System z10 mainframe in February
2008.
|
|
The HATS runtime code runs inside one or more HATS
applications deployed on IBM® WebSphere®
Application Server and sends data back and forth between
the user and an application on the host. Feed readers
interact with the HATS application. After you develop a
HATS application that can deliver feeds, you deploy it
on WebSphere Application Server the same way you
would deploy any other application.
When the feed reader checks the feed-enabled HATS
application, the HATS application triggers the backend
host application from which it collects the content. A configuration file (called a HATS macro)
defines the data that is required from the screens of
the host application. The HATS application collects the
required data from the screens and makes it available
through a variable (called a HATS global variable). It
then triggers the program (called HATS business
logic) and hands over the collected data. You construct
the feed using the Atom feed library from the collected
data, and the same is delivered to the feed reader.
With the HATS macro configuration file, you can provide
programmed navigation through multiple host screens. For
example, it can navigate the screens of a host
application to display the first screen the user
needs to see, bypassing all the screens in between. The
HATS runtime collects and stores the data in the global
variable. It extracts data from host screens and enters
the data on other screens. The HATS business logic
program constructs the feed using the Atom feed library.
Figure 2
can help you understand the flow of the solution.
Figure 2. Overview of the solution flow
Identifying a business process and recording a macro
First, you need to create a HATS project for an
identified business process and record a macro. You can
find a detailed procedure about working with HATS macros
in the online HATS help documentation.
We use an application called Echo on a mainframe that echoes back the input text
entered in the first screen. For demonstration purposes,
we use the text “Hello World” as an input that is
echoed back in the next screen.
Figure 3
shows Echo’s main screen, where the user
inputs the data under the heading "ENTER DATA TO ECHO
BELOW." The user inputs the string “Hello World!!!” You
can change this input to any application-specific string
by setting this value in a HATS global variable.
Figure 3. Input screen of the Echo program
Figure 4
displays the data that the user inputs. “Hello World!!!”
is shown as the displayed output, which corresponds to
the input in
Figure 3. You extract this output and expose it as Atom feeds.
Figure 4. Output screen of the Echo program
You can consider the Echo program as a business process,
and you can record a macro. This macro runs
automatically and collects relevant data from the
mainframe application without any user intervention. Use
the screen customization feature of HATS, where you can
configure HATS to run the macro when the first screen of
the application is detected.
Figure 5
shows how the macro is linked to the application-entry
screen.
Figure 5. Screen customization on the entry screen
of the program
Click New Screen Customization to bring up the Screen Customization wizard, where the
recorded macro is linked to the screen shown in
Figure 5
and plays automatically when HATS detects the entry
screen during runtime.
Figure 6
shows that the echoFeeds macro is triggered and
played back when the application entry screen in
Figure 5
matches during runtime.
Figure 6. Configuring the auto-play macro
Adding business logic
You need to create business logic that contains the code
to expose the output of the business process as Atom
feeds. The business logic creates an Atom feed using
regular XML libraries as noted in the Atom feed
specification. Alternatively, you can also use Atom feed
libraries, such as Apache Abdera, which require you to
write less code than you might with XML libraries.
However, the IBM Rational Software Delivery Platform
doesn't bundle these libraries or the dependent
libraries that they require.
Start by creating the business logic that gets triggered
when you collect all the necessary data from the
mainframe application through macros. To begin, go to
HATS Studio and click File > New > HATS Business Logic, as shown in
Figure 7.
Figure 7. Creating new business logic
Figure 8
shows the Create Business Logic wizard, where you can
see that AtomFeeds is the name of the Java™ file that
contains the business logic. It can belong to a certain
package, but for simplicity, here AtomFeeds belongs to
the default package.
Figure 8. The Create Business Logic wizard
Next, you create a Java file named AtomFeeds.java under
the Java Source folder of the HATS project. HATS
generates the code automatically. You add the code
required to perform the business logic to the
execute
method. Next, as shown in
Listing 1, you add the code to deliver the Atom feeds in this
execute()
method of the generated business logic.
Listing 1. Code for the Atom feeds in the business
logic
IResponse response = blInfo.getResponse();
String outputValue=blInfo.getGlobalVariable("output").getString("outputValue");
try
{
OutputStreamWriter responseStream = new OutputStreamWriter(response.getOutputStream());
try
{
DocumentBuilderFactory feedFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder feedBuilder = feedFactory.newDocumentBuilder();
Document doc = feedBuilder.newDocument();
Element root = doc.createElementNS("http://www.w3.org/2005/Atom",feed);
doc.appendChild(root);
Element title = doc.createElement("title");
root.appendChild(title);
Text titleText = doc.createTextNode("Sample Feed from HATS");
title.appendChild(titleText);
//in similar lines add updated and summary element
Element updated = doc.createElement("updated");
root.appendChild(updated);
Text updateText = doc.createTextNode(new Date().toString());
updated.appendChild(updateText);
Element summary = doc.createElement("summary");
root.appendChild(summary);
Text summaryText = doc.createTextNode("This has the feeds from zSeries");
summary.appendChild(summaryText);
Element entry = doc.createElement("entry");
root.appendChild(entry);
Element titleEntry =doc.createElement("title");
titleEntry.setTextContent("I am first Entry");
entry.appendChild(titleEntry);
Element link=doc.createElement("link");
link.setAttribute("href", "http://www.ibm.com");
entry.appendChild(link);
Element id=doc.createElement("id");
id.setTextContent("urn:test-test");
entry.appendChild(id);
Element updatedEntry = doc.createElement("updated");
entry.appendChild(updatedEntry);
Text updateEntryText = doc.createTextNode(new Date().toString());
updatedEntry.appendChild(updateEntryText);
Element summaryEntry = doc.createElement("summary");
//The next line sets the output from mainframe as summary in Atom Feed
summaryEntry.setTextContent(outputValue);
entry.appendChild(summaryEntry);
TransformerFactory feedTransformerFactory = TransformerFactory.newInstance();
Transformer feedTransformer = feedTransformerFactory.newTransformer();
feedTransformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
feedTransformer.setOutputProperty(OutputKeys.INDENT,"yes");
StringWriter sw = new StringWriter(); StreamResult
result = new StreamResult(sw);
DOMSource source = new DOMSource(doc);
feedTransformer.transform(source,result);
String xmlString = sw.toString();
//The next line delivers the constructed Atom feed to feed reader
responseStream.write(xmlString);
} catch (Exception e) { System.out.println(e); }
responseStream.close();
} catch (IOException e) { e.printStackTrace();
}
|
Finally, you create a DOM
structure using XML according to the Atom feed
specification and add it to the
execute()
method of the business logic Java file AtomFeeds. This
forms the crux of the business logic for this objective.
Customizing the screen to trigger the business logic
Now you need to trigger the business logic after the
macro ends. Use the Screen Customization wizard to
customize the screen from Figure 4
and trigger the business logic AtomFeeds to execute.
Figure 9
shows the Screen Customization wizard, which adds
triggerBusinessLogic under the Screen Customizations
folder of the HATS project.
Figure 9. Triggering business logic
Check Add advanced actions as Figure 10 shows, so that the next screen in this wizard provides a way
for you to trigger the business logic AtomFeeds.java.
Figure 10. Intermediate step for triggering business
logic
Select the radio button for Execute business logic
in the Add Action wizard, as in Figure 11.
Figure 11. Customizing the screen for the business
logic
Specify AtomFeeds as the name of the class that contains
the business logic, as in
Figure 12. This is the same name that you gave when you created
new business logic, as in Figure 8.
Figure 12. Configuring the business logic class
This completes the step-by-step procedure that uses HATS
to deliver the Atom feeds of mainframe applications.
You then deploy the HATS project to the WebSphere
Application Server. To test this project, deploy it in Integrated Test Environment, which comes
bundled with the IBM Software Development Platform. The
URL in which this application is deployed will be the
URL for the feed reader. By default, the URL is
typically in the format http://servername/<HATSProjectName>.
Using a feed reader to test the output
Give the URL where the HATS application is deployed in the
Application Server (see Figure 13).
Figure 13. The Atom feed server configuration in the
feed reader
You collect the output “Hello World” from the mainframe application (see Figure 4) and make it into a summary of the Atom feed, as in Figure 14.
Figure 14. Atom feed of data from the
mainframe application
Conclusion
 |
Mashup editors
Famous commercial mashup editors include IBM Mashup
Starter Kit, Google Mashup Editor, Yahoo! Pipes, and Microsoft® Popfly™.
|
|
Delivering data as Atom feeds in mainframes opens a new
world of possibilities for enterprise applications.
Organizations can use mashup editors to extract data from
companies with external or internal feeds and create new
applications or information. For example, call centers
can take advantage of mashups by passing a calling
customer’s ZIP code information to Google Maps to
identify the location of the customer. This can help the
call center employees personalize the conversation by
enquiring about the weather from the customer's location,
and so on. The delivery of data as Atom feeds in
mainframe servers is one of the fundamental building
blocks that enables an organization to embrace Web 2.0.
Resources Learn
Get products and technologies
Discuss
About the authors  | 
|  | Ramakrishnan Kannan works on host integration at IBM India Software Labs in Bangalore, India. He has been a developer for IBM personal communications and communication servers products. In addition to his development work, he works with customers in the IBM Asia-Pacific region for the Web service enablement of host applications. He has conducted Web services awareness sessions to business partners such as Infosys. He is an IBM Certified Solution Developer for XML and a Sun Certified Java Professional. His interests are host integration, distributed computing, service-oriented architecture (SOA), and networking. For more information, visit his home page. |
 | 
|  | Prasad K. Nagaraj works on host integration at IBM India Software Labs in Bangalore, India. He is a
developer for IBM WebSphere Host On-Demand. Apart from
his regular work, he works with customers for WebSphere
Host Access Transformation Services. He's an expert in
Java, Unified Modeling Language (UML), Java Platform,
Enterprise Edition (Java EE), and Web services. His
interests are in Web 2.0 technologies and solving
puzzles. He has great passion for international films,
travel, and music. |
 | 
|  | Saikrishna Vaidyanathan has worked with IBM India Software Labs since
January 2005. He worked with Polaris Software Lab Ltd.
before joining IBM. He holds an MCA degree from
Bharathidasan University. Currently he is working on
WebSphere Host On-Demand, a Java-based terminal emulator
for hosts from IBM. He has wide engineering experience
from design to development and deployment. He has
assisted many customers by developing proofs of concept
to demonstrate technologies and has been actively
involved during the deployment of his products. Apart
from his regular work, he is interested in contributing
to SOA and Web 2.0 technologies. His focus also lies in
the engineering aspects of life sciences. He has a great
interest in teaching. |
Rate this page
|  |