In this chapter we are going to write and deploy a simple Grid Service. Our first Grid Service is an extremely simple Math Grid Service, which we'll refer to as MathService. It will allow users to perform the following operations:
Addition
Subtraction
High-tech stuff, huh? Don't worry if this seems a bit lackluster. Since this is going to be our first Grid Service, it's better to start with a small didactic service which we'll gradually improve by adding service data, notifications, etc. You should always bear in mind that MathService is, after all, just a means to get acquainted with GT3. Typical grid services are generally much more complex and do more than expose trivial operations (such as addition and subtraction). Although the tutorial is currently based only on MathService, future versions of the tutorial will include examples of grid services which you could find in 'real' applications.
Writing and deploying a Grid Service is easier than you might think. You just have to follow five simple steps.
Define the service's interface. This is done with GWSDL
Implement the service. This is done with Java
Define the deployment parameters. This is done with WSDD
Compile everything and generate GAR file. This is done with Ant
Deploy service. This is also done with Ant
Don't worry if you don't understand these five steps or are baffled by terms such as GWSDL, WSDD, and Ant. In this first example we're going to go through each step in great detail, explaining what each step accomplishes, and giving detailed instructions on how to perform each step. The rest of the examples in the tutorial will also follow these five steps. However, the rest of the examples will simply instruct you to perform a step, and won't repeat the whole explanation of what that step is. So, if you ever find that you don't understand a particular step, you can always come back to this chapter ("Writing Your First Grid Service in 5 Simple Steps") to review the details of that step.
Ready to start? Ok! Just hold your horses for a second. Don't forget to download the tutorial files before you start. You can find a link to the tutorial files in the tutorial website. The tutorial bundle includes all the tutorial source files, plus a couple of extra files we'll need to successfully build and deploy our service. Just create an empty directory on your filesystem and untar-ungzip the file there. From now on, we'll refer to that directory as $TUTORIAL_DIR.
Once you have the files, take into account that there are two ways of following the first chapters of the tutorial:
With the tutorial source files: You'll have all the source code (Java, GWSDL, and WSDD) ready to use in $TUTORIAL_DIR, so there's no need to manually modify these files.
Without the tutorial source files: Some people don't like getting all the source code ready to use out-of-the-box, but rather prefer to write the files themselves so they can have a better understanding of what they're doing at each point. In fact, I think this is probably the best way to follow this first part of the tutorial. Since this first part includes complete code listing in the tutorial (which you can copy and paste to a file), you can easily write all the files yourself. However, you do need a set of auxiliary files included in the tutorial bundle which are needed to build and deploy the services. So, if you want to follow the tutorial without the source files, you still need to download the tutorial files. Once you're in $TUTORIAL_DIR, simply delete directory "org" to delete the source files, but don't delete anything else.
Ok, now we're ready to start :-)