Dashboard > Appistry EAF v3.8 > ... > Tutorials on using the Fabric > Extended Hello World using Client Data
Log In   View a printable version of the current page.  
  Extended Hello World using Client Data

Introduction

In the tutorial Hello World with Process Flows and Tasks, the fabric tasks did not accept any data from the client, but returned a static string "Hello World!". This works fine for a simple Hello World application, however, real world tasks need to accept input and return output. In this tutorial, we explore the various options for marshaling data into and and out of fabric task code. The the Fabric Task API provides several ways to accomplish this and tries to minimize and eliminate a need to adapt code to the Fabric APIs.

You may create your own fabric application and client application, or you may use the files and projects provided in tutorial_samples.zip and tutorial_samples.tgz archives. These files and projects are not included in the Fabric Software Development Kit (SDK) installation, but will be available for later versions. The fabric APIs are not dependent on a particular build tool or development environment (IDE), so you may use your preferred build tools. For your convenience, we have included project files for several platforms. These can be seen in the table to the right.

In this Kick Start tutorial we will

  • create and examine a series of Hello World tasks to handle input and output

 What our extended Hello World tasks will do

  • accept input from the fabric client request object
  • construct a new Hello World string from the input data
  • return the new string to the client via the fabric request
 Projects Provided For Tutorial Samples
Language Platform
Project Type
Java 1.5
All
Eclipse
Java 1.5
All
Ant scripts
.NET 2.0
Windows
Visual Studio 2005
'C'
Windows Visual Studio 2005
'C' Linux
Make scripts
Click the language of your choice for this page:

To create your own fabric application and client, you will need to have done the following:
  1. Read through all the pages in Appistry EAF Essentials to become familiar with the fabric application components and services.
  2. Install the Fabric SDK on your development workstation. Please refer to the Installation procedure.
  3. Download either the tutorial_samples.zip or tutorial_samples.tgz archive from here, and copy the archive into the top level SDK directory ("/usr/local/appistry_eaf_sdk" on unix or "C:\Program Files\Fabric" on Windows) that was created during the SDK install in step #2.
  4. Extract the .zip or .tgz tutorial samples archive into the top level SDK directory. A "tutorial_samples" subdirectory should be created with a path of "/usr/local/appistry_eaf_sdk/tutorial_samples" on unix or "C:\Program Files\Fabric\tutorial_samples" on Windows. Make sure when you extract your archive, particularly using the .zip file, that you do not end up with two tutorial_samples directories like this: "C:\Program Files\Fabric\tutorial_samples\tutorial_samples\...."
  5. Have your build environment setup for Java, .NET, and/or 'C'. We presume in this tutorial that you know how to use the build environment of your choice. We have provided projects for several, as mentioned, for your convenience.
  6. Install at least one fabric worker on a computer. This may be on your development workstation or one or more separate boxes. If the worker is not on your local workstation, then the worker or workers must be accessible over the network from your development workstation. Please refer to the Installing the Fabric procedure.
  7. If you want to go ahead and build the projects, click here for important information below about building the projects.
  8. Now, jump on into the tutorial!

What each task sample in this tutorial has in common

Each Hello World task in this tutorial has the same functionality, but they achieve the result using different approaches. The tasks in this tutorial accept as input two strings from the fabric request map: greeting and greetee. The value of greeting may be "Hello" or "Howdy", and the value of greetee maybe "World" or "Fred". The tasks return a string named "hello" to the fabric request (and consequently to the client). The value of the output string "hello" is "Hello Fred!" or "Howdy World!", depending on the input. Some of the samples get the fabric client user's name from the fabric request, and uses that to produce an output string like "Tom says hello Fred!".

How data is mapped from and into the fabric request object depends on the programming language, and your implementation choice. In Java and .NET, the mapping is accomplished using Java annotations or .NET attributes.  In 'C', the Task API manipulates the fabric request object directly. Please note that the Java Task API 3.5 version of the sample task also required this direct approach in some cases, whereas the Java Task API 3.7 version does not, and can be accomplished using annotations.

What is a fabric request object?
When a fabric client submits an execution request into a fabric, the request and it's user data is passed in a fabric request object. The fabric request object exists for the duration of the request, and is passed to each task executed to fulfill the request. When the fabric has fulfilled the client's request, the fabric request object is returned to the client. A fabric developer can get values from, and set values to the fabric request object using the fabric client API and fabric task API. The Java and .NET task API in particular support several methods for manipulating values in the fabric request object. This Kick Start tutorial demonstrates just one way to return a value to the client from the task via the fabric request object.

Data flow between fabric client and fabric tasks









Extended Hello World Fabric Tasks

Read more about tasks under the Task APIs for .NET, 'C' (CentOS, RHEL, SUSE and Windows), and Java.

How these sample tasks are organized:
  • The sample tasks are arranged by the following priority:
    • least intrusive use of the fabric task API,
    • up to a full dependence on the fabric task API.
  • Each sample builds on the prior one, sometimes using a prior approach, for example, for input, but a different approach for output.
  • For Java and .NET, the examples line up by name for similar fabric task API usage.
  • For 'C', has only one extended example.





Building, packaging and deploying the Extended Hello World Fabric Application

Now we must build, package, and deploy our fabric application. Follow the instructions in the information box below, and then return to this tutorial.

The Building, Packaging, and Deploying a Fabric Application tutorial gives directions for building, packaging and deploying fabric applications.

Running these samples

The complete fabric applications for these samples can be found in the tutorial_samples/<lang>/extended_hello_world_app/ directory. This includes all of the process flow, task, and application definition files ready for fabric packaging. You just need to build the source code for the tasks.

Likewise, a client has been provided in each language that runs each of these fabric applications. The client source can be found in the tutorial_samples/<lang>/extended_hello_world directories.